wallet: Validate all descriptors before importing in importdescriptors #34903

pull HouseOfHufflepuff wants to merge 1 commits into bitcoin:master from HouseOfHufflepuff:wallet-importdescriptors-validate-before-rescan changing 2 files +144 −1
  1. HouseOfHufflepuff commented at 3:47 pm on March 23, 2026: none

    Summary

    • Extract descriptor validation into a separate ValidateDescriptorImport() function
    • Run a validation pass over all descriptors before importing any, so users get immediate error feedback without waiting for a potentially lengthy blockchain rescan
    • If any descriptor fails validation, return immediately — no wallet modifications or rescan are performed
    • Follows pinheadmz’s suggested approach from #33655: “separate the validation into a separate function entirely, so we validate in a loop first then process in a second loop”
    • There’s code duplication between ValidateDescriptorImport and the first half of ProcessDescriptorImport. Happy to consolidate if requested.
    • Addresses achow101’s concern from #33874: descriptors that were not actually imported never return success: true

    fixes #33655

    Test plan

    • New functional test in wallet_importdescriptors.py verifies batch validation behavior
    • All existing wallet_importdescriptors.py tests pass
    • Unit tests pass
  2. wallet: Validate all descriptors before importing in importdescriptors
    Currently, importdescriptors validates and imports descriptors in a
    single loop, then rescans. If any descriptor has a validation error
    (e.g., internal descriptor with a label), the user only sees that
    error after the potentially lengthy rescan completes.
    
    Extract validation logic into a separate ValidateDescriptorImport()
    function and run it for all descriptors before any are imported. If
    any descriptor fails validation, return immediately with errors for
    all descriptors — no wallet modifications or rescan are performed.
    
    Descriptors that passed validation but were not imported (due to a
    sibling failing) are marked with success: false and a message
    explaining the batch was aborted.
    
    Add a functional test verifying the batch-validation-before-import
    behavior.
    
    fixes #33655
    5fa3aad68d
  3. DrahtBot added the label Wallet on Mar 23, 2026
  4. DrahtBot commented at 3:48 pm on March 23, 2026: contributor

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

    Reviews

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

  5. HouseOfHufflepuff commented at 3:49 pm on March 23, 2026: none

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-03-24 03:12 UTC

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