Review report

bitcoin/bitcoin: PR #36420

1 major finding · 1 suggestion

Earlier concerns neither republished nor resolved: 1 major finding · 1 suggestion. See the Run archive for their assessments.

Findings

Link

[major] · Stored Tapscript parity duplicates block the entire wallet load

Upgrading a wallet with a previously imported Tapscript Miniscript descriptor containing opposite-parity hex keys makes the entire wallet fail to load, even if that descriptor is inactive.

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

Details and suggested fix

WalletDescriptor::FromStream uses the same Parse(), so this change also tightens database loading. At base, a checksummed tr(K,or_i(pk(02X),pk(03X))), or the pk(X)/pk(03X) form, can be manually imported with active=false and no range into a watch-only wallet. Supplying a private internal key also permits import into a private-key-enabled wallet, with a warning about missing leaf keys. The constant-hex providers retain their parity prefixes in ToString(), which WalletDescriptor::Serialize stores. Head rejects that record as not sane, converts the exception to UNKNOWN_DESCRIPTOR, and makes LoadExisting reject the whole wallet, including unrelated descriptors. Restoring an affected backup follows the same load path, while the error misleadingly suggests newer software. The added x-only/WIF fixture already normalized to duplicate x-only keys on base reload and is not this new regression. No in-tree caller creating the triggering descriptors was found, so production occurrence after manual import is unconfirmed. Data and consensus-valid outputs remain intact, and base software can still load the wallet. Keep rejecting new imports, but provide legacy loading with a warning while preserving the original scripts and descriptor IDs, without treating these descriptors as sane for new use. Cover that behavior with an explicit 02X/03X wallet-load regression test.


Optional improvements

Link

[suggestion] · Tapscript parity equivalence is untested in KeyConverter

The existing Miniscript fixtures do not distinguish the new x-only comparator from the old full-key comparator, leaving this helper change without regression protection.

Location: src/test/miniscript_tests.cpp:138 (head).

Details and suggested fix

Test() runs both script contexts, but its fixture keys come from private scalars 1..255 and contain no negation pairs. The explicit duplicate-key assertions use only wsh_converter, while the new descriptor cases exercise the separate production KeyParser. Add a direct miniscript::FromString case for or_i(pk(02X),pk(03X)), using the valid x-coordinate from the new descriptor tests. With tap_converter, assert !CheckDuplicateKey() and !IsSane(). With wsh_converter, assert that both checks succeed. This would distinguish parity-equivalent Tapscript keys from distinct compressed P2WSH keys and protect the changed helper branch. No signing data is needed for these parse-and-classify assertions.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.