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.
252# Export the watchonly wallet file and load onto online node253online_wallet = self.export_and_restore(offline_wallet, "encrypted_watchonly")255# watchonly wallet does not have encryption because it doesn't have private keys256assert "unlocked_until" not in online_wallet.getwalletinfo()257# But it still has all of the public descriptors258assert_equal(offline_wallet.listdescriptors()["descriptors"], online_wallet.listdescriptors()["descriptors"])260offline_wallet.unloadwallet()261online_wallet.unloadwallet()263def test_export_blank_wallet(self):264self.log.info("Test that exporting a blank/no-private-key wallet returns an error")266# blank=True + disable_private_keys: wallet has no descriptors at all267self.offline.createwallet(wallet_name="blank_no_keys", blank=True, disable_private_keys=True)268blank_wallet = self.offline.get_wallet_rpc("blank_no_keys")269assert_equal(blank_wallet.listdescriptors()["descriptors"], [])270export_path = os.path.join(self.export_path, "blank_export.dat")271assert_raises_rpc_error(-4, "Wallet has no descriptors to export", blank_wallet.exportwatchonlywallet, export_path)272blank_wallet.unloadwallet()274# disable_private_keys only also results in a blank wallet (no descriptors)275self.offline.createwallet(wallet_name="no_keys_only", disable_private_keys=True)276no_keys_wallet = self.offline.get_wallet_rpc("no_keys_only")277assert_equal(no_keys_wallet.listdescriptors()["descriptors"], [])278assert_raises_rpc_error(-4, "Wallet has no descriptors to export", no_keys_wallet.exportwatchonlywallet, export_path)279no_keys_wallet.unloadwallet()281def run_test(self):282self.online = self.nodes[0]283self.offline = self.nodes[1]284self.funder = self.online.get_wallet_rpc(self.default_wallet_name)285self.export_path = os.path.join(self.options.tmpdir, "exported_wallets")286os.makedirs(self.export_path, exist_ok=True)288# Mine some blocks, and verify disconnected289self.generate(self.online, 101, sync_fun=self.no_op)290assert_not_equal(self.online.getbestblockhash(), self.offline.getbestblockhash())291assert_equal(self.online.getblockcount(), 101)292assert_equal(self.offline.getblockcount(), 0)294self.test_basic_export()295self.test_export_with_address_book()296self.test_export_with_txs_and_locked_coins()297self.test_export_imported_descriptors()298self.test_avoid_reuse()299self.test_encrypted_wallet()300self.test_export_blank_wallet()302if __name__ == '__main__':303WalletExportedWatchOnly(__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.