From a62a58bd8e6ea46c2bb4d2719e653587a0bc0d8d Mon Sep 17 00:00:00 2001 From: shivv23 Date: Tue, 14 Jul 2026 21:52:22 +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..478d2d141 100644 --- a/bdk-ffi/src/bitcoin.rs +++ b/bdk-ffi/src/bitcoin.rs @@ -217,6 +217,7 @@ 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); #[uniffi::export] @@ -249,6 +250,12 @@ impl Amount { impl_from_core_type!(BdkAmount, Amount); impl_into_core_type!(Amount, BdkAmount); +impl Display for Amount { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + /// A bitcoin script: https://en.bitcoin.it/wiki/Script #[derive(Clone, Debug, uniffi::Object)] #[uniffi::export(Display)] @@ -1389,6 +1396,7 @@ impl From<&BdkOutput> for Output { /// A Partially Signed Transaction. #[derive(uniffi::Object)] +#[uniffi::export(Display)] pub struct Psbt(pub(crate) Mutex); #[uniffi::export] @@ -1532,6 +1540,12 @@ impl From for Psbt { } } +impl Display for Psbt { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{}", self.0.lock().unwrap()) + } +} + #[derive(uniffi::Record)] pub struct FinalizedPsbtResult { pub psbt: Arc,