Skip to content

Commit d5ab5a4

Browse files
committed
Merge bitcoin/bitcoin#31452: wallet: Migrate non-HD keys to combo() descriptor
62b2d23 wallet: Migrate non-HD keys to combo() descriptor (Ava Chow) Pull request description: Non-HD keys do not have an HD seed ID associated with them, so if this value is the null value (all 0s), then we should not perform any seed ID comparison that would result in excluding the keys from combo() migration. This changes the migration of non-HD wallets (or blank wallets with imported private keys) to make a single combo() descriptors for the non-HD/imported keys, rather than pk(), pkh(), sh(wpkh()), and wpkh() descriptors for the keys. Implements bitcoin/bitcoin#31374 (comment) ACKs for top commit: laanwj: Concept and code review ACK 62b2d23 brunoerg: code review ACK 62b2d23 furszy: Nice catch. ACK 62b2d23 theStack: ACK 62b2d23 rkrux: tACK 62b2d23 Tree-SHA512: 86a80b7dcc1598ab18068a2572ff4b4920b233178b760f7b76c5b21a9e6608005ac872f90e082a8f99b51daab0b049e73e4bee5b8e0b537d56ed0d34122a1f49
2 parents beac62e + 62b2d23 commit d5ab5a4

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/wallet/scriptpubkeyman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1799,7 +1799,7 @@ std::optional<MigrationData> LegacyDataSPKM::MigrateToDescriptor()
17991799
keyid_it++;
18001800
continue;
18011801
}
1802-
if (m_hd_chain.seed_id == meta.hd_seed_id || m_inactive_hd_chains.count(meta.hd_seed_id) > 0) {
1802+
if (!meta.hd_seed_id.IsNull() && (m_hd_chain.seed_id == meta.hd_seed_id || m_inactive_hd_chains.count(meta.hd_seed_id) > 0)) {
18031803
keyid_it = keyids.erase(keyid_it);
18041804
continue;
18051805
}

test/functional/wallet_migration.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,15 +1032,11 @@ def test_manual_keys_import(self):
10321032
# There should be descriptors containing the imported key for: pk(), pkh(), sh(wpkh()), wpkh()
10331033
key_origin = hash160(pubkey)[:4].hex()
10341034
pubkey_hex = pubkey.hex()
1035-
pk_desc = descsum_create(f'pk([{key_origin}]{pubkey_hex})')
1036-
pkh_desc = descsum_create(f'pkh([{key_origin}]{pubkey_hex})')
1037-
sh_wpkh_desc = descsum_create(f'sh(wpkh([{key_origin}]{pubkey_hex}))')
1038-
wpkh_desc = descsum_create(f'wpkh([{key_origin}]{pubkey_hex})')
1039-
expected_descs = [pk_desc, pkh_desc, sh_wpkh_desc, wpkh_desc]
1035+
combo_desc = descsum_create(f"combo([{key_origin}]{pubkey_hex})")
10401036

10411037
# Verify all expected descriptors were migrated
10421038
migrated_desc = [item['desc'] for item in wallet.listdescriptors()['descriptors'] if pubkey.hex() in item['desc']]
1043-
assert_equal(expected_descs, migrated_desc)
1039+
assert_equal([combo_desc], migrated_desc)
10441040
wallet.unloadwallet()
10451041

10461042
######################################################

0 commit comments

Comments
 (0)