pub struct Transaction {
    pub version: u32,
    pub lock_time: u32,
    pub input: Vec<TxIn>,
    pub output: Vec<TxOut>,
}
Expand description

A Bitcoin transaction, which describes an authenticated movement of coins

Fields

version: u32

The protocol version, should always be 1.

lock_time: u32

Block number before which this transaction is valid, or 0 for valid immediately.

input: Vec<TxIn>

List of inputs

output: Vec<TxOut>

List of outputs

Implementations

Computes a “normalized TXID” which does not include any signatures. This gives a way to identify a transaction that is ``the same’’ as another in the sense of having same inputs and outputs.

Computes the txid. For non-segwit transactions this will be identical to the output of BitcoinHash::bitcoin_hash(), but for segwit transactions, this will give the correct txid (not including witnesses) while bitcoin_hash will also hash witnesses.

Computes a signature hash for a given input index with a given sighash flag. To actually produce a scriptSig, this hash needs to be run through an ECDSA signer, the SigHashType appended to the resulting sig, and a script written around this, but this is the general (and hard) part.

Warning This does NOT attempt to support OP_CODESEPARATOR. In general this would require evaluating script_pubkey to determine which separators get evaluated and which don’t, which we don’t have the information to determine.

Panics

Panics if input_index is greater than or equal to self.input.len()

Gets the “weight” of this transaction, as defined by BIP141. For transactions with an empty witness, this is simply the consensus-serialized size times 4. For transactions with a witness, this is the non-witness consensus-serialized size multiplied by 3 plus the with-witness consensus-serialized size.

Is this a coin base transaction?

Trait Implementations

Produces a Sha256dHash which can be used to refer to the object
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Decode an object with a well-defined format
Encode an object with a well-defined format
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more