chore: improve key parsing logic and fix premature termination issues #2008

pull famouswizard wants to merge 1 commits into bitcoin:master from famouswizard:patch-1 changing 1 files +19 −8
  1. famouswizard commented at 11:26 am on October 18, 2025: none

    fixed several parsing bugs in key handling logic:

    • find_key_end_position: removed '/' from the set of terminating characters. This prevents derivation paths like .../44'/0'/0'/... from being truncated at the first /.
    • parse_key_expressions: implemented proper parenthesis depth tracking for musig(...) expressions instead of stopping at the first ), allowing correct parsing of nested expressions.
    • parse_key_expressions: added boundary checks (key_pos_end < len(descriptor)) before indexing descriptor[key_pos_end] to avoid IndexError at string ends.

    these changes ensure the parser correctly handles complex key expressions and avoids crashes on edge cases.

  2. chore: improve key parsing logic and fix premature termination issues 6c592a0cd3
  3. murchandamus commented at 10:08 pm on January 13, 2026: contributor
    This looks like AI slop to me, so I’m gonna close it. Please feel free to explain what actual issue this resolves should there be any merit to this, so it can be considered for reopening. cc: @bigspider.
  4. murchandamus closed this on Jan 13, 2026

  5. bigspider commented at 10:11 pm on January 13, 2026: contributor

    The code is meant mostly for illustrative purposes. However:

    • find_key_end_position definitely intends to truncate at the first /
    • nested musig is explicitly forbidden by the specifications in BIP-388 (and, today, by descriptors)
    • pretty sure key_pos_end can never be larger than or equal to len(descriptor), by construction.

    So I don’t think those are improvements.

  6. murchandamus commented at 10:12 pm on January 13, 2026: contributor
    Thanks for your time, @bigspider.

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bips. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-01-16 16:10 UTC

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