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 ofTransaction
) is enabled. - Indicating and encoding BIP-68 relative lock-times.
- Indicating whether a transaction opts-in to BIP-125 replace-by-fee.
Note that transactions spending an output with OP_CHECKLOCKTIMEVERIFY
MUST NOT use
Sequence::MAX
for the corresponding input. BIP-65
Tuple Fields§
§0: u32
Implementations§
§impl Sequence
impl Sequence
pub const MAX: Sequence = _
pub const MAX: Sequence = _
The maximum allowable sequence number.
This sequence number disables absolute lock time and replace-by-fee.
pub const ZERO: Sequence = _
pub const ZERO: Sequence = _
Zero value sequence.
This sequence number enables replace-by-fee and absolute lock time.
pub const ENABLE_LOCKTIME_NO_RBF: Sequence = Sequence::MIN_NO_RBF
pub const ENABLE_LOCKTIME_NO_RBF: Sequence = Sequence::MIN_NO_RBF
The sequence number that enables absolute lock time but disables replace-by-fee and relative lock time.
pub const ENABLE_RBF_NO_LOCKTIME: Sequence = _
pub const ENABLE_RBF_NO_LOCKTIME: Sequence = _
The sequence number that enables replace-by-fee and absolute lock time but disables relative lock time.
pub fn enables_absolute_lock_time(&self) -> bool
pub fn enables_absolute_lock_time(&self) -> bool
Returns true
if the sequence number enables absolute lock-time (Transaction::lock_time
).
pub fn is_final(&self) -> bool
pub fn is_final(&self) -> bool
Returns true
if the sequence number indicates that the transaction is finalized.
Instead of this method please consider using !enables_absolute_lock_time
because it
is equivalent and improves readability for those not steeped in Bitcoin folklore.
§Historical note
The term ‘final’ is an archaic Bitcoin term, it may have come about because the sequence
number in the original Bitcoin code was intended to be incremented in order to replace a
transaction, so once the sequence number got to u64::MAX
it could no longer be increased,
hence it was ‘final’.
Some other references to the term:
CTxIn::SEQUENCE_FINAL
in the Bitcoin Core code.- BIP-112: “BIP 68 prevents a non-final transaction from being selected for inclusion in a block until the corresponding input has reached the specified age”
pub fn is_rbf(&self) -> bool
pub fn is_rbf(&self) -> bool
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. Note, this is the highest “non-final” value (see Sequence::is_final
).
pub fn is_relative_lock_time(&self) -> bool
pub fn is_relative_lock_time(&self) -> bool
Returns true
if the sequence has a relative lock-time.
pub fn is_height_locked(&self) -> bool
pub fn is_height_locked(&self) -> bool
Returns true
if the sequence number encodes a block based relative lock-time.
pub fn is_time_locked(&self) -> bool
pub fn is_time_locked(&self) -> bool
Returns true
if the sequence number encodes a time interval based relative lock-time.
pub fn from_hex(s: &str) -> Result<Sequence, PrefixedHexError>
pub fn from_hex(s: &str) -> Result<Sequence, PrefixedHexError>
Creates a Sequence
from an prefixed hex string.
pub fn from_unprefixed_hex(s: &str) -> Result<Sequence, UnprefixedHexError>
pub fn from_unprefixed_hex(s: &str) -> Result<Sequence, UnprefixedHexError>
Creates a Sequence
from an unprefixed hex string.
pub fn from_height(height: u16) -> Sequence
pub fn from_height(height: u16) -> Sequence
Creates a relative lock-time using block height.
pub fn from_512_second_intervals(intervals: u16) -> Sequence
pub fn from_512_second_intervals(intervals: u16) -> Sequence
Creates 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
pub fn from_seconds_floor(seconds: u32) -> Result<Sequence, TimeOverflowError>
pub fn from_seconds_floor(seconds: u32) -> Result<Sequence, TimeOverflowError>
Creates 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.
pub fn from_seconds_ceil(seconds: u32) -> Result<Sequence, TimeOverflowError>
pub fn from_seconds_ceil(seconds: u32) -> Result<Sequence, TimeOverflowError>
Creates 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.
pub fn from_consensus(n: u32) -> Sequence
pub fn from_consensus(n: u32) -> Sequence
Creates a sequence from a u32 value.
pub fn to_consensus_u32(self) -> u32
pub fn to_consensus_u32(self) -> u32
Returns the inner 32bit integer value of Sequence.
pub fn to_relative_lock_time(&self) -> Option<LockTime>
pub fn to_relative_lock_time(&self) -> Option<LockTime>
Creates a relative::LockTime
from this Sequence
number.
Trait Implementations§
§impl<'de> Deserialize<'de> for Sequence
impl<'de> Deserialize<'de> for Sequence
§fn deserialize<__D>(
__deserializer: __D
) -> Result<Sequence, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Sequence, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Ord for Sequence
impl Ord for Sequence
§impl PartialOrd for Sequence
impl PartialOrd for Sequence
§fn partial_cmp(&self, other: &Sequence) -> Option<Ordering>
fn partial_cmp(&self, other: &Sequence) -> 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§impl<Pk> Satisfier<Pk> for Sequencewhere
Pk: MiniscriptKey + ToPublicKey,
impl<Pk> Satisfier<Pk> for Sequencewhere
Pk: MiniscriptKey + ToPublicKey,
§fn check_older(&self, n: LockTime) -> bool
fn check_older(&self, n: LockTime) -> bool
§fn lookup_ecdsa_sig(&self, _: &Pk) -> Option<Signature>
fn lookup_ecdsa_sig(&self, _: &Pk) -> Option<Signature>
§fn lookup_tap_key_spend_sig(&self) -> Option<Signature>
fn lookup_tap_key_spend_sig(&self) -> Option<Signature>
§fn lookup_tap_leaf_script_sig(
&self,
_: &Pk,
_: &TapLeafHash
) -> Option<Signature>
fn lookup_tap_leaf_script_sig( &self, _: &Pk, _: &TapLeafHash ) -> Option<Signature>
§fn lookup_tap_control_block_map(
&self
) -> Option<&BTreeMap<ControlBlock, (ScriptBuf, LeafVersion)>>
fn lookup_tap_control_block_map( &self ) -> Option<&BTreeMap<ControlBlock, (ScriptBuf, LeafVersion)>>
§fn lookup_raw_pkh_pk(&self, _: &Hash) -> Option<PublicKey>
fn lookup_raw_pkh_pk(&self, _: &Hash) -> Option<PublicKey>
Pkh
, lookup corresponding bitcoin::PublicKey
§fn lookup_raw_pkh_x_only_pk(&self, _: &Hash) -> Option<XOnlyPublicKey>
fn lookup_raw_pkh_x_only_pk(&self, _: &Hash) -> Option<XOnlyPublicKey>
Pkh
, lookup corresponding bitcoin::secp256k1::XOnlyPublicKey
§fn lookup_raw_pkh_ecdsa_sig(&self, _: &Hash) -> Option<(PublicKey, Signature)>
fn lookup_raw_pkh_ecdsa_sig(&self, _: &Hash) -> Option<(PublicKey, Signature)>
§fn lookup_raw_pkh_tap_leaf_script_sig(
&self,
_: &(Hash, TapLeafHash)
) -> Option<(XOnlyPublicKey, Signature)>
fn lookup_raw_pkh_tap_leaf_script_sig( &self, _: &(Hash, TapLeafHash) ) -> Option<(XOnlyPublicKey, Signature)>
§fn lookup_sha256(&self, _: &<Pk as MiniscriptKey>::Sha256) -> Option<[u8; 32]>
fn lookup_sha256(&self, _: &<Pk as MiniscriptKey>::Sha256) -> Option<[u8; 32]>
§fn lookup_hash256(&self, _: &<Pk as MiniscriptKey>::Hash256) -> Option<[u8; 32]>
fn lookup_hash256(&self, _: &<Pk as MiniscriptKey>::Hash256) -> Option<[u8; 32]>
§fn lookup_ripemd160(
&self,
_: &<Pk as MiniscriptKey>::Ripemd160
) -> Option<[u8; 32]>
fn lookup_ripemd160( &self, _: &<Pk as MiniscriptKey>::Ripemd160 ) -> Option<[u8; 32]>
§fn lookup_hash160(&self, _: &<Pk as MiniscriptKey>::Hash160) -> Option<[u8; 32]>
fn lookup_hash160(&self, _: &<Pk as MiniscriptKey>::Hash160) -> Option<[u8; 32]>
§fn check_after(&self, _: LockTime) -> bool
fn check_after(&self, _: LockTime) -> bool
§impl Serialize for Sequence
impl Serialize for Sequence
§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
§impl TryFrom<Sequence> for LockTime
impl TryFrom<Sequence> for LockTime
§type Error = DisabledLockTimeError
type Error = DisabledLockTimeError
impl Copy for Sequence
impl Eq for Sequence
impl StructuralPartialEq for Sequence
Auto Trait Implementations§
impl Freeze for Sequence
impl RefUnwindSafe for Sequence
impl Send for Sequence
impl Sync for Sequence
impl Unpin for Sequence
impl UnwindSafe for Sequence
Blanket Implementations§
§impl<T, Pk> AssetProvider<Pk> for Twhere
T: Satisfier<Pk>,
Pk: MiniscriptKey + ToPublicKey,
impl<T, Pk> AssetProvider<Pk> for Twhere
T: Satisfier<Pk>,
Pk: MiniscriptKey + ToPublicKey,
§fn provider_lookup_ecdsa_sig(&self, pk: &Pk) -> bool
fn provider_lookup_ecdsa_sig(&self, pk: &Pk) -> bool
§fn provider_lookup_tap_key_spend_sig(&self, _: &Pk) -> Option<usize>
fn provider_lookup_tap_key_spend_sig(&self, _: &Pk) -> Option<usize>
§fn provider_lookup_tap_leaf_script_sig(
&self,
pk: &Pk,
leaf_hash: &TapLeafHash
) -> Option<usize>
fn provider_lookup_tap_leaf_script_sig( &self, pk: &Pk, leaf_hash: &TapLeafHash ) -> Option<usize>
§fn provider_lookup_tap_control_block_map(
&self
) -> Option<&BTreeMap<ControlBlock, (ScriptBuf, LeafVersion)>>
fn provider_lookup_tap_control_block_map( &self ) -> Option<&BTreeMap<ControlBlock, (ScriptBuf, LeafVersion)>>
§fn provider_lookup_raw_pkh_pk(&self, hash: &Hash) -> Option<PublicKey>
fn provider_lookup_raw_pkh_pk(&self, hash: &Hash) -> Option<PublicKey>
Pkh
, lookup corresponding bitcoin::PublicKey
§fn provider_lookup_raw_pkh_x_only_pk(
&self,
hash: &Hash
) -> Option<XOnlyPublicKey>
fn provider_lookup_raw_pkh_x_only_pk( &self, hash: &Hash ) -> Option<XOnlyPublicKey>
Pkh
, lookup corresponding bitcoin::secp256k1::XOnlyPublicKey