1
1
#!/usr/bin/env python3
2
- # Copyright (c) 2017-2022 The Bitcoin Core developers
2
+ # Copyright (c) 2017-present The Bitcoin Core developers
3
3
# Distributed under the MIT software license, see the accompanying
4
4
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
"""Class for bitcoind node under test"""
@@ -209,7 +209,7 @@ def __del__(self):
209
209
def __getattr__ (self , name ):
210
210
"""Dispatches any unrecognised messages to the RPC connection or a CLI instance."""
211
211
if self .use_cli :
212
- return getattr (RPCOverloadWrapper (self .cli , True ), name )
212
+ return getattr (RPCOverloadWrapper (self .cli ), name )
213
213
else :
214
214
assert self .rpc_connected and self .rpc is not None , self ._node_msg ("Error: no RPC connection" )
215
215
return getattr (RPCOverloadWrapper (self .rpc ), name )
@@ -374,7 +374,7 @@ def setmocktime(self, timestamp):
374
374
375
375
def get_wallet_rpc (self , wallet_name ):
376
376
if self .use_cli :
377
- return RPCOverloadWrapper (self .cli ("-rpcwallet={}" .format (wallet_name )), True )
377
+ return RPCOverloadWrapper (self .cli ("-rpcwallet={}" .format (wallet_name )))
378
378
else :
379
379
assert self .rpc_connected and self .rpc , self ._node_msg ("RPC not connected" )
380
380
wallet_path = "wallet/{}" .format (urllib .parse .quote (wallet_name ))
@@ -925,60 +925,56 @@ def send_cli(self, clicommand=None, *args, **kwargs):
925
925
return cli_stdout .rstrip ("\n " )
926
926
927
927
class RPCOverloadWrapper ():
928
- def __init__ (self , rpc , cli = False ):
928
+ def __init__ (self , rpc ):
929
929
self .rpc = rpc
930
- self .is_cli = cli
931
930
932
931
def __getattr__ (self , name ):
933
932
return getattr (self .rpc , name )
934
933
935
- def createwallet_passthrough (self , * args , ** kwargs ):
936
- return self .__getattr__ ("createwallet" )(* args , ** kwargs )
937
-
938
- def importprivkey (self , privkey , label = None , rescan = None ):
934
+ def importprivkey (self , privkey , * , label = None , rescan = None ):
939
935
wallet_info = self .getwalletinfo ()
940
936
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info ['descriptors' ]):
941
937
return self .__getattr__ ('importprivkey' )(privkey , label , rescan )
942
938
desc = descsum_create ('combo(' + privkey + ')' )
943
939
req = [{
944
940
'desc' : desc ,
945
941
'timestamp' : 0 if rescan else 'now' ,
946
- 'label' : label if label else ''
942
+ 'label' : label if label else '' ,
947
943
}]
948
944
import_res = self .importdescriptors (req )
949
945
if not import_res [0 ]['success' ]:
950
946
raise JSONRPCException (import_res [0 ]['error' ])
951
947
952
- def addmultisigaddress (self , nrequired , keys , label = None , address_type = None ):
948
+ def addmultisigaddress (self , nrequired , keys , * , label = None , address_type = None ):
953
949
wallet_info = self .getwalletinfo ()
954
950
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info ['descriptors' ]):
955
951
return self .__getattr__ ('addmultisigaddress' )(nrequired , keys , label , address_type )
956
952
cms = self .createmultisig (nrequired , keys , address_type )
957
953
req = [{
958
954
'desc' : cms ['descriptor' ],
959
955
'timestamp' : 0 ,
960
- 'label' : label if label else ''
956
+ 'label' : label if label else '' ,
961
957
}]
962
958
import_res = self .importdescriptors (req )
963
959
if not import_res [0 ]['success' ]:
964
960
raise JSONRPCException (import_res [0 ]['error' ])
965
961
return cms
966
962
967
- def importpubkey (self , pubkey , label = None , rescan = None ):
963
+ def importpubkey (self , pubkey , * , label = None , rescan = None ):
968
964
wallet_info = self .getwalletinfo ()
969
965
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info ['descriptors' ]):
970
966
return self .__getattr__ ('importpubkey' )(pubkey , label , rescan )
971
967
desc = descsum_create ('combo(' + pubkey + ')' )
972
968
req = [{
973
969
'desc' : desc ,
974
970
'timestamp' : 0 if rescan else 'now' ,
975
- 'label' : label if label else ''
971
+ 'label' : label if label else '' ,
976
972
}]
977
973
import_res = self .importdescriptors (req )
978
974
if not import_res [0 ]['success' ]:
979
975
raise JSONRPCException (import_res [0 ]['error' ])
980
976
981
- def importaddress (self , address , label = None , rescan = None , p2sh = None ):
977
+ def importaddress (self , address , * , label = None , rescan = None , p2sh = None ):
982
978
wallet_info = self .getwalletinfo ()
983
979
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info ['descriptors' ]):
984
980
return self .__getattr__ ('importaddress' )(address , label , rescan , p2sh )
@@ -992,13 +988,13 @@ def importaddress(self, address, label=None, rescan=None, p2sh=None):
992
988
reqs = [{
993
989
'desc' : desc ,
994
990
'timestamp' : 0 if rescan else 'now' ,
995
- 'label' : label if label else ''
991
+ 'label' : label if label else '' ,
996
992
}]
997
993
if is_hex and p2sh :
998
994
reqs .append ({
999
995
'desc' : descsum_create ('p2sh(raw(' + address + '))' ),
1000
996
'timestamp' : 0 if rescan else 'now' ,
1001
- 'label' : label if label else ''
997
+ 'label' : label if label else '' ,
1002
998
})
1003
999
import_res = self .importdescriptors (reqs )
1004
1000
for res in import_res :
0 commit comments