Skip to content

Commit

Permalink
Add weight, size, and vsize methods on the Transaction type
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderbiscuit committed Mar 8, 2023
1 parent c1243f9 commit 150c26e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bdk-ffi/src/bdk.udl
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,16 @@ interface FeeRate {
};

interface Transaction {
[Throws=BdkError]
constructor(sequence<u8> transaction_bytes);
[Throws=BdkError]
constructor(sequence<u8> transaction_bytes);

sequence<u8> serialize();

u64 weight();

u64 size();

sequence<u8> serialize();
u64 vsize();
};

interface PartiallySignedTransaction {
Expand Down
12 changes: 12 additions & 0 deletions bdk-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,18 @@ impl Transaction {
fn serialize(&self) -> Vec<u8> {
self.internal.serialize()
}

fn weight(&self) -> u64 {
self.internal.weight() as u64
}

fn size(&self) -> u64 {
self.internal.size() as u64
}

fn vsize(&self) -> u64 {
self.internal.vsize() as u64
}
}

/// A Bitcoin address.
Expand Down

0 comments on commit 150c26e

Please sign in to comment.