wallet: stop materializing skipped descriptor addresses after high-index detection #35092

pull takeshikurosawaa wants to merge 2 commits into bitcoin:master from takeshikurosawaa:fix-25895-descriptor-large-range-hang changing 2 files +92 −13
  1. takeshikurosawaa commented at 10:10 AM on April 16, 2026: none

    This fixes the high-index ranged descriptor update path reported in #25895.

    When a descriptor wallet detects use of a ranged item at a high index, MarkUnusedAddresses() currently expands every skipped item up to that index and records each destination in the address book. For large gaps, that turns a single high-index hit into gap-sized work and can make the import/update path appear hung.

    Instead, advance next_index directly past the observed item and return only the observed destination. Skipped destinations are no longer materialized eagerly, but they can still be recorded later if they are actually seen in wallet transactions.

    This intentionally changes listreceivedbyaddress(..., include_empty=True) behavior for this case: a high-index hit no longer creates a gap-sized receive address set. getnewaddress() progression, change derivation, lazy recording of later-used skipped addresses, and reload persistence are covered by the functional test added here.

    Tests:

    • wallet_importdescriptors.py
    • wallet_listreceivedby.py
    • wallet_descriptor.py
    • test_bitcoin --run_test=scriptpubkeyman_tests,wallet_tests,walletdb_tests,walletload_tests
  2. wallet: bound descriptor update work after high-index detection
    Avoid materializing a destination for every skipped index when a descriptor wallet observes a used ranged item at a high index. Advance next_index directly and return only the observed destination so address-book updates stay bounded while skipped addresses can still be recorded lazily if they are later seen.
    
    Add a functional regression covering high-index import detection, address-book fanout, lazy skipped-address handling, getnewaddress/getrawchangeaddress, and wallet reload persistence.
    6490395c51
  3. DrahtBot added the label Wallet on Apr 16, 2026
  4. DrahtBot commented at 10:11 AM on April 16, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34993 (wallet: NotifyCanGetAddressesChanged when advancing next_index by davidgumberg)
    • #33392 (wallet, rpc: add UTXO set check and incremental rescan to importdescriptors by musaHaruna)
    • #32861 (Have createwalletdescriptor auto-detect an unused(KEY) by Sjors)
    • #32784 (wallet: derivehdkey RPC to get xpub at arbitrary path by Sjors)
    • #31668 (Added rescan option for import descriptors by saikiran57)
    • #30343 (wallet, logging: Replace WalletLogPrintf() with LogInfo() by ryanofsky)
    • #29136 (wallet: addhdkey RPC to add just keys to wallets via new unused(KEY) descriptor by achow101)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. test: use functional assert helper
    Replace a raw inequality assertion in the high-index descriptor regression with assert_not_equal() to match the functional test style used elsewhere in the tree.
    a2676538fe
  6. takeshikurosawaa renamed this:
    wallet: bound descriptor update work after high-index detection
    wallet: stop materializing skipped descriptor addresses after high-index detection
    on Apr 17, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 09:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me