Skip to content

wallet: importdescriptors and createwalletdescriptor can strand a pending initial top-up on a replaced descriptor (#318 follow-up) #357

Open

Description

@kiwidream

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.

  • EncryptWallet finishes the pending top-up before SetupDescriptorScriptPubKeyMans (src/wallet/wallet.cpp, around line 1319).
  • importdescriptors with active: true and createwalletdescriptor replace 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.

Related: #318, #300, #284, #299.

Activity

  1. added
    bug
    on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions