diff options
author | Andrew Chow <achow101-github@achow101.com> | 2019-10-07 14:11:34 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2019-11-01 22:56:37 -0400 |
commit | 769acef85730a6c0e2f5603fbd673b176c2d34d0 (patch) | |
tree | 1925d0e279c40779accd83e991ecc835da3bd987 /src | |
parent | acedc5b8230ed9ad07f96f51f0ef862ab3a41d5e (diff) |
Refactor: Move SetAddressBook call out of LegacyScriptPubKeyMan::GetNewDestination
This commit does not change behavior.
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/scriptpubkeyman.cpp | 5 | ||||
-rw-r--r-- | src/wallet/scriptpubkeyman.h | 3 | ||||
-rw-r--r-- | src/wallet/wallet.cpp | 7 |
3 files changed, 9 insertions, 6 deletions
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 41ef121071..03a7b8f289 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -11,9 +11,8 @@ #include <wallet/scriptpubkeyman.h> #include <wallet/wallet.h> -bool LegacyScriptPubKeyMan::GetNewDestination(const OutputType type, const std::string label, CTxDestination& dest, std::string& error) +bool LegacyScriptPubKeyMan::GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error) { - LOCK(cs_wallet); error.clear(); TopUpKeyPool(); @@ -25,8 +24,6 @@ bool LegacyScriptPubKeyMan::GetNewDestination(const OutputType type, const std:: } LearnRelatedScripts(new_key, type); dest = GetDestinationForKey(new_key, type); - - m_wallet.SetAddressBook(dest, label, "receive"); return true; } diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index ac29fdc5ee..f7a3b81d3a 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -146,6 +146,7 @@ protected: public: ScriptPubKeyMan(WalletStorage& storage) : m_storage(storage) {} virtual ~ScriptPubKeyMan() {}; + virtual bool GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error) { return false; } virtual isminetype IsMine(const CScript& script) const { return ISMINE_NO; } virtual bool GetReservedDestination(const OutputType type, bool internal, int64_t& index, CKeyPool& keypool) { return false; } @@ -245,7 +246,7 @@ private: void ReturnKey(int64_t nIndex, bool fInternal, const CPubKey& pubkey); public: - bool GetNewDestination(const OutputType type, const std::string label, CTxDestination& dest, std::string& error); + bool GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error) override; isminetype IsMine(const CScript& script) const override; //! will encrypt previously unencrypted keys diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 7a2ec1ef43..2f1de5220b 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3034,12 +3034,17 @@ bool CWallet::TopUpKeyPool(unsigned int kpSize) bool CWallet::GetNewDestination(const OutputType type, const std::string label, CTxDestination& dest, std::string& error) { + LOCK(cs_wallet); error.clear(); bool result = false; auto spk_man = m_spk_man.get(); if (spk_man) { - result = spk_man->GetNewDestination(type, label, dest, error); + result = spk_man->GetNewDestination(type, dest, error); + } + if (result) { + SetAddressBook(dest, label, "receive"); } + return result; } |