From: Sandipan Dey Date: Wed, 14 Jul 2021 18:35:18 +0000 (+0530) Subject: pulled verbose flag from walletops X-Git-Tag: v0.3.0~37 X-Git-Url: http://internal-gitweb-vhost/?a=commitdiff_plain;h=64bd86dfba23d967e9a82a7e22e3c1a861887810;p=bdk-cli pulled verbose flag from walletops Signed-off-by: Sandipan Dey --- diff --git a/src/bdk_cli.rs b/src/bdk_cli.rs index 7371bc7..25df3b7 100644 --- a/src/bdk_cli.rs +++ b/src/bdk_cli.rs @@ -221,7 +221,11 @@ fn handle_command(cli_opts: CliOpts, network: Network) -> Result } => { let database = open_database(&wallet_opts); let wallet = new_offline_wallet(network, &wallet_opts, database)?; - let result = bdk_cli::handle_offline_wallet_subcommand(&wallet, offline_subcommand)?; + let result = bdk_cli::handle_offline_wallet_subcommand( + &wallet, + &wallet_opts, + offline_subcommand, + )?; serde_json::to_string_pretty(&result)? } CliSubCommand::Key { @@ -290,6 +294,7 @@ fn handle_command(cli_opts: CliOpts, network: Network) -> Result ReplSubCommand::OfflineWalletSubCommand(offline_subcommand) => { bdk_cli::handle_offline_wallet_subcommand( &online_wallet, + &wallet_opts, offline_subcommand, ) } diff --git a/src/lib.rs b/src/lib.rs index 2e2d676..1c38c60 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -691,6 +691,7 @@ fn parse_outpoint(s: &str) -> Result { /// Offline wallet sub-commands are described in [`OfflineWalletSubCommand`]. pub fn handle_offline_wallet_subcommand( wallet: &Wallet, + wallet_opts: &WalletOpts, offline_subcommand: OfflineWalletSubCommand, ) -> Result where @@ -754,7 +755,13 @@ where } let (psbt, details) = tx_builder.finish()?; - Ok(json!({"psbt": base64::encode(&serialize(&psbt)),"details": details,})) + if wallet_opts.verbose { + Ok( + json!({"psbt": base64::encode(&serialize(&psbt)),"details": details, "serialized_psbt": psbt}), + ) + } else { + Ok(json!({"psbt": base64::encode(&serialize(&psbt)),"details": details})) + } } BumpFee { txid, @@ -807,7 +814,13 @@ where ..Default::default() }; let finalized = wallet.sign(&mut psbt, signopt)?; - Ok(json!({"psbt": base64::encode(&serialize(&psbt)),"is_finalized": finalized,})) + if wallet_opts.verbose { + Ok( + json!({"psbt": base64::encode(&serialize(&psbt)),"is_finalized": finalized, "serialized_psbt": psbt}), + ) + } else { + Ok(json!({"psbt": base64::encode(&serialize(&psbt)),"is_finalized": finalized,})) + } } ExtractPsbt { psbt } => { let psbt = base64::decode(&psbt).unwrap(); @@ -826,7 +839,13 @@ where ..Default::default() }; let finalized = wallet.finalize_psbt(&mut psbt, signopt)?; - Ok(json!({ "psbt": base64::encode(&serialize(&psbt)),"is_finalized": finalized,})) + if wallet_opts.verbose { + Ok( + json!({ "psbt": base64::encode(&serialize(&psbt)),"is_finalized": finalized, "serialized_psbt": psbt}), + ) + } else { + Ok(json!({ "psbt": base64::encode(&serialize(&psbt)),"is_finalized": finalized,})) + } } CombinePsbt { psbt } => { let mut psbts = psbt