pub struct Sequence(pub u32);
Expand description

Bitcoin transaction input sequence number.

The sequence field is used for:

  • Indicating whether absolute lock-time (specified in lock_time field of Transaction) is enabled.
  • Indicating and encoding BIP-68 relative lock-times.
  • Indicating whether a transcation opts-in to BIP-125 replace-by-fee.

Note that transactions spending an output with OP_CHECKLOCKTIMEVERIFYMUST NOT use Sequence::MAX for the corresponding input. BIP-65

Tuple Fields

0: u32

Implementations

The maximum allowable sequence number.

This sequence number disables lock-time and replace-by-fee.

Zero value sequence.

This sequence number enables replace-by-fee and lock-time.

The sequence number that enables absolute lock-time but disables replace-by-fee and relative lock-time.

The sequence number that enables replace-by-fee and absolute lock-time but disables relative lock-time.

Retuns true if the sequence number indicates that the transaction is finalised.

The sequence number being equal to 0xffffffff on all txin sequences indicates that the transaction is finalised.

Returns true if the transaction opted-in to BIP125 replace-by-fee.

Replace by fee is signaled by the sequence being less than 0xfffffffe which is checked by this method.

Returns true if the sequence has a relative lock-time.

Returns true if the sequence number encodes a block based relative lock-time.

Returns true if the sequene number encodes a time interval based relative lock-time.

Create a relative lock-time using block height.

Create a relative lock-time using time intervals where each interval is equivalent to 512 seconds.

Encoding finer granularity of time for relative lock-times is not supported in Bitcoin

Create a relative lock-time from seconds, converting the seconds into 512 second interval with floor division.

Will return an error if the input cannot be encoded in 16 bits.

Create a relative lock-time from seconds, converting the seconds into 512 second interval with ceiling division.

Will return an error if the input cannot be encoded in 16 bits.

Returns true if the sequence number enables absolute lock-time (Transaction::lock_time).

Create a sequence from a u32 value.

Returns the inner 32bit integer value of Sequence.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Decode an object with a well-defined format. Read more
Decode Self from a size-limited reader. Read more

The default value of sequence is 0xffffffff.

Deserialize this value from the given Serde deserializer. Read more
Formats the value using the given formatter. Read more
Encode an object with a well-defined format. Returns the number of bytes written on success. Read more
Converts to this type from the input type.
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
Formats the value using the given formatter.
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. 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
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Serialize this value into the given Serde serializer. 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.
The type returned in the event of a conversion error.
Performs the conversion.
Formats the value using the given formatter.

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.

Calls U::from(self).

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

Outputs the hash in hexadecimal form.

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
Converts the given value to a String. 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.