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.
251'internal': internal252}])254for i in range(0, 10):255if internal:256exp_addr = exp_rpc.getrawchangeaddress(address_type=addr_type)257imp_addr = imp_rpc.getrawchangeaddress(address_type=addr_type)258else:259exp_addr = exp_rpc.getnewaddress(address_type=addr_type)260imp_addr = imp_rpc.getnewaddress(address_type=addr_type)261assert_equal(exp_addr, imp_addr)263self.log.info("Test that loading descriptor wallet containing legacy key types throws error")264self.nodes[0].createwallet(wallet_name="crashme")265self.nodes[0].unloadwallet("crashme")266wallet_db = self.nodes[0].wallets_path / "crashme" / self.wallet_data_filename267conn = sqlite3.connect(wallet_db)268with conn:269# add "cscript" entry: key type is uint160 (20 bytes), value type is CScript (zero-length here)270conn.execute('INSERT INTO main VALUES(?, ?)', (b'\x07cscript' + b'\x00'*20, b'\x00'))271conn.close()272assert_raises_rpc_error(-4, "Unexpected legacy entry in descriptor wallet found.", self.nodes[0].loadwallet, "crashme")274self.log.info("Test that loading descriptor wallet containing both unencrypted and encrypted keys for same descriptor fails to load")275wallet_name = "mixed_crypt"276self.nodes[0].createwallet(wallet_name)277self.nodes[0].unloadwallet(wallet_name)278wallet_db = self.nodes[0].wallets_path / wallet_name / self.wallet_data_filename279conn = sqlite3.connect(wallet_db)280with conn:281key_prefix = ser_string(b"walletdescriptorkey")282ckey_prefix = ser_string(b"walletdescriptorckey")283rows = conn.execute('SELECT key, value FROM main').fetchall()284key_rows = [(k, v) for k, v in rows if k.startswith(key_prefix)]285# Test the test, want to be sure there is at least one unencrypted key.286assert len(key_rows) >= 1287k, v = key_rows[0]288conn.execute('INSERT INTO main VALUES(?, ?)', (k.replace(key_prefix, ckey_prefix), v))289conn.close()290with self.nodes[0].assert_debug_log(["Wallet contains both unencrypted and encrypted keys"]):291assert_raises_rpc_error(-4, "Wallet corrupted", self.nodes[0].loadwallet, wallet_name)293self.test_parent_descriptors()295if __name__ == '__main__':296WalletDescriptorTest(__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.