Skip to content

Commit 0bd995a

Browse files
committed
wallet: upgrade the CHDChain version number when upgrading to split hd
1 parent 8e32e1c commit 0bd995a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/wallet/scriptpubkeyman.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,13 @@ bool LegacyScriptPubKeyMan::Upgrade(int prev_version, int new_version, bilingual
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;
460+
// Upgrade the HDChain
461+
if (m_hd_chain.nVersion < CHDChain::VERSION_HD_CHAIN_SPLIT) {
462+
m_hd_chain.nVersion = CHDChain::VERSION_HD_CHAIN_SPLIT;
463+
if (!WalletBatch(m_storage.GetDatabase()).WriteHDChain(m_hd_chain)) {
464+
throw std::runtime_error(std::string(__func__) + ": writing chain failed");
465+
}
466+
}
460467
}
461468
// Mark all keys currently in the keypool as pre-split
462469
if (split_upgrade) {

0 commit comments

Comments
 (0)