From 5dd68637770f9c34f70b0eeb945fb00e5da7d44d Mon Sep 17 00:00:00 2001 From: itorod Date: Mon, 7 Jul 2025 09:58:31 +0000 Subject: [PATCH] feat: Add `from_unsigned_tx` to Psbt --- bdk-ffi/src/bitcoin.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bdk-ffi/src/bitcoin.rs b/bdk-ffi/src/bitcoin.rs index a8aebd9d..d7e5dd15 100644 --- a/bdk-ffi/src/bitcoin.rs +++ b/bdk-ffi/src/bitcoin.rs @@ -484,6 +484,17 @@ impl Psbt { Ok(Psbt(Mutex::new(psbt))) } + /// Creates a PSBT from an unsigned transaction. + /// + /// # Errors + /// + /// If transactions is not unsigned. + #[uniffi::constructor] + pub(crate) fn from_unsigned_tx(tx: Arc) -> Result, PsbtError> { + let psbt: BdkPsbt = BdkPsbt::from_unsigned_tx(tx.0.clone())?; + Ok(Arc::new(Psbt(Mutex::new(psbt)))) + } + /// Serialize the PSBT into a base64-encoded string. pub(crate) fn serialize(&self) -> String { let psbt = self.0.lock().unwrap().clone();