Skip to content

Commit 524562c

Browse files
committed
fix: signing / finalizing psbt
- fix the returned data after signing or finalizing `psbt` [Ticket: X]
1 parent fb7232f commit 524562c

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/handlers.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::error::BDKCliError as Error;
2323
use crate::utils::*;
2424
use bdk_wallet::bip39::{Language, Mnemonic};
2525
use bdk_wallet::bitcoin::bip32::{DerivationPath, KeySource};
26-
use bdk_wallet::bitcoin::consensus::encode::{serialize, serialize_hex};
26+
use bdk_wallet::bitcoin::consensus::encode::serialize_hex;
2727
use bdk_wallet::bitcoin::script::PushBytesBuf;
2828
use bdk_wallet::bitcoin::Network;
2929
#[cfg(any(
@@ -208,15 +208,14 @@ pub fn handle_offline_wallet_subcommand(
208208

209209
let psbt = tx_builder.finish()?;
210210

211-
let serialized_psbt = psbt.serialize();
212-
let psbt_base64 = BASE64_STANDARD.encode(serialized_psbt);
211+
let psbt_base64 = BASE64_STANDARD.encode(psbt.serialize());
213212

214213
if wallet_opts.verbose {
215214
Ok(
216-
json!({"psbt": psbt_base64, "serialized_psbt": psbt.serialize(), "details": psbt}),
215+
json!({"psbt": psbt_base64, "details": psbt}),
217216
)
218217
} else {
219-
Ok(json!({"psbt": psbt_base64, "details": psbt}))
218+
Ok(json!({"psbt": psbt_base64 }))
220219
}
221220
}
222221
BumpFee {
@@ -253,10 +252,9 @@ pub fn handle_offline_wallet_subcommand(
253252

254253
let psbt = tx_builder.finish()?;
255254

256-
let serialized_psbt = psbt.serialize();
257-
let psbt_base64 = BASE64_STANDARD.encode(serialized_psbt);
255+
let psbt_base64 = BASE64_STANDARD.encode(psbt.serialize());
258256

259-
Ok(json!({"psbt": psbt_base64, "details": psbt}))
257+
Ok(json!({"psbt": psbt_base64 }))
260258
}
261259
Policies => {
262260
let external_policy = wallet.policies(KeychainKind::External)?;
@@ -284,13 +282,14 @@ pub fn handle_offline_wallet_subcommand(
284282
..Default::default()
285283
};
286284
let finalized = wallet.sign(&mut psbt, signopt)?;
285+
let psbt_base64 = BASE64_STANDARD.encode(psbt.serialize());
287286
if wallet_opts.verbose {
288287
Ok(
289-
json!({"psbt": BASE64_STANDARD.encode(serialize(&psbt_bytes)),"is_finalized": finalized, "serialized_psbt": psbt}),
288+
json!({"psbt": &psbt_base64, "is_finalized": finalized, "serialized_psbt": &psbt}),
290289
)
291290
} else {
292291
Ok(
293-
json!({"psbt": BASE64_STANDARD.encode(serialize(&psbt_bytes)),"is_finalized": finalized,}),
292+
json!({"psbt": &psbt_base64, "is_finalized": finalized,}),
294293
)
295294
}
296295
}
@@ -316,11 +315,11 @@ pub fn handle_offline_wallet_subcommand(
316315
let finalized = wallet.finalize_psbt(&mut psbt, signopt)?;
317316
if wallet_opts.verbose {
318317
Ok(
319-
json!({ "psbt": BASE64_STANDARD.encode(serialize(&psbt_bytes)),"is_finalized": finalized, "serialized_psbt": psbt}),
318+
json!({ "psbt": BASE64_STANDARD.encode(psbt.serialize()), "is_finalized": finalized, "details": psbt}),
320319
)
321320
} else {
322321
Ok(
323-
json!({ "psbt": BASE64_STANDARD.encode(serialize(&psbt_bytes)),"is_finalized": finalized,}),
322+
json!({ "psbt": BASE64_STANDARD.encode(psbt.serialize()), "is_finalized": finalized,}),
324323
)
325324
}
326325
}

0 commit comments

Comments
 (0)