From: merge-script Date: Mon, 5 Oct 2026 18:50:35 +0000 (+0100) Subject: Merge bitcoindevkit/bdk-cli#317: fix(compile): compile only for the requested script... X-Git-Url: http://internal-gitweb-vhost/-client-interface/src/example_cli/psbt/struct.InputsIndexError.html?a=commitdiff_plain;p=bdk-cli Merge bitcoindevkit/bdk-cli#317: fix(compile): compile only for the requested script context eadbdc7db8b80728d8dfd2dafadf6f4f901afb16 fix(compile): compile only for the requested script context (Vadim Anufriev) Pull request description: The policy is compiled for all three script contexts one after another, before `--type` is looked at, and any of those failing aborts the command. So a policy that is valid for the type you asked for is rejected because it is invalid for one of the other two. Here a 9-of-16 multisig is compiled with `--type tr` and fails on the sh limit: 16 keys don't fit into [`MAX_SCRIPT_ELEMENT_SIZE`](https://github.com/rust-bitcoin/rust-miniscript/blob/miniscript-12.3.7/src/miniscript/limits.rs#L22), the 520-byte consensus limit for the sh redeem script. Taproot has no such limit. ``` $ cargo run --all-features -- compile "thresh(9,pk(1),pk(2),pk(3),pk(4),pk(5),pk(6),pk(7),pk(8),pk(9),pk(10),pk(11),pk(12),pk(13),pk(14),pk(15),pk(16))" --type tr thread 'main' panicked at miniscript-12.3.7/src/policy/compiler.rs:506:52: Terminal creation must always succeed: ContextError(MaxRedeemScriptSizeExceeded) ``` The fix moves the compilation into the matching branch, so only the requested context is compiled. ## Changelog notice - Fixed `compile` rejecting policies that are valid for the requested script type ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk-cli/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### Bugfixes: * [ ] This pull request breaks the existing API * [x] I've added tests to reproduce the issue which are now passing * [ ] I'm linking the issue being fixed by this PR ACKs for top commit: tvpeter: reACK eadbdc7db8b80728d8dfd2dafadf6f4f901afb16 Tree-SHA512: 3c6b082d429ac922ea36b8613293e82d6940b9090e080124a89e91ef8d144f3806d608a3760a811699e2d58db85184c142a8006d38fdb990d81d54711e93ffc7 --- 4f4d8cafb3dd6a449aa587e520ece781128f0904