3
3
import sys
4
4
from datetime import datetime
5
5
from io import BytesIO
6
+ from typing import Optional
6
7
7
8
import click
8
9
from test_framework .messages import ser_uint256
@@ -23,23 +24,24 @@ def bitcoin():
23
24
@click .argument ("tank" , type = str )
24
25
@click .argument ("method" , type = str )
25
26
@click .argument ("params" , type = str , nargs = - 1 ) # this will capture all remaining arguments
26
- def rpc (tank : str , method : str , params : str ):
27
+ @click .option ("--namespace" , default = None , show_default = True )
28
+ def rpc (tank : str , method : str , params : str , namespace : Optional [str ]):
27
29
"""
28
30
Call bitcoin-cli <method> [params] on <tank pod name>
29
31
"""
30
32
try :
31
- result = _rpc (tank , method , params )
33
+ result = _rpc (tank , method , params , namespace )
32
34
except Exception as e :
33
35
print (f"{ e } " )
34
36
sys .exit (1 )
35
37
print (result )
36
38
37
39
38
- def _rpc (tank : str , method : str , params : str ):
40
+ def _rpc (tank : str , method : str , params : str , namespace : Optional [ str ] = None ):
39
41
# bitcoin-cli should be able to read bitcoin.conf inside the container
40
42
# so no extra args like port, chain, username or password are needed
41
- namespace = get_default_namespace ()
42
-
43
+ if not namespace :
44
+ namespace = get_default_namespace ()
43
45
if params :
44
46
cmd = f"kubectl -n { namespace } exec { tank } --container { BITCOINCORE_CONTAINER } -- bitcoin-cli { method } { ' ' .join (map (str , params ))} "
45
47
else :
0 commit comments