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§

source§

impl TxIn

source

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].

BIP-65

source

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.

source

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
source

pub fn base_size(&self) -> usize

Returns the base size of this input.

Base size excludes the witness data (see Self::total_size).

source

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§

source§

impl Clone for TxIn

source§

fn clone(&self) -> TxIn

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TxIn

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Decodable for TxIn

source§

fn consensus_decode_from_finite_reader<R: Read + ?Sized>( r: &mut R ) -> Result<Self, Error>

Decode Self from a size-limited reader. Read more
source§

fn consensus_decode<R: Read + ?Sized>(reader: &mut R) -> Result<Self, Error>

Decode an object with a well-defined format. Read more
source§

impl Default for TxIn

source§

fn default() -> TxIn

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for TxIn

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Encodable for TxIn

source§

fn consensus_encode<W: Write + ?Sized>(&self, w: &mut W) -> Result<usize, Error>

Encodes an object with a well-defined format. Read more
source§

impl Hash for TxIn

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for TxIn

source§

fn cmp(&self, other: &TxIn) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for TxIn

source§

fn eq(&self, other: &TxIn) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for TxIn

source§

fn partial_cmp(&self, other: &TxIn) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for TxIn

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for TxIn

source§

impl StructuralEq for TxIn

source§

impl StructuralPartialEq for TxIn

Auto Trait Implementations§

§

impl RefUnwindSafe for TxIn

§

impl Send for TxIn

§

impl Sync for TxIn

§

impl Unpin for TxIn

§

impl UnwindSafe for TxIn

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,