mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
wallet: avoid double TopUp() calls on descriptor wallets
Move TopUp() responsibility from the wallet class to each scriptpubkeyman. So each spkm can decide to call it or not after perform the basic checks for the new destination request. Reason: We were calling it twice in the following flows for descriptor wallets: A) CWallet::GetNewDestination: 1) Calls spk_man->TopUp() 2) Calls spk_man->GetNewDestination() --> which, after the basic script checks, calls TopUp() again. B) CWallet::GetReservedDestination: 1) Calls spk_man->TopUp() 2) Calls spk_man->GetReservedDestination() --> which calls to GetNewDestination (which calls to TopUp again).
This commit is contained in:
@@ -2346,7 +2346,6 @@ util::Result<CTxDestination> CWallet::GetNewDestination(const OutputType type, c
|
||||
return util::Error{strprintf(_("Error: No %s addresses available."), FormatOutputType(type))};
|
||||
}
|
||||
|
||||
spk_man->TopUp();
|
||||
auto op_dest = spk_man->GetNewDestination(type);
|
||||
if (op_dest) {
|
||||
SetAddressBook(*op_dest, label, "receive");
|
||||
@@ -2440,10 +2439,7 @@ util::Result<CTxDestination> ReserveDestination::GetReservedDestination(bool int
|
||||
return util::Error{strprintf(_("Error: No %s addresses available."), FormatOutputType(type))};
|
||||
}
|
||||
|
||||
if (nIndex == -1)
|
||||
{
|
||||
m_spk_man->TopUp();
|
||||
|
||||
if (nIndex == -1) {
|
||||
CKeyPool keypool;
|
||||
auto op_address = m_spk_man->GetReservedDestination(type, internal, nIndex, keypool);
|
||||
if (!op_address) return op_address;
|
||||
|
||||
Reference in New Issue
Block a user