Skip to content

Commit e4dd37f

Browse files
rustaceanrobthunderbiscuit
authored andcommitted
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.
1 parent 9ddddef commit e4dd37f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

bdk-ffi/src/bitcoin.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ impl_into_core_type!(Amount, BdkAmount);
174174

175175
/// A bitcoin script: https://en.bitcoin.it/wiki/Script
176176
#[derive(Clone, Debug, uniffi::Object)]
177+
#[uniffi::export(Display)]
177178
pub struct Script(pub BdkScriptBuf);
178179

179180
#[uniffi::export]
@@ -194,6 +195,12 @@ impl Script {
194195
impl_from_core_type!(BdkScriptBuf, Script);
195196
impl_into_core_type!(Script, BdkScriptBuf);
196197

198+
impl Display for Script {
199+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
200+
self.0.fmt_asm(f)
201+
}
202+
}
203+
197204
/// Bitcoin block header.
198205
/// Contains all the block’s information except the actual transactions, but including a root of a merkle tree
199206
/// committing to all transactions in the block.

0 commit comments

Comments
 (0)