44import sys
55from datetime import datetime
66from io import BytesIO
7+ from typing import Optional
78
89import click
910from test_framework .messages import ser_uint256
@@ -24,23 +25,24 @@ def bitcoin():
2425@click .argument ("tank" , type = str )
2526@click .argument ("method" , type = str )
2627@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 ]):
2830 """
2931 Call bitcoin-cli <method> [params] on <tank pod name>
3032 """
3133 try :
32- result = _rpc (tank , method , params )
34+ result = _rpc (tank , method , params , namespace )
3335 except Exception as e :
3436 print (f"{ e } " )
3537 sys .exit (1 )
3638 print (result )
3739
3840
39- def _rpc (tank : str , method : str , params : str ):
41+ def _rpc (tank : str , method : str , params : str , namespace : Optional [ str ] = None ):
4042 # bitcoin-cli should be able to read bitcoin.conf inside the container
4143 # 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 ()
4446 if params :
4547 cmd = f"kubectl -n { namespace } exec { tank } --container { BITCOINCORE_CONTAINER } -- bitcoin-cli { method } { ' ' .join (map (str , params ))} "
4648 else :
0 commit comments