0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00

Get rid of confusing LegacyScriptPubKeyMan::TopUpKeyPool method

Previous discussion https://github.com/bitcoin/bitcoin/pull/17304#discussion_r340307903
This commit is contained in:
Russell Yanofsky 2019-11-05 10:43:36 -05:00
parent 4a0abf694e
commit 491a599b37
2 changed files with 6 additions and 12 deletions

View file

@ -14,7 +14,7 @@
bool LegacyScriptPubKeyMan::GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error)
{
error.clear();
TopUpKeyPool();
TopUp();
// Generate a new key that is added to wallet
CPubKey new_key;
@ -282,11 +282,6 @@ void LegacyScriptPubKeyMan::ReturnDestination(int64_t index, bool internal, cons
ReturnKey(index, internal, pubkey);
}
bool LegacyScriptPubKeyMan::TopUp(unsigned int size)
{
return TopUpKeyPool(size);
}
void LegacyScriptPubKeyMan::MarkUnusedAddresses(const CScript& script)
{
AssertLockHeld(cs_wallet);
@ -297,7 +292,7 @@ void LegacyScriptPubKeyMan::MarkUnusedAddresses(const CScript& script)
WalletLogPrintf("%s: Detected a used keypool key, mark all keypool key up to this key as used\n", __func__);
MarkReserveKeysAsUsed(mi->second);
if (!TopUpKeyPool()) {
if (!TopUp()) {
WalletLogPrintf("%s: Topping up keypool failed (locked wallet)\n", __func__);
}
}
@ -401,7 +396,7 @@ bool LegacyScriptPubKeyMan::Upgrade(int prev_version, std::string& error)
}
// Regenerate the keypool if upgraded to HD
if (hd_upgrade) {
if (!TopUpKeyPool()) {
if (!TopUp()) {
error = _("Unable to generate keys").translated;
return false;
}
@ -1029,7 +1024,7 @@ bool LegacyScriptPubKeyMan::NewKeyPool()
m_pool_key_to_index.clear();
if (!TopUpKeyPool()) {
if (!TopUp()) {
return false;
}
WalletLogPrintf("LegacyScriptPubKeyMan::NewKeyPool rewrote keypool\n");
@ -1037,7 +1032,7 @@ bool LegacyScriptPubKeyMan::NewKeyPool()
return true;
}
bool LegacyScriptPubKeyMan::TopUpKeyPool(unsigned int kpSize)
bool LegacyScriptPubKeyMan::TopUp(unsigned int kpSize)
{
if (!CanGenerateKeys()) {
return false;
@ -1154,7 +1149,7 @@ bool LegacyScriptPubKeyMan::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& key
{
LOCK(cs_wallet);
TopUpKeyPool();
TopUp();
bool fReturningInternal = fRequestedInternal;
fReturningInternal &= (IsHDEnabled() && m_storage.CanSupportFeature(FEATURE_HD_SPLIT)) || m_storage.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS);

View file

@ -356,7 +356,6 @@ public:
//! Load a keypool entry
void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
bool TopUpKeyPool(unsigned int kpSize = 0);
bool NewKeyPool();
void MarkPreSplitKeys() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);