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
@@ -23,23 +24,24 @@ def bitcoin():
2324@click .argument ("tank" , type = str )
2425@click .argument ("method" , type = str )
2526@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 ]):
2729 """
2830 Call bitcoin-cli <method> [params] on <tank pod name>
2931 """
3032 try :
31- result = _rpc (tank , method , params )
33+ result = _rpc (tank , method , params , namespace )
3234 except Exception as e :
3335 print (f"{ e } " )
3436 sys .exit (1 )
3537 print (result )
3638
3739
38- def _rpc (tank : str , method : str , params : str ):
40+ def _rpc (tank : str , method : str , params : str , namespace : Optional [ str ] = None ):
3941 # bitcoin-cli should be able to read bitcoin.conf inside the container
4042 # 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 ()
4345 if params :
4446 cmd = f"kubectl -n { namespace } exec { tank } --container { BITCOINCORE_CONTAINER } -- bitcoin-cli { method } { ' ' .join (map (str , params ))} "
4547 else :
0 commit comments