From e4dd37f467e12d89aa24d063925ced9ce7284d65 Mon Sep 17 00:00:00 2001 From: rustaceanrob Date: Fri, 18 Jul 2025 15:08:06 +0100 Subject: [PATCH] feat: export `Display` for `Script` The `rust-bitcoin` type has a nice feature where the human-readable OP-codes are printed when using the `Display` version of `ScriptBuf`. Some users might find this interesting, as this is a feature of the almighty Sparrow wallet. --- bdk-ffi/src/bitcoin.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bdk-ffi/src/bitcoin.rs b/bdk-ffi/src/bitcoin.rs index af47f686..42e64e59 100644 --- a/bdk-ffi/src/bitcoin.rs +++ b/bdk-ffi/src/bitcoin.rs @@ -174,6 +174,7 @@ impl_into_core_type!(Amount, BdkAmount); /// A bitcoin script: https://en.bitcoin.it/wiki/Script #[derive(Clone, Debug, uniffi::Object)] +#[uniffi::export(Display)] pub struct Script(pub BdkScriptBuf); #[uniffi::export] @@ -194,6 +195,12 @@ impl Script { impl_from_core_type!(BdkScriptBuf, Script); impl_into_core_type!(Script, BdkScriptBuf); +impl Display for Script { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.fmt_asm(f) + } +} + /// Bitcoin block header. /// Contains all the block’s information except the actual transactions, but including a root of a merkle tree /// committing to all transactions in the block.