wallet: Disallow loading legacy wallets

Legacy wallets do not have the descriptors flag set. Don't load wallets
without the descriptors flag.

At the same time, we will no longer load BDB databases since they are
only used for legacy wallets.
This commit is contained in:
Ava Chow
2024-01-05 18:42:18 -05:00
parent 9f04e02ffa
commit 17bb63f9f9
7 changed files with 42 additions and 30 deletions

View File

@@ -285,5 +285,28 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
info = wallet_res.getaddressinfo(address)
assert_equal(info, addr_info)
self.log.info("Test that a wallet from a legacy only node must be migrated, from:")
for node in legacy_nodes:
self.log.info(f"- {node.version}")
wallet_name = f"legacy_up_{node.version}"
if self.major_version_at_least(node, 21):
node.rpc.createwallet(wallet_name=wallet_name, descriptors=False)
else:
node.rpc.createwallet(wallet_name=wallet_name)
wallet_prev = node.get_wallet_rpc(wallet_name)
address = wallet_prev.getnewaddress('', "bech32")
addr_info = wallet_prev.getaddressinfo(address)
# Make a backup of the wallet file
backup_path = os.path.join(self.options.tmpdir, f"{wallet_name}.dat")
wallet_prev.backupwallet(backup_path)
# Remove the wallet from old node
wallet_prev.unloadwallet()
# Restore the wallet to master
# Legacy wallets are no longer supported. Trying to load these should result in an error
assert_raises_rpc_error(-18, "The wallet appears to be a Legacy wallet, please use the wallet migration tool (migratewallet RPC)", node_master.restorewallet, wallet_name, backup_path)
if __name__ == '__main__':
BackwardsCompatibilityTest(__file__).main()