From: Alekos Filini Date: Mon, 30 Nov 2020 13:23:19 +0000 (+0100) Subject: [cli] Add a flag to build PSBTs for offline signers X-Git-Tag: v0.1.0~20 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.MemoryDatabase.html?a=commitdiff_plain;h=2d6faaa5d4d957ba2d898c294420be5cf36822d5;p=bdk-cli [cli] Add a flag to build PSBTs for offline signers The `--offline_signer` flag forces the addition of `non_witness_utxo` and the full witness and redeem script for every output, which makes it easier for the signer to identify the change output. Closes #199 --- diff --git a/src/cli.rs b/src/cli.rs index 350614e..87a5ff6 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -163,6 +163,12 @@ pub fn make_cli_subcommands<'a, 'b>() -> App<'a, 'b> { .help("Selects which policy should be used to satisfy the internal descriptor") .takes_value(true) .number_of_values(1), + ) + .arg( + Arg::with_name("offline_signer") + .long("offline_signer") + .help("Make a PSBT that can be signed by offline signers and hardware wallets. Forces the addition of `non_witness_utxo` and more details to let the signer identify the change output.") + .takes_value(false), ), ) .subcommand( @@ -210,6 +216,12 @@ pub fn make_cli_subcommands<'a, 'b>() -> App<'a, 'b> { .value_name("SATS_VBYTE") .help("The new targeted fee rate in sat/vbyte") .takes_value(true), + ) + .arg( + Arg::with_name("offline_signer") + .long("offline_signer") + .help("Make a PSBT that can be signed by offline signers and hardware wallets. Forces the addition of `non_witness_utxo` and more details to let the signer identify the change output.") + .takes_value(false), ), ) .subcommand( @@ -444,6 +456,12 @@ where tx_builder = tx_builder.enable_rbf(); } + if sub_matches.is_present("offline_signer") { + tx_builder = tx_builder + .force_non_witness_utxo() + .include_output_redeem_witness_script(); + } + if let Some(fee_rate) = sub_matches.value_of("fee_rate") { let fee_rate = f32::from_str(fee_rate).map_err(|s| Error::Generic(s.to_string()))?; tx_builder = tx_builder.fee_rate(FeeRate::from_sat_per_vb(fee_rate)); @@ -495,6 +513,12 @@ where tx_builder = tx_builder.maintain_single_recipient(); } + if sub_matches.is_present("offline_signer") { + tx_builder = tx_builder + .force_non_witness_utxo() + .include_output_redeem_witness_script(); + } + if let Some(utxos) = sub_matches.values_of("utxos") { let utxos = utxos .map(|i| parse_outpoint(i))