Found it while was digging over a getnewaddress timeout on the functional test suite.
Context:
We are calling TopUp() twice in the following flows for descriptor wallets:
A) CWallet::GetNewDestination:
- Calls spk_man->TopUp()
- Calls spk_man->GetNewDestination() --> which, after the basic script checks, calls TopUp() again.
B) CWallet::GetReservedDestination:
- Calls spk_man->TopUp()
- Calls spk_man->GetReservedDestination() --> which calls to GetNewDestination (which calls to TopUp again).
Changes:
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.
Aside from that, remove the unused nAccountingEntryNumber wallet field. And a duplicated descriptor type check in GetNewDestination