diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index 8f672f23074..deb519803cf 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -111,7 +111,7 @@ class PSBTTest(BitcoinTestFramework): # Mine a transaction that credits the offline address offline_addr = offline_node.getnewaddress(address_type="bech32m") online_addr = w2.getnewaddress(address_type="bech32m") - wonline.importaddress(offline_addr, "", False) + wonline.importaddress(offline_addr, label="", rescan=False) mining_wallet = mining_node.get_wallet_rpc(self.default_wallet_name) mining_wallet.sendtoaddress(address=offline_addr, amount=1.0) self.generate(mining_node, nblocks=1, sync_fun=lambda: self.sync_all([online_node, mining_node])) @@ -312,9 +312,9 @@ class PSBTTest(BitcoinTestFramework): wmulti = self.nodes[2].get_wallet_rpc('wmulti') # Create all the addresses - p2sh = wmulti.addmultisigaddress(2, [pubkey0, pubkey1, pubkey2], "", "legacy")['address'] - p2wsh = wmulti.addmultisigaddress(2, [pubkey0, pubkey1, pubkey2], "", "bech32")['address'] - p2sh_p2wsh = wmulti.addmultisigaddress(2, [pubkey0, pubkey1, pubkey2], "", "p2sh-segwit")['address'] + p2sh = wmulti.addmultisigaddress(2, [pubkey0, pubkey1, pubkey2], label="", address_type="legacy")["address"] + p2wsh = wmulti.addmultisigaddress(2, [pubkey0, pubkey1, pubkey2], label="", address_type="bech32")["address"] + p2sh_p2wsh = wmulti.addmultisigaddress(2, [pubkey0, pubkey1, pubkey2], label="", address_type="p2sh-segwit")["address"] p2wpkh = self.nodes[1].getnewaddress("", "bech32") p2pkh = self.nodes[1].getnewaddress("", "legacy") p2sh_p2wpkh = self.nodes[1].getnewaddress("", "p2sh-segwit") diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 4bae690b3f4..9f0baaccca2 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright (c) 2017-2022 The Bitcoin Core developers +# Copyright (c) 2017-present The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Class for bitcoind node under test""" @@ -209,7 +209,7 @@ class TestNode(): def __getattr__(self, name): """Dispatches any unrecognised messages to the RPC connection or a CLI instance.""" if self.use_cli: - return getattr(RPCOverloadWrapper(self.cli, True), name) + return getattr(RPCOverloadWrapper(self.cli), name) else: assert self.rpc_connected and self.rpc is not None, self._node_msg("Error: no RPC connection") return getattr(RPCOverloadWrapper(self.rpc), name) @@ -374,7 +374,7 @@ class TestNode(): def get_wallet_rpc(self, wallet_name): if self.use_cli: - return RPCOverloadWrapper(self.cli("-rpcwallet={}".format(wallet_name)), True) + return RPCOverloadWrapper(self.cli("-rpcwallet={}".format(wallet_name))) else: assert self.rpc_connected and self.rpc, self._node_msg("RPC not connected") wallet_path = "wallet/{}".format(urllib.parse.quote(wallet_name)) @@ -925,17 +925,13 @@ class TestNodeCLI(): return cli_stdout.rstrip("\n") class RPCOverloadWrapper(): - def __init__(self, rpc, cli=False): + def __init__(self, rpc): self.rpc = rpc - self.is_cli = cli def __getattr__(self, name): return getattr(self.rpc, name) - def createwallet_passthrough(self, *args, **kwargs): - return self.__getattr__("createwallet")(*args, **kwargs) - - def importprivkey(self, privkey, label=None, rescan=None): + def importprivkey(self, privkey, *, label=None, rescan=None): wallet_info = self.getwalletinfo() if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']): return self.__getattr__('importprivkey')(privkey, label, rescan) @@ -943,13 +939,13 @@ class RPCOverloadWrapper(): req = [{ 'desc': desc, 'timestamp': 0 if rescan else 'now', - 'label': label if label else '' + 'label': label if label else '', }] import_res = self.importdescriptors(req) if not import_res[0]['success']: raise JSONRPCException(import_res[0]['error']) - def addmultisigaddress(self, nrequired, keys, label=None, address_type=None): + def addmultisigaddress(self, nrequired, keys, *, label=None, address_type=None): wallet_info = self.getwalletinfo() if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']): return self.__getattr__('addmultisigaddress')(nrequired, keys, label, address_type) @@ -957,14 +953,14 @@ class RPCOverloadWrapper(): req = [{ 'desc': cms['descriptor'], 'timestamp': 0, - 'label': label if label else '' + 'label': label if label else '', }] import_res = self.importdescriptors(req) if not import_res[0]['success']: raise JSONRPCException(import_res[0]['error']) return cms - def importpubkey(self, pubkey, label=None, rescan=None): + def importpubkey(self, pubkey, *, label=None, rescan=None): wallet_info = self.getwalletinfo() if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']): return self.__getattr__('importpubkey')(pubkey, label, rescan) @@ -972,13 +968,13 @@ class RPCOverloadWrapper(): req = [{ 'desc': desc, 'timestamp': 0 if rescan else 'now', - 'label': label if label else '' + 'label': label if label else '', }] import_res = self.importdescriptors(req) if not import_res[0]['success']: raise JSONRPCException(import_res[0]['error']) - def importaddress(self, address, label=None, rescan=None, p2sh=None): + def importaddress(self, address, *, label=None, rescan=None, p2sh=None): wallet_info = self.getwalletinfo() if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']): return self.__getattr__('importaddress')(address, label, rescan, p2sh) @@ -992,13 +988,13 @@ class RPCOverloadWrapper(): reqs = [{ 'desc': desc, 'timestamp': 0 if rescan else 'now', - 'label': label if label else '' + 'label': label if label else '', }] if is_hex and p2sh: reqs.append({ 'desc': descsum_create('p2sh(raw(' + address + '))'), 'timestamp': 0 if rescan else 'now', - 'label': label if label else '' + 'label': label if label else '', }) import_res = self.importdescriptors(reqs) for res in import_res: diff --git a/test/functional/wallet_address_types.py b/test/functional/wallet_address_types.py index 27adb155951..d8c2aab36de 100755 --- a/test/functional/wallet_address_types.py +++ b/test/functional/wallet_address_types.py @@ -344,7 +344,7 @@ class AddressTypeTest(BitcoinTestFramework): self.test_address(3, self.nodes[3].getrawchangeaddress(), multisig=False, typ='bech32') self.log.info('test invalid address type arguments') - assert_raises_rpc_error(-5, "Unknown address type ''", self.nodes[3].addmultisigaddress, 2, [compressed_1, compressed_2], None, '') + assert_raises_rpc_error(-5, "Unknown address type ''", self.nodes[3].addmultisigaddress, 2, [compressed_1, compressed_2], address_type="") assert_raises_rpc_error(-5, "Unknown address type ''", self.nodes[3].getnewaddress, None, '') assert_raises_rpc_error(-5, "Unknown address type ''", self.nodes[3].getrawchangeaddress, '') assert_raises_rpc_error(-5, "Unknown address type 'bech23'", self.nodes[3].getrawchangeaddress, 'bech23') diff --git a/test/functional/wallet_fundrawtransaction.py b/test/functional/wallet_fundrawtransaction.py index 1339f9e28c3..aeaa8e54622 100755 --- a/test/functional/wallet_fundrawtransaction.py +++ b/test/functional/wallet_fundrawtransaction.py @@ -192,7 +192,7 @@ class RawTransactionsTest(BitcoinTestFramework): watchonly_address = self.nodes[0].getnewaddress() watchonly_pubkey = self.nodes[0].getaddressinfo(watchonly_address)["pubkey"] self.watchonly_amount = Decimal(200) - wwatch.importpubkey(watchonly_pubkey, "", True) + wwatch.importpubkey(watchonly_pubkey, label="", rescan=True) self.watchonly_utxo = self.create_outpoints(self.nodes[0], outputs=[{watchonly_address: self.watchonly_amount}])[0] # Lock UTXO so nodes[0] doesn't accidentally spend it diff --git a/test/functional/wallet_labels.py b/test/functional/wallet_labels.py index fb26b87a648..800f3ad7c40 100755 --- a/test/functional/wallet_labels.py +++ b/test/functional/wallet_labels.py @@ -49,7 +49,7 @@ class WalletLabelsTest(BitcoinTestFramework): assert_equal(response[0]['error']['message'], "Invalid label name") for rpc_call in rpc_calls: - assert_raises_rpc_error(-11, "Invalid label name", *rpc_call, "*") + assert_raises_rpc_error(-11, "Invalid label name", *rpc_call, label="*") def run_test(self): # Check that there's no UTXO on the node