Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
502# Check for last hardened xpubs if the flag is newly set503if diff_flags & (1 << 2):504self.log.debug("Checking descriptor cache was upgraded")505# Fetch all records with the walletdescriptorlhcache prefix506lh_cache_recs = conn.execute(f"SELECT value FROM main where key >= x'{ser_string(b'walletdescriptorlhcache').hex()}' AND key < x'{ser_string(b'walletdescriptorlhcachf').hex()}'").fetchall()507assert_greater_than(len(lh_cache_recs), 0)509self.inspect_sqlite_db(down_backup_path, check_upgraded_records, old_flags)511# Check that no automatic upgrade broke downgrading the wallet512target_dir = node.wallets_path / down_wallet_name513os.makedirs(target_dir, exist_ok=True)514shutil.copyfile(515down_backup_path,516target_dir / "wallet.dat"517)518node.loadwallet(down_wallet_name)519wallet_res = node.get_wallet_rpc(down_wallet_name)520info = wallet_res.getaddressinfo(address)521assert_equal(info, addr_info)523self.log.info("Test that a wallet from a legacy only node must be migrated, from:")524for node in legacy_nodes:525self.log.info(f"- {node.version}")526wallet_name = f"legacy_up_{node.version}"527if self.major_version_at_least(node, 21):528node.createwallet(wallet_name=wallet_name, descriptors=False)529else:530node.createwallet(wallet_name=wallet_name)531wallet_prev = node.get_wallet_rpc(wallet_name)532address = wallet_prev.getnewaddress('', "bech32")533addr_info = wallet_prev.getaddressinfo(address)535# Make a backup of the wallet file536backup_path = os.path.join(self.options.tmpdir, f"{wallet_name}.dat")537wallet_prev.backupwallet(backup_path)539# Remove the wallet from old node540wallet_prev.unloadwallet()542# Restore the wallet to master543# Legacy wallets are no longer supported. Trying to load these should result in an error544assert_raises_rpc_error(-18, "The wallet appears to be a Legacy wallet, please use the wallet migration tool (migratewallet RPC or the GUI option)", node_master.restorewallet, wallet_name, backup_path)546self.test_v22_inactivehdchain_path()547self.test_ignore_legacy_during_startup(legacy_nodes, node_master)548node_v25 = self.nodes[2] # note: could be any node prior to v32549self.test_downgrade_preserves_witness_variants(node_master, node_miner, node_v25)551if __name__ == '__main__':552BackwardsCompatibilityTest(__file__).main()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.