Skip to content

wallet: deferred P2MR keypool top-up is not resumed for wallets loaded at startup #284

Closed

Description

@kiwidream

Existing issue search

  • I have searched the existing issues.

Summary

A new P2MR wallet gets a 16-key warm pool and fills the rest of its keypool in a deferred background top-up that starts 30 s later.

If the node stops before that top-up finishes, it never resumes for wallets loaded at node startup. Their receive lookahead stays at 16, and payments to later addresses of the same seed are not seen.

Current behaviour

An unencrypted wallet loaded through -wallet or load_on_startup therefore keeps a 16-key lookahead across every restart. It stays that way until keypoolrefill or an unloadwallet/loadwallet cycle. An encrypted wallet recovers at its first walletpassphrase.

Expected behaviour

Loading a wallet at startup should resume a pending deferred top-up, as loadwallet already does.

Steps to reproduce

Regtest, -p2mronly=1 -keypool=200:

  1. createwallet u with load_on_startup=true. keypoolsize is 16.
  2. Restart the node within 30 s, then wait 45 s. keypoolsize is still 16.
  3. Import the same descriptor into another wallet and hand out index 30. Pay that address. Wallet u shows balance 0.
  4. Run unloadwallet u and loadwallet u. The deferred top-up runs and keypoolsize becomes 200, but the balance stays 0 until rescanblockchain.

Suggested fix

Schedule the pending initial top-up from StartWallets, for example with MaybeSchedulePendingInitialKeyPoolTopUp.

The existing LoadWalletSchedulerRefillsDeferredP2MRKeypoolAcrossBatches test covers only the LoadWallet path. A matching test for LoadWallets + StartWallets would catch this.

Version

1.x.x at e374ba24cf; also v1.0.0 and v0.1.2-testnet4.

Activity

  1. added
    bug
    on Nov 3, 2026
  2. added a commit that references this issue on Nov 5, 2026
    dd86425
  3. kiwidream commented on Nov 5, 2026

    @kiwidream
    MemberAuthor

    Fixed on 1.x.x by #299 (merged as dd86425), which resumes a pending deferred P2MR keypool top-up for wallets loaded at startup (30 s after load). main gets the fix when 1.x.x is integrated.

  4. added a commit that references this issue on Nov 12, 2026
    b178391
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