Review report

bitcoin/bitcoin: PR #36648

1 suggestion

Optional improvements

Link

[suggestion] · Key positions do not identify the failing taproot leaf

After removing quoted key text, an invalid key in a multi-leaf tr() produces a diagnostic that can match several leaves because key positions are local and no leaf number is reported.

Location: src/script/descriptor.cpp:2336 (head).

Details and suggested fix

Each miniscript leaf constructs a fresh KeyParser, so its key numbering restarts, while a standalone pk() leaf adds no position at all. tr() returns the failing leaf's error unchanged. For example, with valid keys K and A and a malformed WIF BAD, tr(K,{pk(A),pk(BAD)}) reports pk(): key is not valid, without identifying the second leaf. Previously, the quoted rejected key supplied that locator. Prefix failed subscript errors in tr() with the leaf number, using subscripts.size() after insertion, and add an assertion with an invalid key in a later leaf. This preserves rejection behavior and keeps key text out of errors.


Coverage details