mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-26 03:03:22 -03:00
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:
parent
9fcf8ce7ae
commit
65833a7407
3 changed files with 8 additions and 8 deletions
|
@ -18,7 +18,7 @@ bool LegacyScriptPubKeyMan::GetNewDestination(const OutputType type, CTxDestinat
|
||||||
|
|
||||||
// Generate a new key that is added to wallet
|
// Generate a new key that is added to wallet
|
||||||
CPubKey new_key;
|
CPubKey new_key;
|
||||||
if (!GetKeyFromPool(new_key)) {
|
if (!GetKeyFromPool(new_key, type)) {
|
||||||
error = "Error: Keypool ran out, please call keypoolrefill first";
|
error = "Error: Keypool ran out, please call keypoolrefill first";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1086,7 +1086,7 @@ void LegacyScriptPubKeyMan::AddKeypoolPubkeyWithDB(const CPubKey& pubkey, const
|
||||||
m_pool_key_to_index[pubkey.GetID()] = index;
|
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
|
// Remove from key pool
|
||||||
WalletBatch batch(m_storage.GetDatabase());
|
WalletBatch batch(m_storage.GetDatabase());
|
||||||
|
@ -1112,7 +1112,7 @@ void LegacyScriptPubKeyMan::ReturnDestination(int64_t nIndex, bool fInternal, co
|
||||||
WalletLogPrintf("keypool return %d\n", nIndex);
|
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)) {
|
if (!CanGetAddresses(internal)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1128,7 +1128,7 @@ bool LegacyScriptPubKeyMan::GetKeyFromPool(CPubKey& result, bool internal)
|
||||||
result = GenerateNewKey(batch, internal);
|
result = GenerateNewKey(batch, internal);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
KeepDestination(nIndex);
|
KeepDestination(nIndex, type, keypool.vchPubKey);
|
||||||
result = keypool.vchPubKey;
|
result = keypool.vchPubKey;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -151,7 +151,7 @@ public:
|
||||||
virtual isminetype IsMine(const CScript& script) const { return ISMINE_NO; }
|
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, 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 void ReturnDestination(int64_t index, bool internal, const CPubKey& pubkey) {}
|
||||||
|
|
||||||
virtual bool TopUp(unsigned int size = 0) { return false; }
|
virtual bool TopUp(unsigned int size = 0) { return false; }
|
||||||
|
@ -248,7 +248,7 @@ private:
|
||||||
std::map<CKeyID, int64_t> m_pool_key_to_index;
|
std::map<CKeyID, int64_t> m_pool_key_to_index;
|
||||||
|
|
||||||
//! Fetches a key from the keypool
|
//! 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
|
* Reserves a key from the keypool and sets nIndex to its index
|
||||||
|
@ -274,7 +274,7 @@ public:
|
||||||
bool EncryptKeys(CKeyingMaterial& vMasterKeyIn);
|
bool EncryptKeys(CKeyingMaterial& vMasterKeyIn);
|
||||||
|
|
||||||
bool GetReservedDestination(const OutputType type, bool internal, int64_t& index, CKeyPool& keypool) override;
|
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;
|
void ReturnDestination(int64_t index, bool internal, const CPubKey& pubkey) override;
|
||||||
|
|
||||||
bool TopUp(unsigned int size = 0) override;
|
bool TopUp(unsigned int size = 0) override;
|
||||||
|
|
|
@ -3317,7 +3317,7 @@ bool ReserveDestination::GetReservedDestination(CTxDestination& dest, bool inter
|
||||||
void ReserveDestination::KeepDestination()
|
void ReserveDestination::KeepDestination()
|
||||||
{
|
{
|
||||||
if (nIndex != -1) {
|
if (nIndex != -1) {
|
||||||
m_spk_man->KeepDestination(nIndex);
|
m_spk_man->KeepDestination(nIndex, type, vchPubKey);
|
||||||
m_spk_man->LearnRelatedScripts(vchPubKey, type);
|
m_spk_man->LearnRelatedScripts(vchPubKey, type);
|
||||||
}
|
}
|
||||||
nIndex = -1;
|
nIndex = -1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue