From: merge-script Date: Mon, 12 Oct 2026 13:53:34 +0000 (+0100) Subject: Merge bitcoindevkit/bdk-cli#346: refactor(compile): use ValueEnum for script type X-Git-Url: http://internal-gitweb-vhost/-client-interface/src/encode/bitcoin/blockdata/script/struct.Transaction.html?a=commitdiff_plain;p=bdk-cli Merge bitcoindevkit/bdk-cli#346: refactor(compile): use ValueEnum for script type 79b2b8377bd0977d3f806ce1b82e3e88f0424f88 test(compile): cover sh and sh-wsh script types (Ikeh Celestine Chukwudi) 36e41a3afa66f575955bf81c62b91dd32e43a9e5 refactor(compile): use ValueEnum for script type (Ikeh Celestine Chukwudi) Pull request description: ### Description This PR replaces the `String` `script_type` in `CompileCommand` with a `ScriptType` enum deriving `clap::ValueEnum`. The goal is to make the `match` in `execute` exhaustive and keep the list of accepted script types in one place, instead of repeating it in the argument definition and in the match. Fixes #345 ### Notes to the reviewers The change is limited to `src/handlers/descriptor.rs` and follows the existing `DatabaseType` enum in `src/persister.rs`. * Added the `ScriptType` enum with the variants `Sh`, `Wsh`, `ShWsh` and `Tr`, gated behind the `compiler` feature like the rest of the `compile` command. * Changed `script_type` from `String` to `ScriptType`, replacing the hand-written `value_parser` list with `value_enum`. * The `match` in `execute` now matches on the enum variants. * Removed the `_ =>` arm returning "Invalid script type", which was unreachable because clap already rejects any other value. There is no CLI behavior change. clap renders the variants in kebab-case, so `--type` still accepts `sh`, `wsh`, `sh-wsh` and `tr`, the default is still `wsh`, and the `TYPE` env var still works. I checked manually that `compile --type sh-wsh` produces the same descriptor before and after the change, and the existing `compile` tests pass. ### Changelog notice None. This is an internal refactor with no user-facing change. ### 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 ACKs for top commit: tvpeter: ACK 79b2b8377bd0977d3f806ce1b82e3e88f0424f88 Tree-SHA512: cb8ab8fef5d109149740f22c20d6bee768079d082f3f84b7cb80541b605b66f2235d386ff080d4e31b24285a8e7935ab87deeae500abf9895f91d766226ba500 --- fe89838dcb53f0188d1dbecde8ae8bab05b991fc