From: Alekos Filini Date: Fri, 13 Nov 2020 11:53:42 +0000 (+0100) Subject: [cli] Split the internal and external policy paths X-Git-Tag: v0.1.0~35 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.Decoder.html?a=commitdiff_plain;h=aadeffaaccc62bca4ba395ddc28442a6f695562f;p=bdk-cli [cli] Split the internal and external policy paths --- diff --git a/src/cli.rs b/src/cli.rs index 513d25f..ada49cc 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -149,10 +149,18 @@ pub fn make_cli_subcommands<'a, 'b>() -> App<'a, 'b> { .takes_value(true), ) .arg( - Arg::with_name("policy") - .long("policy") + Arg::with_name("external_policy") + .long("external_policy") .value_name("POLICY") - .help("Selects which policy should be used to satisfy the descriptor") + .help("Selects which policy should be used to satisfy the external descriptor") + .takes_value(true) + .number_of_values(1), + ) + .arg( + Arg::with_name("internal_policy") + .long("internal_policy") + .value_name("POLICY") + .help("Selects which policy should be used to satisfy the internal descriptor") .takes_value(true) .number_of_values(1), ), @@ -430,10 +438,19 @@ where .map_err(Error::Generic)?; tx_builder = tx_builder.unspendable(unspendable); } - if let Some(policy) = sub_matches.value_of("policy") { + + let policies = vec![ + sub_matches + .value_of("external_policy") + .map(|p| (p, ScriptType::External)), + sub_matches + .value_of("internal_policy") + .map(|p| (p, ScriptType::Internal)), + ]; + for (policy, script_type) in policies.into_iter().filter_map(|x| x) { let policy = serde_json::from_str::>>(&policy) .map_err(|s| Error::Generic(s.to_string()))?; - tx_builder = tx_builder.policy_path(policy); + tx_builder = tx_builder.policy_path(policy, script_type); } let (psbt, details) = wallet.create_tx(tx_builder)?;