diff options
author | Andrew Chow <achow101-github@achow101.com> | 2020-04-29 17:11:19 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2020-11-04 12:15:14 -0500 |
commit | 0bd995aa19be65b0dd23df1df571c71428c2bc32 (patch) | |
tree | 9cf3a515095daa478ee8c30a15a286f2acb20ce6 /src/wallet/scriptpubkeyman.cpp | |
parent | 8e32e1c41c995e832e643f605d35a7aa112837e6 (diff) |
wallet: upgrade the CHDChain version number when upgrading to split hd
Diffstat (limited to 'src/wallet/scriptpubkeyman.cpp')
-rw-r--r-- | src/wallet/scriptpubkeyman.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 149e8a4c9b..d2e1be6402 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -457,6 +457,13 @@ bool LegacyScriptPubKeyMan::Upgrade(int prev_version, int new_version, bilingual WalletLogPrintf("Upgrading wallet to use HD chain split\n"); m_storage.SetMinVersion(FEATURE_PRE_SPLIT_KEYPOOL); split_upgrade = FEATURE_HD_SPLIT > prev_version; + // Upgrade the HDChain + if (m_hd_chain.nVersion < CHDChain::VERSION_HD_CHAIN_SPLIT) { + m_hd_chain.nVersion = CHDChain::VERSION_HD_CHAIN_SPLIT; + if (!WalletBatch(m_storage.GetDatabase()).WriteHDChain(m_hd_chain)) { + throw std::runtime_error(std::string(__func__) + ": writing chain failed"); + } + } } // Mark all keys currently in the keypool as pre-split if (split_upgrade) { |