Skip to content

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

@JeremyRubin

Description

@JeremyRubin

Summary:

When attempting to add a non-ranged descriptor with a start/end range of [0,0] via AddWalletDescriptor, an error may appear:

UpdateWalletDescriptor: new range must include current range = [0,0].

This is unexpected for a non-ranged descriptor, as [0,0] should effectively mean “no range.” In some cases, changing the end to 1 (i.e. [0,1]) circumvents the issue, but that implies a single-index range rather than a truly non-ranged descriptor.

Further debugging revealed this seems tied to:

  1. Multiple calls to AddWalletDescriptor for the same descriptor.
  2. Internal handling of descriptor ranges (the wallet expects a valid range for ranged descriptors, but still enforces checks on start/end even if the descriptor is meant to be non-ranged).
  3. A possible bug in UpdateWalletDescriptor when it encounters repeated or zero-width ranges.

What was expected:

  • Specifying [0,0] for a non-ranged descriptor (or not specifying a range at all) should not fail.
  • A truly non-ranged descriptor should not require these range checks.
  • AddWalletDescriptor should be idempotent

What actually happens:

  • Repeatedly adding a descriptor (or calling it in a way that triggers UpdateWalletDescriptor) with [0,0] can cause the wallet to complain that the “new range must include current range = [0,0]”.

Why this matters:

  • Non-ranged descriptor workflows should be consistent and should not require a dummy range.
  • The wallet code should either cleanly ignore range parameters for non-ranged descriptors or handle a [0,0] range gracefully.

Proposed fix or investigation:

  • Review AddWalletDescriptor and UpdateWalletDescriptor logic to ensure zero-width ([0,0]) or absent ranges are handled properly for non-ranged descriptors.
  • Confirm if the internal code should treat [0,0] as a valid non-ranged descriptor or if that scenario should simply be disallowed/ignored in favor of no range parameters at all.
  • Add tests to cover repeatedly adding the same descriptor and verifying correct behavior for non-ranged descriptors.
  • Change the wallet::WalletDescriptor to have std::optional<std::pair<start,end>> to differentiate unranged v.s. empty ranged descriptors.

This appears to be a minor bug, but it can lead to confusion and error messages when using or experimenting with non-ranged descriptors in custom wallet workflows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions