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