mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-20 05:42:50 +02:00
Get rid of confusing LegacyScriptPubKeyMan::TopUpKeyPool method
Previous discussion https://github.com/bitcoin/bitcoin/pull/17304#discussion_r340307903
This commit is contained in:
parent
4a0abf694e
commit
491a599b37
@ -14,7 +14,7 @@
|
|||||||
bool LegacyScriptPubKeyMan::GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error)
|
bool LegacyScriptPubKeyMan::GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error)
|
||||||
{
|
{
|
||||||
error.clear();
|
error.clear();
|
||||||
TopUpKeyPool();
|
TopUp();
|
||||||
|
|
||||||
// Generate a new key that is added to wallet
|
// Generate a new key that is added to wallet
|
||||||
CPubKey new_key;
|
CPubKey new_key;
|
||||||
@ -282,11 +282,6 @@ void LegacyScriptPubKeyMan::ReturnDestination(int64_t index, bool internal, cons
|
|||||||
ReturnKey(index, internal, pubkey);
|
ReturnKey(index, internal, pubkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LegacyScriptPubKeyMan::TopUp(unsigned int size)
|
|
||||||
{
|
|
||||||
return TopUpKeyPool(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LegacyScriptPubKeyMan::MarkUnusedAddresses(const CScript& script)
|
void LegacyScriptPubKeyMan::MarkUnusedAddresses(const CScript& script)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet);
|
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__);
|
WalletLogPrintf("%s: Detected a used keypool key, mark all keypool key up to this key as used\n", __func__);
|
||||||
MarkReserveKeysAsUsed(mi->second);
|
MarkReserveKeysAsUsed(mi->second);
|
||||||
|
|
||||||
if (!TopUpKeyPool()) {
|
if (!TopUp()) {
|
||||||
WalletLogPrintf("%s: Topping up keypool failed (locked wallet)\n", __func__);
|
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
|
// Regenerate the keypool if upgraded to HD
|
||||||
if (hd_upgrade) {
|
if (hd_upgrade) {
|
||||||
if (!TopUpKeyPool()) {
|
if (!TopUp()) {
|
||||||
error = _("Unable to generate keys").translated;
|
error = _("Unable to generate keys").translated;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1029,7 +1024,7 @@ bool LegacyScriptPubKeyMan::NewKeyPool()
|
|||||||
|
|
||||||
m_pool_key_to_index.clear();
|
m_pool_key_to_index.clear();
|
||||||
|
|
||||||
if (!TopUpKeyPool()) {
|
if (!TopUp()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
WalletLogPrintf("LegacyScriptPubKeyMan::NewKeyPool rewrote keypool\n");
|
WalletLogPrintf("LegacyScriptPubKeyMan::NewKeyPool rewrote keypool\n");
|
||||||
@ -1037,7 +1032,7 @@ bool LegacyScriptPubKeyMan::NewKeyPool()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LegacyScriptPubKeyMan::TopUpKeyPool(unsigned int kpSize)
|
bool LegacyScriptPubKeyMan::TopUp(unsigned int kpSize)
|
||||||
{
|
{
|
||||||
if (!CanGenerateKeys()) {
|
if (!CanGenerateKeys()) {
|
||||||
return false;
|
return false;
|
||||||
@ -1154,7 +1149,7 @@ bool LegacyScriptPubKeyMan::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& key
|
|||||||
{
|
{
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
|
|
||||||
TopUpKeyPool();
|
TopUp();
|
||||||
|
|
||||||
bool fReturningInternal = fRequestedInternal;
|
bool fReturningInternal = fRequestedInternal;
|
||||||
fReturningInternal &= (IsHDEnabled() && m_storage.CanSupportFeature(FEATURE_HD_SPLIT)) || m_storage.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
|
fReturningInternal &= (IsHDEnabled() && m_storage.CanSupportFeature(FEATURE_HD_SPLIT)) || m_storage.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
|
||||||
|
@ -356,7 +356,6 @@ public:
|
|||||||
|
|
||||||
//! Load a keypool entry
|
//! Load a keypool entry
|
||||||
void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
bool TopUpKeyPool(unsigned int kpSize = 0);
|
|
||||||
bool NewKeyPool();
|
bool NewKeyPool();
|
||||||
void MarkPreSplitKeys() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
void MarkPreSplitKeys() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user