Merge bitcoin/bitcoin#36867: test: remove legacy wallet leftovers from wallet functional tests
What changed, and why it matters
This commit only cleans up Bitcoin Core's own functional test suite. It removes unused multisig test code, fixes outdated docstrings, and drops a no-longer-needed command-line flag in test scripts. None of these changes affect the actual Bitcoin Core wallet or network code that users run, so there is no security impact.
No action required; this is a routine test-maintenance change with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The merge commit updates three functional test files: wallet_address_types.py removes a dead multisig code path that could never execute (do_multisigs=[False]), wallet_backup.py updates docstrings to match the actual backupwallet/restorewallet RPCs being tested, and wallet_hd.py removes the no-op -keypool=0 argument for descriptor wallets. All changes are confined to test/functional/ and do not alter node/wallet consensus or networking behavior.
Changed components
test/functional/wallet_address_types.pytest/functional/wallet_backup.pytest/functional/wallet_hd.pyInspect captured patch +40 / −92
### test/functional/wallet_address_types.py
@@ -13,23 +13,14 @@
node5 exists to generate new blocks.
-## Multisig address test
-
-Test that adding a multisig address with:
- - an uncompressed pubkey always gives a legacy address
- - only compressed pubkeys gives the an `-addresstype` address
-
## Sending to address types test
-A series of tests, iterating over node0-node4. In each iteration of the test, one node sends:
- - 10/101th of its balance to itself (using getrawchangeaddress for single key addresses)
- - 20/101th to the next node
- - 30/101th to the node after that
- - 40/101th to the remaining node
- - 1/101th remains as fee+change
-
-Iterate over each node for single key addresses, and then over each node for
-multisig addresses.
+A series of tests, iterating over node0-node3. In each iteration of the test, one node sends:
+ - 10/101 of its balance to itself (using getrawchangeaddress)
+ - 20/101 to the next node
+ - 30/101 to the node after that
+ - 40/101 to the remaining node
+ - 1/101 remains as fee+change
Repeat test, but with explicit address_type parameters passed to getnewaddress
and getrawchangeaddress:
@@ -94,66 +85,41 @@ def get_balances(self, key='trusted'):
"""Return a list of balances."""
return [self.nodes[i].getbalances()['mine'][key] for i in range(4)]
- def test_address(self, node, address, multisig, typ):
+ def test_address(self, node, address, typ):
"""Run sanity checks on an address."""
info = self.nodes[node].getaddressinfo(address)
assert self.nodes[node].validateaddress(address)['isvalid']
assert_equal(info.get('solvable'), True)
- if not multisig and typ == 'legacy':
+ if typ == 'legacy':
# P2PKH
assert not info['isscript']
assert not info['iswitness']
assert 'pubkey' in info
- elif not multisig and typ == 'p2sh-segwit':
+ elif typ == 'p2sh-segwit':
# P2SH-P2WPKH
assert info['isscript']
assert not info['iswitness']
assert_equal(info['script'], 'witness_v0_keyhash')
assert 'pubkey' in info
- elif not multisig and typ == 'bech32':
+ elif typ == 'bech32':
# P2WPKH
assert not info['isscript']
assert info['iswitness']
assert_equal(info['witness_version'], 0)
assert_equal(len(info['witness_program']), 40)
assert 'pubkey' in info
- elif not multisig and typ == "bech32m":
+ elif typ == "bech32m":
# P2TR single sig
assert info["isscript"]
assert info["iswitness"]
assert_equal(info["witness_version"], 1)
assert_equal(len(info["witness_program"]), 64)
- elif typ == 'legacy':
- # P2SH-multisig
- assert info['isscript']
- assert_equal(info['script'], 'multisig')
- assert not info['iswitness']
- assert 'pubkeys' in info
- elif typ == 'p2sh-segwit':
- # P2SH-P2WSH-multisig
- assert info['isscript']
- assert_equal(info['script'], 'witness_v0_scripthash')
- assert not info['iswitness']
- assert info['embedded']['isscript']
- assert_equal(info['embedded']['script'], 'multisig')
- assert info['embedded']['iswitness']
- assert_equal(info['embedded']['witness_version'], 0)
- assert_equal(len(info['embedded']['witness_program']), 64)
- assert 'pubkeys' in info['embedded']
- elif typ == 'bech32':
- # P2WSH-multisig
- assert info['isscript']
- assert_equal(info['script'], 'multisig')
- assert info['iswitness']
- assert_equal(info['witness_version'], 0)
- assert_equal(len(info['witness_program']), 64)
- assert 'pubkeys' in info
else:
# Unknown type
assert False
- def test_desc(self, node, address, multisig, typ, utxo):
+ def test_desc(self, node, address, typ, utxo):
"""Run sanity checks on a descriptor reported by getaddressinfo."""
info = self.nodes[node].getaddressinfo(address)
assert 'desc' in info
@@ -183,24 +149,15 @@ def test_desc(self, node, address, multisig, typ, utxo):
assert_equal(info['desc'], self.nodes[0].getdescriptorinfo(info['desc'])['descriptor'])
assert_equal(info['desc'][-8:], self.nodes[0].getdescriptorinfo(info['desc'])['checksum'])
- if not multisig and typ == 'legacy':
+ if typ == 'legacy':
# P2PKH
assert_equal(info['desc'], descsum_create("pkh(%s)" % key_descs[info['pubkey']]))
- elif not multisig and typ == 'p2sh-segwit':
+ elif typ == 'p2sh-segwit':
# P2SH-P2WPKH
assert_equal(info['desc'], descsum_create("sh(wpkh(%s))" % key_descs[info['pubkey']]))
- elif not multisig and typ == 'bech32':
+ elif typ == 'bech32':
# P2WPKH
assert_equal(info['desc'], descsum_create("wpkh(%s)" % key_descs[info['pubkey']]))
- elif typ == 'legacy':
- # P2SH-multisig
- assert_equal(info['desc'], descsum_create("sh(multi(2,%s,%s))" % (key_descs[info['pubkeys'][0]], key_descs[info['pubkeys'][1]])))
- elif typ == 'p2sh-segwit':
- # P2SH-P2WSH-multisig
- assert_equal(info['desc'], descsum_create("sh(wsh(multi(2,%s,%s)))" % (key_descs[info['embedded']['pubkeys'][0]], key_descs[info['embedded']['pubkeys'][1]])))
- elif typ == 'bech32':
- # P2WSH-multisig
- assert_equal(info['desc'], descsum_create("wsh(multi(2,%s,%s))" % (key_descs[info['pubkeys'][0]], key_descs[info['pubkeys'][1]])))
else:
# Unknown type
assert False
@@ -218,7 +175,7 @@ def test_change_output_type(self, node_sender, destinations, expected_type):
assert_equal(len(change_addresses), 1)
self.log.debug("Check if change address " + change_addresses[0] + " is " + expected_type)
- self.test_address(node_sender, change_addresses[0], multisig=False, typ=expected_type)
+ self.test_address(node_sender, change_addresses[0], typ=expected_type)
def run_test(self):
# Mine 101 blocks on node5 to bring nodes out of IBD and make sure that
@@ -228,18 +185,16 @@ def run_test(self):
compressed_1 = "0296b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52"
compressed_2 = "037211a824f55b505228e4c3d5194c1fcfaa15a456abdf37f9b9d97a4040afc073"
- do_multisigs = [False]
-
- for explicit_type, multisig, from_node in itertools.product([False, True], do_multisigs, range(4)):
+ for explicit_type, from_node in itertools.product([False, True], range(4)):
address_type = None
- if explicit_type and not multisig:
+ if explicit_type:
if from_node == 1:
address_type = 'bech32'
elif from_node == 0 or from_node == 3:
address_type = 'p2sh-segwit'
else:
address_type = 'legacy'
- self.log.info("Sending from node {} ({}) with{} multisig using {}".format(from_node, self.extra_args[from_node], "" if multisig else "out", "default" if address_type is None else address_type))
+ self.log.info("Sending from node {} ({}) using {}".format(from_node, self.extra_args[from_node], "default" if address_type is None else address_type))
old_balances = self.get_balances()
self.log.debug("Old balances are {}".format(old_balances))
to_send = (old_balances[from_node] / (COINBASE_MATURITY + 1)).quantize(Decimal("0.00000001"))
@@ -250,19 +205,12 @@ def run_test(self):
for n, to_node in enumerate(range(from_node, from_node + 4)):
to_node %= 4
change = False
- if not multisig:
- if from_node == to_node:
- # When sending non-multisig to self, use getrawchangeaddress
- address = self.nodes[to_node].getrawchangeaddress(address_type=address_type)
- change = True
- else:
- address = self.nodes[to_node].getnewaddress(address_type=address_type)
+ if from_node == to_node:
+ # When sending to self, use getrawchangeaddress
+ address = self.nodes[to_node].getrawchangeaddress(address_type=address_type)
+ change = True
else:
- pubkey1 = self.nodes[to_node].getaddressinfo(self.nodes[to_node].getnewaddress())["pubkey"]
- pubkey2 = self.nodes[to_node].getaddressinfo(self.nodes[to_node].getnewaddress())["pubkey"]
- ms = self.nodes[to_node].createmultisig(2, [pubkey1, pubkey2])
- import_res = self.nodes[to_node].importdescriptors([{"desc": ms["descriptor"], "timestamp": 0}])
- assert_equal(import_res[0]["success"], True)
+ address = self.nodes[to_node].getnewaddress(address_type=address_type)
# Do some sanity checking on the created address
if address_type is not None:
@@ -273,7 +221,7 @@ def run_test(self):
typ = 'p2sh-segwit'
else:
typ = 'bech32'
- self.test_address(to_node, address, multisig, typ)
+ self.test_address(to_node, address, typ)
# Output entry
sends[address] = to_send * 10 * (1 + n)
@@ -300,7 +248,7 @@ def run_test(self):
for utxo in self.nodes[to_node].listunspent():
if utxo['address'] == addresses[to_node][0]:
found = True
- self.test_desc(to_node, addresses[to_node][0], multisig, addresses[to_node][1], utxo)
+ self.test_desc(to_node, addresses[to_node][0], addresses[to_node][1], utxo)
break
assert found
@@ -341,7 +289,7 @@ def run_test(self):
self.test_change_output_type(3, [to_address_p2sh], 'p2sh-segwit')
self.log.info('getrawchangeaddress defaults to addresstype if -changetype is not set and argument is absent')
- self.test_address(3, self.nodes[3].getrawchangeaddress(), multisig=False, typ='bech32')
+ self.test_address(3, self.nodes[3].getrawchangeaddress(), typ='bech32')
self.log.info('test invalid address type arguments')
assert_raises_rpc_error(-5, "Unknown address type ''", self.nodes[3].createmultisig, 2, [compressed_1, compressed_2], address_type="")
@@ -352,14 +300,14 @@ def run_test(self):
self.log.info("Nodes with changetype=p2sh-segwit never use a P2WPKH change output")
self.test_change_output_type(4, [to_address_bech32_1], 'p2sh-segwit')
- self.test_address(4, self.nodes[4].getrawchangeaddress(), multisig=False, typ='p2sh-segwit')
+ self.test_address(4, self.nodes[4].getrawchangeaddress(), typ='p2sh-segwit')
self.log.info("Except for getrawchangeaddress if specified:")
- self.test_address(4, self.nodes[4].getrawchangeaddress(), multisig=False, typ='p2sh-segwit')
- self.test_address(4, self.nodes[4].getrawchangeaddress('bech32'), multisig=False, typ='bech32')
+ self.test_address(4, self.nodes[4].getrawchangeaddress(), typ='p2sh-segwit')
+ self.test_address(4, self.nodes[4].getrawchangeaddress('bech32'), typ='bech32')
self.log.info("Descriptor wallets have bech32m addresses")
- self.test_address(4, self.nodes[4].getnewaddress("", "bech32m"), multisig=False, typ="bech32m")
- self.test_address(4, self.nodes[4].getrawchangeaddress("bech32m"), multisig=False, typ="bech32m")
+ self.test_address(4, self.nodes[4].getnewaddress("", "bech32m"), typ="bech32m")
+ self.test_address(4, self.nodes[4].getrawchangeaddress("bech32m"), typ="bech32m")
if __name__ == '__main__':
AddressTypeTest(__file__).main()
### test/functional/wallet_backup.py
@@ -14,7 +14,7 @@
themselves to get transactions in the wallets,
and the miner mining one block.
-Wallets are backed up using dumpwallet/backupwallet.
+Wallets are backed up using backupwallet.
Then 5 more iterations of transactions and mining a block.
Miner then generates 101 more blocks, so any
@@ -23,12 +23,13 @@
Sanity check:
Sum(1,2,3,4 balances) == 114*50
-1/2/3 are shutdown, and their wallets erased.
-Then restore using wallet.dat backup. And
-confirm 1/2/3/4 balances are same as before.
+The backups of 1/2/3 are restored on the miner
+using restorewallet, and their balances are
+confirmed to be the same as those of 1/2/3.
-Shutdown again, restore using importwallet,
-and confirm again balances are correct.
+Then restorewallet error cases, backing up onto
+the source wallet, and restoring on a pruned node
+are tested.
"""
from decimal import Decimal
import os
### test/functional/wallet_hd.py
@@ -20,7 +20,6 @@ class WalletHDTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 2
- self.extra_args = [[], ['-keypool=0']]
self.noban_tx_relay = True # faster tx relay
def skip_test_if_missing_module(self):
@@ -164,7 +163,7 @@ def run_test(self):
self.nodes[1].datadir_path / "hd.bak",
self.nodes[1].wallets_path / self.default_wallet_name / self.wallet_data_filename
)
- self.start_node(1, extra_args=self.extra_args[1])
+ self.start_node(1)
self.connect_nodes(0, 1)
self.sync_all()
# Wallet automatically scans blocks older than key on startupWhy this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.