Skip to content

Commit 491a599

Browse files
committed
Get rid of confusing LegacyScriptPubKeyMan::TopUpKeyPool method
Previous discussion bitcoin/bitcoin#17304 (comment)
1 parent 4a0abf6 commit 491a599

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

src/wallet/scriptpubkeyman.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
bool LegacyScriptPubKeyMan::GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error)
1515
{
1616
error.clear();
17-
TopUpKeyPool();
17+
TopUp();
1818

1919
// Generate a new key that is added to wallet
2020
CPubKey new_key;
@@ -282,11 +282,6 @@ void LegacyScriptPubKeyMan::ReturnDestination(int64_t index, bool internal, cons
282282
ReturnKey(index, internal, pubkey);
283283
}
284284

285-
bool LegacyScriptPubKeyMan::TopUp(unsigned int size)
286-
{
287-
return TopUpKeyPool(size);
288-
}
289-
290285
void LegacyScriptPubKeyMan::MarkUnusedAddresses(const CScript& script)
291286
{
292287
AssertLockHeld(cs_wallet);
@@ -297,7 +292,7 @@ void LegacyScriptPubKeyMan::MarkUnusedAddresses(const CScript& script)
297292
WalletLogPrintf("%s: Detected a used keypool key, mark all keypool key up to this key as used\n", __func__);
298293
MarkReserveKeysAsUsed(mi->second);
299294

300-
if (!TopUpKeyPool()) {
295+
if (!TopUp()) {
301296
WalletLogPrintf("%s: Topping up keypool failed (locked wallet)\n", __func__);
302297
}
303298
}
@@ -401,7 +396,7 @@ bool LegacyScriptPubKeyMan::Upgrade(int prev_version, std::string& error)
401396
}
402397
// Regenerate the keypool if upgraded to HD
403398
if (hd_upgrade) {
404-
if (!TopUpKeyPool()) {
399+
if (!TopUp()) {
405400
error = _("Unable to generate keys").translated;
406401
return false;
407402
}
@@ -1029,15 +1024,15 @@ bool LegacyScriptPubKeyMan::NewKeyPool()
10291024

10301025
m_pool_key_to_index.clear();
10311026

1032-
if (!TopUpKeyPool()) {
1027+
if (!TopUp()) {
10331028
return false;
10341029
}
10351030
WalletLogPrintf("LegacyScriptPubKeyMan::NewKeyPool rewrote keypool\n");
10361031
}
10371032
return true;
10381033
}
10391034

1040-
bool LegacyScriptPubKeyMan::TopUpKeyPool(unsigned int kpSize)
1035+
bool LegacyScriptPubKeyMan::TopUp(unsigned int kpSize)
10411036
{
10421037
if (!CanGenerateKeys()) {
10431038
return false;
@@ -1154,7 +1149,7 @@ bool LegacyScriptPubKeyMan::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& key
11541149
{
11551150
LOCK(cs_wallet);
11561151

1157-
TopUpKeyPool();
1152+
TopUp();
11581153

11591154
bool fReturningInternal = fRequestedInternal;
11601155
fReturningInternal &= (IsHDEnabled() && m_storage.CanSupportFeature(FEATURE_HD_SPLIT)) || m_storage.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS);

src/wallet/scriptpubkeyman.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv
356356

357357
//! Load a keypool entry
358358
void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
359-
bool TopUpKeyPool(unsigned int kpSize = 0);
360359
bool NewKeyPool();
361360
void MarkPreSplitKeys() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
362361

0 commit comments

Comments
 (0)