Description
Summary
#300 fixes #318 for encryption: before EncryptWallet replaces the active descriptors, it finishes their pending create-time top-up. Other paths that replace an active descriptor do not. A replaced descriptor can then stay at its 16-key warm lookahead for good, so payments to its later addresses go unseen.
Observed
At #300's head 867ceb00f6, which is not merged yet. Found while reviewing the #300 work; not reproduced.
EncryptWalletfinishes the pending top-up beforeSetupDescriptorScriptPubKeyMans(src/wallet/wallet.cpp, around line 1319).importdescriptorswithactive: trueandcreatewalletdescriptorreplace an active descriptor without that step.- Wallets that were encrypted inside the pending window, by v1.0.0 or by v1.0.1 without wallet: remove deleted plaintext keys from the wallet file after encryption #300, already have replaced descriptors stuck at 16 keys, and nothing repairs them.
Impact
Low. It needs a wallet whose deferred initial top-up has not finished when an active descriptor is replaced. Payments to the replaced descriptor's later addresses, from a restored copy or from addresses handed out before the replacement, are not detected. keypoolrefill tops up only active descriptors, so it does not help either.
Suggested fix
Factor #300's step into a helper, and call it wherever an active descriptor is replaced (AddWalletDescriptor with active, and createwalletdescriptor). Add a one-time repair: when an unlocked wallet has an inactive descriptor still marked as pending, top it up to the configured lookahead. Add a test for each path.
Activity