diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 211b38b..1d81b34 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -654,6 +654,9 @@ interface Psbt { [Throws=ExtractTxError] Transaction extract_tx(); + + [Throws=PsbtError] + u64 fee(); }; dictionary OutPoint { diff --git a/bdk-ffi/src/bitcoin.rs b/bdk-ffi/src/bitcoin.rs index 09c9e66..d994205 100644 --- a/bdk-ffi/src/bitcoin.rs +++ b/bdk-ffi/src/bitcoin.rs @@ -1,4 +1,4 @@ -use crate::error::{AddressError, FeeRateError, PsbtParseError, TransactionError}; +use crate::error::{AddressError, FeeRateError, PsbtError, PsbtParseError, TransactionError}; use bdk::bitcoin::address::{NetworkChecked, NetworkUnchecked}; use bdk::bitcoin::amount::ParseAmountError; @@ -219,6 +219,30 @@ impl Psbt { let transaction: Transaction = tx.into(); Ok(Arc::new(transaction)) } + + pub(crate) fn fee(&self) -> Result { + self + .0 + .lock() + .unwrap() + .fee() + .map(|fee| fee.to_sat()) + .map_err(PsbtError::from) + } + + // + // pub(crate) fn combine( + // &self, + // other: Arc, + // ) -> Result, > { + // let other_psbt = other.inner.lock().unwrap().clone(); + // let mut original_psbt = self.inner.lock().unwrap().clone(); + // + // original_psbt.combine(other_psbt)?; + // Ok(Arc::new(PartiallySignedTransaction { + // inner: Mutex::new(original_psbt), + // })) + // } } impl From for Psbt {