diff options
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/scriptpubkeyman.cpp | 4 | ||||
-rw-r--r-- | src/wallet/scriptpubkeyman.h | 4 | ||||
-rw-r--r-- | src/wallet/wallet.cpp | 4 | ||||
-rw-r--r-- | src/wallet/wallet.h | 3 |
4 files changed, 8 insertions, 7 deletions
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index f7153a751f..4986871fb7 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -262,7 +262,7 @@ bool LegacyScriptPubKeyMan::EncryptKeys(CKeyingMaterial& vMasterKeyIn) return true; } -bool LegacyScriptPubKeyMan::GetReservedDestination(const OutputType type, bool internal, int64_t& index, CKeyPool& keypool) +bool LegacyScriptPubKeyMan::GetReservedDestination(const OutputType type, bool internal, CTxDestination& address, int64_t& index, CKeyPool& keypool) { if (!CanGetAddresses(internal)) { return false; @@ -271,6 +271,7 @@ bool LegacyScriptPubKeyMan::GetReservedDestination(const OutputType type, bool i if (!ReserveKeyFromKeyPool(index, keypool, internal)) { return false; } + address = GetDestinationForKey(keypool.vchPubKey, type); return true; } @@ -1091,6 +1092,7 @@ void LegacyScriptPubKeyMan::KeepDestination(int64_t nIndex, const OutputType& ty // Remove from key pool WalletBatch batch(m_storage.GetDatabase()); batch.ErasePool(nIndex); + LearnRelatedScripts(pubkey, type); WalletLogPrintf("keypool keep %d\n", nIndex); } diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 16901952a6..bcc62ece1e 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -150,7 +150,7 @@ public: 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; } + virtual bool GetReservedDestination(const OutputType type, bool internal, CTxDestination& address, int64_t& index, CKeyPool& keypool) { return false; } virtual void KeepDestination(int64_t index, const OutputType& type, const CPubKey& pubkey) {} virtual void ReturnDestination(int64_t index, bool internal, const CPubKey& pubkey) {} @@ -273,7 +273,7 @@ public: //! will encrypt previously unencrypted keys bool EncryptKeys(CKeyingMaterial& vMasterKeyIn); - bool GetReservedDestination(const OutputType type, bool internal, int64_t& index, CKeyPool& keypool) override; + bool GetReservedDestination(const OutputType type, bool internal, CTxDestination& address, int64_t& index, CKeyPool& keypool) override; void KeepDestination(int64_t index, const OutputType& type, const CPubKey& pubkey) override; void ReturnDestination(int64_t index, bool internal, const CPubKey& pubkey) override; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 179e7b39ea..2bdec16f28 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3302,14 +3302,13 @@ bool ReserveDestination::GetReservedDestination(CTxDestination& dest, bool inter if (nIndex == -1) { CKeyPool keypool; - if (!m_spk_man->GetReservedDestination(type, internal, nIndex, keypool)) { + if (!m_spk_man->GetReservedDestination(type, internal, address, nIndex, keypool)) { return false; } vchPubKey = keypool.vchPubKey; fInternal = keypool.fInternal; } assert(vchPubKey.IsValid()); - address = GetDestinationForKey(vchPubKey, type); dest = address; return true; } @@ -3318,7 +3317,6 @@ void ReserveDestination::KeepDestination() { if (nIndex != -1) { m_spk_man->KeepDestination(nIndex, type, vchPubKey); - m_spk_man->LearnRelatedScripts(vchPubKey, type); } nIndex = -1; vchPubKey = CPubKey(); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index fce49ec56c..f6cbe6f6de 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -141,7 +141,8 @@ class ReserveDestination protected: //! The wallet to reserve from CWallet* const pwallet; - LegacyScriptPubKeyMan* m_spk_man{nullptr}; + //! The ScriptPubKeyMan to reserve from. Based on type when GetReservedDestination is called + ScriptPubKeyMan* m_spk_man{nullptr}; OutputType const type; //! The index of the address's key in the keypool int64_t nIndex{-1}; |