diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 14373b7a..a8cab3ba 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -719,6 +719,8 @@ interface TxBuilder { TxBuilder allow_dust(boolean allow_dust); + TxBuilder version(i32 version); + [Throws=CreateTxError] Psbt finish([ByRef] Wallet wallet); }; @@ -734,6 +736,8 @@ interface BumpFeeTxBuilder { BumpFeeTxBuilder allow_dust(boolean allow_dust); + BumpFeeTxBuilder version(i32 version); + [Throws=CreateTxError] Psbt finish([ByRef] Wallet wallet); }; diff --git a/bdk-ffi/src/tx_builder.rs b/bdk-ffi/src/tx_builder.rs index e0f88997..f6efae8f 100644 --- a/bdk-ffi/src/tx_builder.rs +++ b/bdk-ffi/src/tx_builder.rs @@ -40,6 +40,7 @@ pub struct TxBuilder { pub(crate) current_height: Option, pub(crate) locktime: Option, pub(crate) allow_dust: bool, + pub(crate) version: Option, } impl TxBuilder { @@ -62,6 +63,7 @@ impl TxBuilder { current_height: None, locktime: None, allow_dust: false, + version: None, } } @@ -232,6 +234,13 @@ impl TxBuilder { }) } + pub(crate) fn version(&self, version: i32) -> Arc { + Arc::new(TxBuilder { + version: Some(version), + ..self.clone() + }) + } + pub(crate) fn finish(&self, wallet: &Arc) -> Result, CreateTxError> { // TODO: I had to change the wallet here to be mutable. Why is that now required with the 1.0 API? let mut wallet = wallet.get_wallet(); @@ -290,6 +299,9 @@ impl TxBuilder { if self.allow_dust { tx_builder.allow_dust(self.allow_dust); } + if let Some(version) = self.version { + tx_builder.version(version); + } let psbt = tx_builder.finish().map_err(CreateTxError::from)?; @@ -305,6 +317,7 @@ pub(crate) struct BumpFeeTxBuilder { pub(crate) current_height: Option, pub(crate) locktime: Option, pub(crate) allow_dust: bool, + pub(crate) version: Option, } impl BumpFeeTxBuilder { @@ -316,6 +329,7 @@ impl BumpFeeTxBuilder { current_height: None, locktime: None, allow_dust: false, + version: None, } } @@ -347,6 +361,13 @@ impl BumpFeeTxBuilder { }) } + pub(crate) fn version(&self, version: i32) -> Arc { + Arc::new(BumpFeeTxBuilder { + version: Some(version), + ..self.clone() + }) + } + pub(crate) fn finish(&self, wallet: &Arc) -> Result, CreateTxError> { let txid = Txid::from_str(self.txid.as_str()).map_err(|_| CreateTxError::UnknownUtxo { outpoint: self.txid.clone(), @@ -367,6 +388,9 @@ impl BumpFeeTxBuilder { if self.allow_dust { tx_builder.allow_dust(self.allow_dust); } + if let Some(version) = self.version { + tx_builder.version(version); + } let psbt: BdkPsbt = tx_builder.finish()?;