Struct bdk_chain::bitcoin::blockdata::transaction::TxIn
pub struct TxIn {
pub previous_output: OutPoint,
pub script_sig: ScriptBuf,
pub sequence: Sequence,
pub witness: Witness,
}
Expand description
Bitcoin transaction input.
It contains the location of the previous transaction’s output, that it spends and set of scripts that satisfy its spending conditions.
§Bitcoin Core References
Fields§
§previous_output: OutPoint
The reference to the previous output that is being used as an input.
script_sig: ScriptBuf
The script which pushes values on the stack which will cause the referenced output’s script to be accepted.
sequence: Sequence
The sequence number, which suggests to miners which of two conflicting transactions should be preferred, or 0xFFFFFFFF to ignore this feature. This is generally never used since the miner behavior cannot be enforced.
witness: Witness
Witness data: an array of byte-arrays. Note that this field is not (de)serialized with the rest of the TxIn in Encodable/Decodable, as it is (de)serialized at the end of the full Transaction. It is (de)serialized with the rest of the TxIn in other (de)serialization routines.
Implementations§
§impl TxIn
impl TxIn
pub fn enables_lock_time(&self) -> bool
pub fn enables_lock_time(&self) -> bool
Returns true if this input enables the absolute::LockTime
(aka nLockTime
) of its
Transaction
.
nLockTime
is enabled if any input enables it. See Transaction::is_lock_time_enabled
to check the overall state. If none of the inputs enables it, the lock time value is simply
ignored. If this returns false and OP_CHECKLOCKTIMEVERIFY is used in the redeem script with
this input then the script execution will fail [BIP-0065].
pub fn legacy_weight(&self) -> Weight
pub fn legacy_weight(&self) -> Weight
The weight of the TxIn when it’s included in a legacy transaction (i.e., a transaction having only legacy inputs).
The witness weight is ignored here even when the witness is non-empty.
If you want the witness to be taken into account, use TxIn::segwit_weight
instead.
Keep in mind that when adding a TxIn to a transaction, the total weight of the transaction
might increase more than TxIn::legacy_weight
. This happens when the new input added causes
the input length VarInt
to increase its encoding length.
pub fn segwit_weight(&self) -> Weight
pub fn segwit_weight(&self) -> Weight
The weight of the TxIn when it’s included in a segwit transaction (i.e., a transaction having at least one segwit input).
This always takes into account the witness, even when empty, in which
case 1WU for the witness length varint (00
) is included.
Keep in mind that when adding a TxIn to a transaction, the total weight of the transaction
might increase more than TxIn::segwit_weight
. This happens when:
- the new input added causes the input length
VarInt
to increase its encoding length - the new input is the first segwit input added - this will add an additional 2WU to the transaction weight to take into account the segwit marker
pub fn base_size(&self) -> usize
pub fn base_size(&self) -> usize
Returns the base size of this input.
Base size excludes the witness data (see Self::total_size
).
pub fn total_size(&self) -> usize
pub fn total_size(&self) -> usize
Returns the total number of bytes that this input contributes to a transaction.
Total size includes the witness data (for base size see Self::base_size
).
Trait Implementations§
§impl<'de> Deserialize<'de> for TxIn
impl<'de> Deserialize<'de> for TxIn
§fn deserialize<__D>(
__deserializer: __D
) -> Result<TxIn, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<TxIn, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Ord for TxIn
impl Ord for TxIn
§impl PartialOrd for TxIn
impl PartialOrd for TxIn
§fn partial_cmp(&self, other: &TxIn) -> Option<Ordering>
fn partial_cmp(&self, other: &TxIn) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more