From: Dominik Spicher Date: Fri, 7 Aug 2020 14:08:23 +0000 (+0200) Subject: [examples] Fix Miniscript variants issue in compiler example X-Git-Tag: 0.1.0-beta.1~35 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/enum.FileStoreError.html?a=commitdiff_plain;h=462d413b02ec05b401d25dd7acb3237fcb522b4a;p=bdk [examples] Fix Miniscript variants issue in compiler example miniscript has extended the `Miniscript` struct to be generic over a `ScriptContext`. This context is different for the `Sh` variant (`Legacy`) than for the `Wsh` and `ShWsh` variants (`Segwitv0`). Therefore, Rust is not happy with the single `compiled` variable if it is used as an argument for all three variants. --- diff --git a/examples/compiler.rs b/examples/compiler.rs index 09cad948..04558fba 100644 --- a/examples/compiler.rs +++ b/examples/compiler.rs @@ -63,12 +63,11 @@ fn main() { info!("Compiling policy: {}", policy_str); let policy = Concrete::::from_str(&policy_str).unwrap(); - let compiled = policy.compile().unwrap(); let descriptor = match matches.value_of("TYPE").unwrap() { - "sh" => Descriptor::Sh(compiled), - "wsh" => Descriptor::Wsh(compiled), - "sh-wsh" => Descriptor::ShWsh(compiled), + "sh" => Descriptor::Sh(policy.compile().unwrap()), + "wsh" => Descriptor::Wsh(policy.compile().unwrap()), + "sh-wsh" => Descriptor::ShWsh(policy.compile().unwrap()), _ => panic!("Invalid type"), };