Add OutputType and CPubKey parameters to KeepDestination

These need to be added so that LearnRelatedScripts can be called
from within KeepDestination later.
This commit is contained in:
Andrew Chow 2019-11-26 11:52:51 -05:00
parent 9fcf8ce7ae
commit 65833a7407
3 changed files with 8 additions and 8 deletions

View file

@ -18,7 +18,7 @@ bool LegacyScriptPubKeyMan::GetNewDestination(const OutputType type, CTxDestinat
// Generate a new key that is added to wallet
CPubKey new_key;
if (!GetKeyFromPool(new_key)) {
if (!GetKeyFromPool(new_key, type)) {
error = "Error: Keypool ran out, please call keypoolrefill first";
return false;
}
@ -1086,7 +1086,7 @@ void LegacyScriptPubKeyMan::AddKeypoolPubkeyWithDB(const CPubKey& pubkey, const
m_pool_key_to_index[pubkey.GetID()] = index;
}
void LegacyScriptPubKeyMan::KeepDestination(int64_t nIndex)
void LegacyScriptPubKeyMan::KeepDestination(int64_t nIndex, const OutputType& type, const CPubKey& pubkey)
{
// Remove from key pool
WalletBatch batch(m_storage.GetDatabase());
@ -1112,7 +1112,7 @@ void LegacyScriptPubKeyMan::ReturnDestination(int64_t nIndex, bool fInternal, co
WalletLogPrintf("keypool return %d\n", nIndex);
}
bool LegacyScriptPubKeyMan::GetKeyFromPool(CPubKey& result, bool internal)
bool LegacyScriptPubKeyMan::GetKeyFromPool(CPubKey& result, const OutputType type, bool internal)
{
if (!CanGetAddresses(internal)) {
return false;
@ -1128,7 +1128,7 @@ bool LegacyScriptPubKeyMan::GetKeyFromPool(CPubKey& result, bool internal)
result = GenerateNewKey(batch, internal);
return true;
}
KeepDestination(nIndex);
KeepDestination(nIndex, type, keypool.vchPubKey);
result = keypool.vchPubKey;
}
return true;

View file

@ -151,7 +151,7 @@ public:
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 void KeepDestination(int64_t index) {}
virtual void KeepDestination(int64_t index, const OutputType& type, const CPubKey& pubkey) {}
virtual void ReturnDestination(int64_t index, bool internal, const CPubKey& pubkey) {}
virtual bool TopUp(unsigned int size = 0) { return false; }
@ -248,7 +248,7 @@ private:
std::map<CKeyID, int64_t> m_pool_key_to_index;
//! Fetches a key from the keypool
bool GetKeyFromPool(CPubKey &key, bool internal = false);
bool GetKeyFromPool(CPubKey &key, const OutputType type, bool internal = false);
/**
* Reserves a key from the keypool and sets nIndex to its index
@ -274,7 +274,7 @@ public:
bool EncryptKeys(CKeyingMaterial& vMasterKeyIn);
bool GetReservedDestination(const OutputType type, bool internal, int64_t& index, CKeyPool& keypool) override;
void KeepDestination(int64_t index) override;
void KeepDestination(int64_t index, const OutputType& type, const CPubKey& pubkey) override;
void ReturnDestination(int64_t index, bool internal, const CPubKey& pubkey) override;
bool TopUp(unsigned int size = 0) override;

View file

@ -3317,7 +3317,7 @@ bool ReserveDestination::GetReservedDestination(CTxDestination& dest, bool inter
void ReserveDestination::KeepDestination()
{
if (nIndex != -1) {
m_spk_man->KeepDestination(nIndex);
m_spk_man->KeepDestination(nIndex, type, vchPubKey);
m_spk_man->LearnRelatedScripts(vchPubKey, type);
}
nIndex = -1;