wallet, migration: Fix crash on empty wallet

Same as with a blank wallet, wallets with no legacy
records (i.e. empty, non-blank, watch-only wallet)
do not require to be migrated.
This commit is contained in:
pablomartin4btc
2025-03-26 19:13:44 -03:00
parent 42c13141b5
commit 0f602c5693
2 changed files with 12 additions and 3 deletions

View File

@@ -445,6 +445,15 @@ class WalletMigrationTest(BitcoinTestFramework):
# After migrating, the "keypool" is empty
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", watchonly1.getnewaddress)
self.log.info("Test migration of a watch-only empty wallet")
for idx, is_blank in enumerate([True, False], start=1):
wallet_name = f"watchonly_empty{idx}"
self.create_legacy_wallet(wallet_name, disable_private_keys=True, blank=is_blank)
_, watchonly_empty = self.migrate_and_get_rpc(wallet_name)
info = watchonly_empty.getwalletinfo()
assert_equal(info["private_keys_enabled"], False)
assert_equal(info["blank"], is_blank)
def test_pk_coinbases(self):
self.log.info("Test migration of a wallet using old pk() coinbases")
wallet = self.create_legacy_wallet("pkcb")