From 9fb72e054b814daedbc442a977dd0ffb82876b70 Mon Sep 17 00:00:00 2001 From: andreasgriffin Date: Wed, 31 Jul 2024 21:46:19 +0200 Subject: [PATCH] Added finalize clippy map to OtherPsbtErr otherwise uniffi is giving a warning clippy --- bdk-ffi/src/bdk.udl | 3 +++ bdk-ffi/src/bitcoin.rs | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 2c8876e4..e59854e1 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -685,6 +685,9 @@ interface Psbt { [Throws=PsbtError] Psbt combine(Psbt other); + [Throws=PsbtError] + Psbt finalize(); + string json_serialize(); }; diff --git a/bdk-ffi/src/bitcoin.rs b/bdk-ffi/src/bitcoin.rs index 29439fe3..f15faba3 100644 --- a/bdk-ffi/src/bitcoin.rs +++ b/bdk-ffi/src/bitcoin.rs @@ -11,12 +11,14 @@ use bdk_wallet::bitcoin::consensus::encode::serialize; use bdk_wallet::bitcoin::consensus::Decodable; use bdk_wallet::bitcoin::io::Cursor; use bdk_wallet::bitcoin::psbt::ExtractTxError; +use bdk_wallet::bitcoin::secp256k1::Secp256k1; use bdk_wallet::bitcoin::Address as BdkAddress; use bdk_wallet::bitcoin::Network; use bdk_wallet::bitcoin::Psbt as BdkPsbt; use bdk_wallet::bitcoin::Transaction as BdkTransaction; use bdk_wallet::bitcoin::TxIn as BdkTxIn; use bdk_wallet::bitcoin::TxOut as BdkTxOut; +use bdk_wallet::miniscript::psbt::PsbtExt as MiniscriptPsbtExt; use std::fmt::Display; use std::ops::Deref; @@ -166,6 +168,15 @@ impl Psbt { psbt.to_string() } + pub(crate) fn finalize(&self) -> Result, PsbtError> { + let secp = Secp256k1::new(); + let result = self.0.lock().unwrap().clone().finalize(&secp); + match result { + Ok(psbt) => Ok(Arc::new(Psbt::from(psbt))), + Err((_psbt, _errors)) => Err(PsbtError::OtherPsbtErr), + } + } + pub(crate) fn extract_tx(&self) -> Result, ExtractTxError> { let tx: BdkTransaction = self.0.lock().unwrap().clone().extract_tx()?; let transaction: Transaction = tx.into();