Skip to content

Commit d255630

Browse files
committed
refactor: use macros for block::Header
1 parent 1e84562 commit d255630

File tree

3 files changed

+11
-23
lines changed

3 files changed

+11
-23
lines changed

bdk-ffi/src/bdk.udl

+1-22
Original file line numberDiff line numberDiff line change
@@ -605,28 +605,7 @@ enum WordCount {
605605

606606
typedef interface Address;
607607

608-
/// Bitcoin block header.
609-
/// Contains all the block’s information except the actual transactions, but including a root of a merkle tree
610-
/// committing to all transactions in the block.
611-
dictionary Header {
612-
/// Block version, now repurposed for soft fork signalling.
613-
i32 version;
614-
615-
/// Reference to the previous block in the chain.
616-
string prev_blockhash;
617-
618-
/// The root hash of the merkle tree of transactions in the block.
619-
string merkle_root;
620-
621-
/// The timestamp of the block, as claimed by the miner.
622-
u32 time;
623-
624-
/// The target value below which the blockhash must lie.
625-
u32 bits;
626-
627-
/// The nonce, selected to obtain a low enough blockhash.
628-
u32 nonce;
629-
};
608+
typedef dictionary Header;
630609

631610
typedef interface Transaction;
632611

bdk-ffi/src/bitcoin.rs

+10
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,22 @@ impl Script {
150150
impl_from_core_type!(BdkScriptBuf, Script);
151151
impl_into_core_type!(Script, BdkScriptBuf);
152152

153+
/// Bitcoin block header.
154+
/// Contains all the block’s information except the actual transactions, but including a root of a merkle tree
155+
/// committing to all transactions in the block.
156+
#[derive(uniffi::Record)]
153157
pub struct Header {
158+
/// Block version, now repurposed for soft fork signalling.
154159
pub version: i32,
160+
/// Reference to the previous block in the chain.
155161
pub prev_blockhash: String,
162+
/// The root hash of the merkle tree of transactions in the block.
156163
pub merkle_root: String,
164+
/// The timestamp of the block, as claimed by the miner.
157165
pub time: u32,
166+
/// The target value below which the blockhash must lie.
158167
pub bits: u32,
168+
/// The nonce, selected to obtain a low enough blockhash.
159169
pub nonce: u32,
160170
}
161171

bdk-ffi/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ mod wallet;
1414
use crate::bitcoin::Address;
1515
use crate::bitcoin::Amount;
1616
use crate::bitcoin::FeeRate;
17-
use crate::bitcoin::Header;
1817
use crate::bitcoin::OutPoint;
1918
use crate::bitcoin::Script;
2019
use crate::bitcoin::Transaction;

0 commit comments

Comments
 (0)