]> Untitled Git - bdk-cli/commitdiff
pulled verbose flag from walletops
authorSandipan Dey <hey@sandipan.dev>
Wed, 14 Jul 2021 18:35:18 +0000 (00:05 +0530)
committerSandipan Dey <hey@sandipan.dev>
Wed, 14 Jul 2021 19:19:39 +0000 (00:49 +0530)
Signed-off-by: Sandipan Dey <hey@sandipan.dev>
src/bdk_cli.rs
src/lib.rs

index 7371bc7e8dd19d4effb16fa4f52f8e76d46152f7..25df3b7a51783ff8bff82fc06e517bd1c6ae5da6 100644 (file)
@@ -221,7 +221,11 @@ fn handle_command(cli_opts: CliOpts, network: Network) -> Result<String, Error>
         } => {
             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<String, Error>
                             ReplSubCommand::OfflineWalletSubCommand(offline_subcommand) => {
                                 bdk_cli::handle_offline_wallet_subcommand(
                                     &online_wallet,
+                                    &wallet_opts,
                                     offline_subcommand,
                                 )
                             }
index 2e2d6763d5ca19ec4f19ca97a574231257dbc39f..1c38c600ed4dd7bb74c2a4a6ee7236fdb41f6b3a 100644 (file)
@@ -691,6 +691,7 @@ fn parse_outpoint(s: &str) -> Result<OutPoint, String> {
 /// Offline wallet sub-commands are described in [`OfflineWalletSubCommand`].
 pub fn handle_offline_wallet_subcommand<T, D>(
     wallet: &Wallet<T, D>,
+    wallet_opts: &WalletOpts,
     offline_subcommand: OfflineWalletSubCommand,
 ) -> Result<serde_json::Value, Error>
 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