From 1fd30843122bd8cfa9df8d27444d4c665718fd5e Mon Sep 17 00:00:00 2001 From: shivv23 Date: Fri, 3 Jul 2026 13:32:47 +0530 Subject: [PATCH] feat: expose Display trait on Amount and Psbt types Signed-off-by: shivv23 --- bdk-ffi/src/bitcoin.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bdk-ffi/src/bitcoin.rs b/bdk-ffi/src/bitcoin.rs index 223f874ce..1951ed224 100644 --- a/bdk-ffi/src/bitcoin.rs +++ b/bdk-ffi/src/bitcoin.rs @@ -217,8 +217,15 @@ impl_into_core_type!(FeeRate, BdkFeeRate); /// underflow occurs. Also note that since the internal representation of amounts is unsigned, /// subtracting below zero is considered an underflow and will cause a panic. #[derive(Debug, Clone, PartialEq, Eq, uniffi::Object)] +#[uniffi::export(Display)] pub struct Amount(pub(crate) BdkAmount); +impl Display for Amount { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + #[uniffi::export] impl Amount { /// Create an Amount with satoshi precision and the given number of satoshis. @@ -1389,8 +1396,15 @@ impl From<&BdkOutput> for Output { /// A Partially Signed Transaction. #[derive(uniffi::Object)] +#[uniffi::export(Display)] pub struct Psbt(pub(crate) Mutex); +impl Display for Psbt { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{}", self.0.lock().unwrap()) + } +} + #[uniffi::export] impl Psbt { /// Creates a new `Psbt` instance from a base64-encoded string.