mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
keypool: Move opportunistic TopUps from LegacyScriptPubKeyMan to CWallet and ReserveDestination
An opportunistic TopUp is moved from LegacyScriptPubKeyMan::GetNewDestination to CWallet::GetNewDestination. Another opportunistic TopUp is moved from LegacyScriptPubKeyMan::ReserveKeyFromKeyPool (called by LegacyScriptPubKeyMan::GetReservedDestination) to ReserveDestination::GetReservedDestination. Moving opportunistic TopUps ensures that ScriptPubKeyMans will always be topped up before requesting Destinations from them as we cannot always rely on future ScriptPubKeyMan implementaions topping up internally. As such, it is also unnecessary to keep the TopUp calls in the LegacyScriptPubKeyMan functions so they are moved. This does not change behavior as TopUp calls are moved up the call stack.
This commit is contained in:
parent
bb2c8ce23c
commit
ea50e34b28
2 changed files with 3 additions and 3 deletions
|
@ -14,7 +14,6 @@
|
|||
bool LegacyScriptPubKeyMan::GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error)
|
||||
{
|
||||
error.clear();
|
||||
TopUp();
|
||||
|
||||
// Generate a new key that is added to wallet
|
||||
CPubKey new_key;
|
||||
|
@ -1147,8 +1146,6 @@ bool LegacyScriptPubKeyMan::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& key
|
|||
{
|
||||
LOCK(cs_wallet);
|
||||
|
||||
TopUp();
|
||||
|
||||
bool fReturningInternal = fRequestedInternal;
|
||||
fReturningInternal &= (IsHDEnabled() && m_storage.CanSupportFeature(FEATURE_HD_SPLIT)) || m_storage.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
|
||||
bool use_split_keypool = set_pre_split_keypool.empty();
|
||||
|
|
|
@ -3109,6 +3109,7 @@ bool CWallet::GetNewDestination(const OutputType type, const std::string label,
|
|||
bool result = false;
|
||||
auto spk_man = m_spk_man.get();
|
||||
if (spk_man) {
|
||||
spk_man->TopUp();
|
||||
result = spk_man->GetNewDestination(type, dest, error);
|
||||
}
|
||||
if (result) {
|
||||
|
@ -3302,6 +3303,8 @@ bool ReserveDestination::GetReservedDestination(CTxDestination& dest, bool inter
|
|||
|
||||
if (nIndex == -1)
|
||||
{
|
||||
m_spk_man->TopUp();
|
||||
|
||||
CKeyPool keypool;
|
||||
if (!m_spk_man->GetReservedDestination(type, internal, nIndex, keypool)) {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue