33import sys
44from datetime import datetime
55from io import BytesIO
6+ from typing import Optional
67
78import click
89from test_framework .messages import ser_uint256
@@ -22,22 +23,24 @@ def bitcoin():
2223@click .argument ("tank" , type = str )
2324@click .argument ("method" , type = str )
2425@click .argument ("params" , type = str , nargs = - 1 ) # this will capture all remaining arguments
25- def rpc (tank : str , method : str , params : str ):
26+ @click .option ("--namespace" , default = None , show_default = True )
27+ def rpc (tank : str , method : str , params : str , namespace : Optional [str ]):
2628 """
2729 Call bitcoin-cli <method> [params] on <tank pod name>
2830 """
2931 try :
30- result = _rpc (tank , method , params )
32+ result = _rpc (tank , method , params , namespace )
3133 except Exception as e :
3234 print (f"{ e } " )
3335 sys .exit (1 )
3436 print (result )
3537
3638
37- def _rpc (tank : str , method : str , params : str ):
39+ def _rpc (tank : str , method : str , params : str , namespace : Optional [ str ] = None ):
3840 # bitcoin-cli should be able to read bitcoin.conf inside the container
3941 # so no extra args like port, chain, username or password are needed
40- namespace = get_default_namespace ()
42+ if not namespace :
43+ namespace = get_default_namespace ()
4144 if params :
4245 cmd = f"kubectl -n { namespace } exec { tank } -- bitcoin-cli { method } { ' ' .join (map (str , params ))} "
4346 else :
0 commit comments