Skip to content

Commit 65833a7

Browse files
committed
Add OutputType and CPubKey parameters to KeepDestination
These need to be added so that LearnRelatedScripts can be called from within KeepDestination later.
1 parent 9fcf8ce commit 65833a7

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/wallet/scriptpubkeyman.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ bool LegacyScriptPubKeyMan::GetNewDestination(const OutputType type, CTxDestinat
1818

1919
// Generate a new key that is added to wallet
2020
CPubKey new_key;
21-
if (!GetKeyFromPool(new_key)) {
21+
if (!GetKeyFromPool(new_key, type)) {
2222
error = "Error: Keypool ran out, please call keypoolrefill first";
2323
return false;
2424
}
@@ -1086,7 +1086,7 @@ void LegacyScriptPubKeyMan::AddKeypoolPubkeyWithDB(const CPubKey& pubkey, const
10861086
m_pool_key_to_index[pubkey.GetID()] = index;
10871087
}
10881088

1089-
void LegacyScriptPubKeyMan::KeepDestination(int64_t nIndex)
1089+
void LegacyScriptPubKeyMan::KeepDestination(int64_t nIndex, const OutputType& type, const CPubKey& pubkey)
10901090
{
10911091
// Remove from key pool
10921092
WalletBatch batch(m_storage.GetDatabase());
@@ -1112,7 +1112,7 @@ void LegacyScriptPubKeyMan::ReturnDestination(int64_t nIndex, bool fInternal, co
11121112
WalletLogPrintf("keypool return %d\n", nIndex);
11131113
}
11141114

1115-
bool LegacyScriptPubKeyMan::GetKeyFromPool(CPubKey& result, bool internal)
1115+
bool LegacyScriptPubKeyMan::GetKeyFromPool(CPubKey& result, const OutputType type, bool internal)
11161116
{
11171117
if (!CanGetAddresses(internal)) {
11181118
return false;
@@ -1128,7 +1128,7 @@ bool LegacyScriptPubKeyMan::GetKeyFromPool(CPubKey& result, bool internal)
11281128
result = GenerateNewKey(batch, internal);
11291129
return true;
11301130
}
1131-
KeepDestination(nIndex);
1131+
KeepDestination(nIndex, type, keypool.vchPubKey);
11321132
result = keypool.vchPubKey;
11331133
}
11341134
return true;

src/wallet/scriptpubkeyman.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class ScriptPubKeyMan
151151
virtual isminetype IsMine(const CScript& script) const { return ISMINE_NO; }
152152

153153
virtual bool GetReservedDestination(const OutputType type, bool internal, int64_t& index, CKeyPool& keypool) { return false; }
154-
virtual void KeepDestination(int64_t index) {}
154+
virtual void KeepDestination(int64_t index, const OutputType& type, const CPubKey& pubkey) {}
155155
virtual void ReturnDestination(int64_t index, bool internal, const CPubKey& pubkey) {}
156156

157157
virtual bool TopUp(unsigned int size = 0) { return false; }
@@ -248,7 +248,7 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv
248248
std::map<CKeyID, int64_t> m_pool_key_to_index;
249249

250250
//! Fetches a key from the keypool
251-
bool GetKeyFromPool(CPubKey &key, bool internal = false);
251+
bool GetKeyFromPool(CPubKey &key, const OutputType type, bool internal = false);
252252

253253
/**
254254
* Reserves a key from the keypool and sets nIndex to its index
@@ -274,7 +274,7 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv
274274
bool EncryptKeys(CKeyingMaterial& vMasterKeyIn);
275275

276276
bool GetReservedDestination(const OutputType type, bool internal, int64_t& index, CKeyPool& keypool) override;
277-
void KeepDestination(int64_t index) override;
277+
void KeepDestination(int64_t index, const OutputType& type, const CPubKey& pubkey) override;
278278
void ReturnDestination(int64_t index, bool internal, const CPubKey& pubkey) override;
279279

280280
bool TopUp(unsigned int size = 0) override;

src/wallet/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3317,7 +3317,7 @@ bool ReserveDestination::GetReservedDestination(CTxDestination& dest, bool inter
33173317
void ReserveDestination::KeepDestination()
33183318
{
33193319
if (nIndex != -1) {
3320-
m_spk_man->KeepDestination(nIndex);
3320+
m_spk_man->KeepDestination(nIndex, type, vchPubKey);
33213321
m_spk_man->LearnRelatedScripts(vchPubKey, type);
33223322
}
33233323
nIndex = -1;

0 commit comments

Comments
 (0)