You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Review finding: encrypting during a pending deferred refill leaves the old seed at a 16-key lookahead #318
Encrypting during a pending deferred refill leaves the old seed's descriptors with a 16-key lookahead forever.
Severity: low. Found in the 2026-11-04 review of the v1.0.1 change set (all 1.x.x merges since v1.0.0 plus the open PRs that target it), against 1.x.x21fee6ee8e; area: #277.
Observed
Confidence: plausible.
Location:src/wallet/wallet.cpp:3481-3522 (HasPendingInitialKeyPoolTopUp and RunPendingInitialKeyPoolTopUpStep look only at GetActiveScriptPubKeyMans()); src/wallet/wallet.cpp:3467-3476 (TopUpKeyPool/keypoolrefill cover only active managers); src/wallet/scriptpubkeyman.cpp:1705-1713 (MarkUnusedAddresses on a deferred descriptor only persists the flag) at 21fee6e.
Scenario: a P2MR wallet is created, and encryptwallet runs before its deferred refill finishes. That is exactly the window wallet: take descriptor locks before EncryptWallet's transaction #277's release note says to watch: within about 30 s of creation, or after a step paused. With wallet: take descriptor locks before EncryptWallet's transaction #277 an in-flight refill step now fails ("wallet was encrypted after this keypool top-up took its key snapshot"), and EncryptWallet makes new active descriptors. The old descriptors keep deferred_create_keypool_top_up=true and a range of next_index + 16. Nothing ever extends them: not the scheduler, keypoolrefill, MarkUnusedAddresses, nor wallet: deferred P2MR keypool refill at startup and unlock; Lock() waits for key copies #299's startup resume, which also uses only active managers. Payments to the old seed beyond that range are never detected. Such payments come from a pre-encryption backup or another copy of the old seed that handed out more addresses.
Evidence: code read, not run.
Impact
It is a missed-funds class. It is low severity because it needs addresses of the old seed beyond the warm pool to be paid after encryption.
Suggested fix
In EncryptWallet, finish or clear the deferred flag on managers that are about to become inactive. The wallet is unlocked inside EncryptWallet, so a bounded top-up of the old managers' lookahead is possible there. Alternatively, let the deferred scheduler and keypoolrefill include inactive managers whose HasDeferredCreateKeyPoolTopUp() is true. At minimum, document that encrypting during the first minute after creation leaves the old seed with a 16-address lookahead.
Related: extends #284. #284 covers startup resume of active descriptors; this route covers inactive descriptors, which #299 does not change.
Fixed on 1.x.x by #300 (ea571b86f5), which ships in v1.0.1: encrypting while the deferred create-time top-up is pending now finishes that top-up for the descriptors that the new seed replaces. The other paths that can replace a descriptor with a pending top-up (importdescriptors, createwalletdescriptor) are tracked in #357.
Closing by hand, because a merge into 1.x.x does not close issues automatically.
Activity
wallet: keep EncryptWallet's outcome when a step after its commit fails
wallet: keep EncryptWallet's outcome when a step after its commit fails
wallet: keep EncryptWallet's outcome when a step after its commit fails
wallet: remove deleted plaintext keys from the wallet file after encr…
kiwidream commentedon Nov 11, 2026
Fixed on
1.x.xby #300 (ea571b86f5), which ships in v1.0.1: encrypting while the deferred create-time top-up is pending now finishes that top-up for the descriptors that the new seed replaces. The other paths that can replace a descriptor with a pending top-up (importdescriptors,createwalletdescriptor) are tracked in #357.Closing by hand, because a merge into
1.x.xdoes not close issues automatically.wallet: remove deleted plaintext keys from the wallet file after encr…