pub struct Transaction {
pub version: i32,
pub inputs: Vec<TxIn>,
pub outputs: Vec<TxOut>,
pub witnesses: Vec<Vec<Vec<u8>>>,
pub locktime: u32,
}Expand description
A Bitcoin transaction with optional witness data.
Fields§
§version: i32Transaction version (typically 1 or 2).
inputs: Vec<TxIn>Transaction inputs.
outputs: Vec<TxOut>Transaction outputs.
witnesses: Vec<Vec<Vec<u8>>>Per-input witness stacks (empty for legacy transactions).
locktime: u32Lock time.
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn has_witness(&self) -> bool
pub fn has_witness(&self) -> bool
Returns true if any input has witness data.
Sourcepub fn serialize_legacy(&self) -> Vec<u8> ⓘ
pub fn serialize_legacy(&self) -> Vec<u8> ⓘ
Serialize without witness data (used for txid computation).
Sourcepub fn serialize_witness(&self) -> Vec<u8> ⓘ
pub fn serialize_witness(&self) -> Vec<u8> ⓘ
Serialize with witness data (BIP-144 format).
If no witnesses exist, falls back to legacy serialization.
Sourcepub fn txid(&self) -> [u8; 32]
pub fn txid(&self) -> [u8; 32]
Compute the transaction ID (double-SHA256 of legacy serialization, reversed).
The txid is displayed in reversed byte order by convention.
Trait Implementations§
Source§impl Clone for Transaction
impl Clone for Transaction
Source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Transaction
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnsafeUnpin for Transaction
impl UnwindSafe for Transaction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more