Review report

bitcoin/bitcoin: PR #36648

2 suggestions

Optional improvements

Link

[suggestion] · Errors lose the failing leaf or path-element location

Removing quoted key text leaves errors ambiguous across taproot leaves and within long derivation paths, despite the new local key positions.

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

Details and suggested fix

In tr(H,{pk(A),pk(B)}), a WIF typo in either A or B now produces the same pk(): key is not valid error. The taproot parser returns the failing leaf's error unchanged. Miniscript key positions do not resolve this across leaves because each leaf creates a fresh KeyParser, restarting its count. Likewise, ParseKeyPath forwards Key path value is not a valid uint32 without identifying the element. Add a leaf position when propagating taproot errors and an element position when propagating path errors. These structural positions would restore useful location information without quoting key material. Top-level single-key descriptors and the local multi()/musig() positions already identify the key; they still do not identify a failing path element.


Link

[suggestion] · Wrapper failures are reported as invalid pk() expressions

A taproot leaf with invalid miniscript wrappers reports Not a valid pk() expression even when its underlying pk(K) is valid, directing users to the wrong part of the expression.

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

Details and suggested fix

For z:pk(K) or vv:pk(K) with a valid key, miniscript rejects the unknown or doubled wrapper before parsing the key. No key-parsing error is set, so the fallback strips the prefix, recognizes pk, and reports Not a valid pk() expression. This fallback applies in TOP and P2TR contexts; P2WSH returns its earlier function-needed error. The updated wallet_miniscript.py assertion also pins this message for a leaf rejected because one extra n wrapper exceeds the parser's script-size limit. When stripping a wrapper prefix, use a generic non-echoing message for the wrapped miniscript expression and update that assertion. This would avoid blaming the inner function without changing rejection behavior; reporting the precise wrapper or size failure would require additional error plumbing.


Coverage details