Wallet: Fix Non-Ranged Descriptors with Range [0,0] Trigger Unexpected Wallet Errors in AddWalletDescriptor #32344

pull Eunovo wants to merge 2 commits into bitcoin:master from Eunovo:bug-fix-wallet-add-non-ranged-descriptors changing 2 files +26 −0
  1. Eunovo commented at 7:22 pm on April 24, 2025: contributor

    Closes #31728

    This PR updates the DescriptorScriptPubKeyMan to skip range checks for non-ranged descriptors, which previously caused errors when updating a non-ranged descriptor with the range [0,0]

    Testing

    A unit test was added to test the new behaviour

  2. DrahtBot commented at 7:22 pm on April 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/32344.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK achow101, BrandonOdiwuor
    Concept ACK w0xlt, shahsb

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot renamed this:
    Bug/Wallet: Non-Ranged Descriptors with Range [0,0] Trigger Unexpected Wallet Errors in AddWalletDescriptor
    Bug/Wallet: Non-Ranged Descriptors with Range [0,0] Trigger Unexpected Wallet Errors in AddWalletDescriptor
    on Apr 24, 2025
  4. Eunovo force-pushed on Apr 24, 2025
  5. DrahtBot added the label CI failed on Apr 24, 2025
  6. DrahtBot commented at 7:32 pm on April 24, 2025: contributor

    🚧 At least one of the CI tasks failed. Debug: https://github.com/bitcoin/bitcoin/runs/41113093377

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

  7. Eunovo renamed this:
    Bug/Wallet: Non-Ranged Descriptors with Range [0,0] Trigger Unexpected Wallet Errors in AddWalletDescriptor
    Wallet: Non-Ranged Descriptors with Range [0,0] Trigger Unexpected Wallet Errors in AddWalletDescriptor
    on Apr 24, 2025
  8. Eunovo renamed this:
    Wallet: Non-Ranged Descriptors with Range [0,0] Trigger Unexpected Wallet Errors in AddWalletDescriptor
    Wallet: Fix Non-Ranged Descriptors with Range [0,0] Trigger Unexpected Wallet Errors in AddWalletDescriptor
    on Apr 24, 2025
  9. w0xlt commented at 10:39 pm on April 24, 2025: contributor

    Concept ACK.

    Functional tests might be necessary.

  10. DrahtBot removed the label CI failed on Apr 24, 2025
  11. DrahtBot added the label Wallet on Apr 24, 2025
  12. Skip range verification for non-ranged desc
    Non-range desc  are always added to the wallet with the range [0,0]. After the descriptor is added, the wallet will  TopUp the keypool. For non-range descriptors, this process updates the desc range to [0,1].
    
    Any attempts to update this non-range descriptor with a [0,0] range will result in an error because the range checks rejects new ranges not included in the old range.
    
    Since  this is a non-range desc, the range information should be disregarded and AddWalletDescriptor should always succeed regardless of provided range information
    2ae1788dd4
  13. Test updating non-ranged descriptor with [0,0] range succeeds fa0993462b
  14. Eunovo force-pushed on Apr 25, 2025
  15. Eunovo commented at 4:56 am on April 25, 2025: contributor

    Functional tests might be necessary.

    The importdescriptors RPC sets the range for all non-ranged descriptors to [0,1] in every request so this error cannot be triggered using the RPC.

    In #31728 @JeremyRubin explains that this error may be unexpectedly triggered when " experimenting with non-ranged descriptors in custom wallet workflows."

  16. in src/wallet/test/wallet_tests.cpp:91 in fa0993462b
    86+            FlatSigningProvider provider;
    87+            std::string error;
    88+            auto descs{Parse(desc_str, provider, error, /* require_checksum=*/ false)};
    89+            auto& desc{descs.at(0)};
    90+            WalletDescriptor w_desc{std::move(desc), 0, 0, 0, 0};
    91+            auto spk_manager{*Assert(wallet.AddWalletDescriptor(w_desc, provider, "", false))};
    


    shahsb commented at 9:02 am on April 26, 2025:
    I do not see the call to the function DescriptorScriptPubKeyMan::CanUpdateToWalletDescriptor() being made in this test case?

    Eunovo commented at 1:04 pm on April 26, 2025:
    Calling AddWalletDescriptor with a descriptor that’s already in wallet, calls UpdateWalletDescriptor which calls CanUpdateWalletDescriptor. This is what happens on the second call to AddWalletDescriptor.
  17. shahsb commented at 9:02 am on April 26, 2025: none
    Concept ACK
  18. achow101 commented at 10:25 pm on April 30, 2025: member
    ACK fa0993462b3bc8db40c1a6ea2e7f5fd4a22353a6
  19. DrahtBot requested review from shahsb on Apr 30, 2025
  20. DrahtBot requested review from w0xlt on Apr 30, 2025
  21. BrandonOdiwuor commented at 3:45 pm on May 2, 2025: contributor
    Code Review ACK fa0993462b3bc8db40c1a6ea2e7f5fd4a22353a6

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-05-05 12:12 UTC

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