Skip to content

Commit 2498b04

Browse files
achow101jonatack
authored andcommitted
Don't upgrade to HD split if it is already supported
It is unnecessary to upgrade to FEATURE_HD_SPLIT if this feature is already supported by the wallet. Because upgrading to FEATURE_HD_SPLIT actually requires upgrading to FEATURE_PRE_SPLIT_KEYPOOL, users would accidentally be upgraded to FEATURE_PRE_SPLIT_KEYPOOL instead of nothing being done. Fixes the issue described at bitcoin/bitcoin#20403 (comment)
1 parent c46c18b commit 2498b04

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/wallet/scriptpubkeyman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ bool LegacyScriptPubKeyMan::Upgrade(int prev_version, int new_version, bilingual
453453
hd_upgrade = true;
454454
}
455455
// Upgrade to HD chain split if necessary
456-
if (IsFeatureSupported(new_version, FEATURE_HD_SPLIT)) {
456+
if (!IsFeatureSupported(prev_version, FEATURE_HD_SPLIT) && IsFeatureSupported(new_version, FEATURE_HD_SPLIT)) {
457457
WalletLogPrintf("Upgrading wallet to use HD chain split\n");
458458
m_storage.SetMinVersion(FEATURE_PRE_SPLIT_KEYPOOL);
459459
split_upgrade = FEATURE_HD_SPLIT > prev_version;

test/functional/wallet_upgradewallet.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ def copy_split_hd():
338338
new_kvs = dump_bdb_kv(node_master_wallet)
339339
up_defaultkey = new_kvs[b'\x0adefaultkey']
340340
assert_equal(defaultkey, up_defaultkey)
341+
assert_equal(wallet.getwalletinfo()["walletversion"], 159900)
341342
# 0.16.3 doesn't have a default key
342343
v16_3_kvs = dump_bdb_kv(v16_3_wallet)
343344
assert b'\x0adefaultkey' not in v16_3_kvs

0 commit comments

Comments
 (0)