aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/scriptpubkeyman.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2020-05-21 22:43:58 -0400
committerAndrew Chow <achow101-github@achow101.com>2020-05-21 22:43:58 -0400
commit0122fbab4c340b23ae56173de6c5ab866ba25ab8 (patch)
tree8fbde6abd2086591ecebf24ad6918dd2bedb4f32 /src/wallet/scriptpubkeyman.cpp
parentdf303ceb650521dc7b1ba91e0eea383c387a5860 (diff)
Split SetHDChain into AddHDChain and LoadHDChain
Remove the memonly bool and follow our typical Add and Load pattern.
Diffstat (limited to 'src/wallet/scriptpubkeyman.cpp')
-rw-r--r--src/wallet/scriptpubkeyman.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp
index 8a2a798644..9199a843fd 100644
--- a/src/wallet/scriptpubkeyman.cpp
+++ b/src/wallet/scriptpubkeyman.cpp
@@ -900,20 +900,22 @@ bool LegacyScriptPubKeyMan::AddWatchOnly(const CScript& dest, int64_t nCreateTim
return AddWatchOnly(dest);
}
-void LegacyScriptPubKeyMan::SetHDChain(const CHDChain& chain, bool memonly)
+void LegacyScriptPubKeyMan::LoadHDChain(const CHDChain& chain)
{
LOCK(cs_KeyStore);
- // memonly == true means we are loading the wallet file
- // memonly == false means that the chain is actually being changed
- if (!memonly) {
- // Store the new chain
- if (!WalletBatch(m_storage.GetDatabase()).WriteHDChain(chain)) {
- throw std::runtime_error(std::string(__func__) + ": writing chain failed");
- }
- // When there's an old chain, add it as an inactive chain as we are now rotating hd chains
- if (!m_hd_chain.seed_id.IsNull()) {
- AddInactiveHDChain(m_hd_chain);
- }
+ m_hd_chain = chain;
+}
+
+void LegacyScriptPubKeyMan::AddHDChain(const CHDChain& chain)
+{
+ LOCK(cs_KeyStore);
+ // Store the new chain
+ if (!WalletBatch(m_storage.GetDatabase()).WriteHDChain(chain)) {
+ throw std::runtime_error(std::string(__func__) + ": writing chain failed");
+ }
+ // When there's an old chain, add it as an inactive chain as we are now rotating hd chains
+ if (!m_hd_chain.seed_id.IsNull()) {
+ AddInactiveHDChain(m_hd_chain);
}
m_hd_chain = chain;
@@ -1167,7 +1169,7 @@ void LegacyScriptPubKeyMan::SetHDSeed(const CPubKey& seed)
CHDChain newHdChain;
newHdChain.nVersion = m_storage.CanSupportFeature(FEATURE_HD_SPLIT) ? CHDChain::VERSION_HD_CHAIN_SPLIT : CHDChain::VERSION_HD_BASE;
newHdChain.seed_id = seed.GetID();
- SetHDChain(newHdChain, false);
+ AddHDChain(newHdChain);
NotifyCanGetAddressesChanged();
WalletBatch batch(m_storage.GetDatabase());
m_storage.UnsetBlankWalletFlag(batch);