Struct bdk_chain::bitcoin::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

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

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

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

Returns the base size of this input.

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

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 Clone for TxIn

§

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
§

impl Debug for TxIn

§

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

Formats the value using the given formatter. Read more
§

impl Decodable for TxIn

§

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

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

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

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

impl Default for TxIn

§

fn default() -> TxIn

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

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

§

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

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

impl Encodable for TxIn

§

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

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

impl Hash for TxIn

§

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

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
§

impl Ord for TxIn

§

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) -> Self
where Self: Sized,

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

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

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

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

Restrict a value to a certain interval. Read more
§

impl PartialEq for TxIn

§

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

impl PartialOrd for TxIn

§

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
§

impl Serialize for TxIn

§

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

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

impl Eq for TxIn

§

impl StructuralPartialEq for TxIn

Auto Trait Implementations§

§

impl Freeze for TxIn

§

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 T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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 T
where 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 T
where 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 T
where 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 T
where 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 T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

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