wallet: Validate all descriptors before rescanning in importdescriptors #33938

pull psam21 wants to merge 1 commits into bitcoin:master from psam21:fix-importdescriptors-validate-first changing 1 files +145 −0
  1. psam21 commented at 1:29 pm on November 24, 2025: none

    Fixes #33655

    The importdescriptors RPC was performing expensive blockchain rescans even when descriptor validation failed, wasting time and resources.

    Changes

    This PR separates validation logic into a new ValidateDescriptorImport() function that validates all descriptors before any wallet modifications or rescanning occurs.

    Behavior

    • Before: ProcessDescriptorImport() validated and imported descriptors one by one, triggering a rescan even if some descriptors were invalid
    • After: ValidateDescriptorImport() checks all descriptors first, fails fast on any validation error, and only proceeds to ProcessDescriptorImport() and rescanning if all descriptors are valid

    Benefits

    • Fails fast on invalid descriptors without triggering rescan
    • Validates all descriptors upfront before processing any
    • Improves user experience with immediate feedback on validation errors
    • Saves significant time by avoiding unnecessary blockchain rescans
    • Follows the approach suggested by @pinheadmz in the issue discussion
  2. wallet: Validate all descriptors before rescanning in importdescriptors
    The importdescriptors RPC was performing a rescan even when descriptor
    validation failed. This wasted time and resources on invalid imports.
    
    This change separates validation into a new ValidateDescriptorImport()
    function that checks all descriptors before any wallet modifications or
    rescanning occurs. If any descriptor fails validation, the function
    returns early with an error, preventing unnecessary blockchain rescans.
    
    Benefits:
    - Fails fast on invalid descriptors without triggering rescan
    - Validates all descriptors upfront before processing any
    - Improves user experience by providing immediate feedback
    - Saves time by avoiding unnecessary blockchain rescans
    
    Fixes #33655
    065e2e56c2
  3. DrahtBot added the label Wallet on Nov 24, 2025
  4. DrahtBot commented at 1:29 pm on November 24, 2025: contributor

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

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33938.

    Reviews

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

  5. maflcko commented at 1:56 pm on November 24, 2025: member

    thx, but LLM generated pull requests, where the author does not understand the changes themselves, are not accepted:

    • There are no tests
    • The code does not even compile
    • There is a already a pull request and you’d have to review/reflect that one first, as already mentioned previously
  6. maflcko closed this on Nov 24, 2025


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: 2025-12-01 21:13 UTC

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