Improve lock time docs
Bitcoin lock times are easy to get confused, add absolute/relative in various places to help clarify things.
This commit is contained in:
parent
9f7d934f5d
commit
cbfa8cff4c
|
@ -141,7 +141,8 @@ impl fmt::UpperHex for PackedLockTime {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A lock time value, representing either a block height or a UNIX timestamp (seconds since epoch).
|
/// An absolute lock time value, representing either a block height or a UNIX timestamp (seconds
|
||||||
|
/// since epoch).
|
||||||
///
|
///
|
||||||
/// Used for transaction lock time (`nLockTime` in Bitcoin Core and [`crate::Transaction::lock_time`]
|
/// Used for transaction lock time (`nLockTime` in Bitcoin Core and [`crate::Transaction::lock_time`]
|
||||||
/// in this library) and also for the argument to opcode 'OP_CHECKLOCKTIMEVERIFY`.
|
/// in this library) and also for the argument to opcode 'OP_CHECKLOCKTIMEVERIFY`.
|
||||||
|
@ -156,7 +157,7 @@ impl fmt::UpperHex for PackedLockTime {
|
||||||
/// # use bitcoin::absolute::{LockTime, LockTime::*};
|
/// # use bitcoin::absolute::{LockTime, LockTime::*};
|
||||||
/// # let n = LockTime::from_consensus(100); // n OP_CHECKLOCKTIMEVERIFY
|
/// # let n = LockTime::from_consensus(100); // n OP_CHECKLOCKTIMEVERIFY
|
||||||
/// # let lock_time = LockTime::from_consensus(100); // nLockTime
|
/// # let lock_time = LockTime::from_consensus(100); // nLockTime
|
||||||
/// // To compare lock times there are various `is_satisfied_*` methods, you may also use:
|
/// // To compare absolute lock times there are various `is_satisfied_*` methods, you may also use:
|
||||||
/// let is_satisfied = match (n, lock_time) {
|
/// let is_satisfied = match (n, lock_time) {
|
||||||
/// (Blocks(n), Blocks(lock_time)) => n <= lock_time,
|
/// (Blocks(n), Blocks(lock_time)) => n <= lock_time,
|
||||||
/// (Seconds(n), Seconds(lock_time)) => n <= lock_time,
|
/// (Seconds(n), Seconds(lock_time)) => n <= lock_time,
|
||||||
|
|
|
@ -262,17 +262,17 @@ pub enum RelativeLockTimeError {
|
||||||
impl Sequence {
|
impl Sequence {
|
||||||
/// The maximum allowable sequence number.
|
/// The maximum allowable sequence number.
|
||||||
///
|
///
|
||||||
/// This sequence number disables lock-time and replace-by-fee.
|
/// This sequence number disables absolute lock time and replace-by-fee.
|
||||||
pub const MAX: Self = Sequence(0xFFFFFFFF);
|
pub const MAX: Self = Sequence(0xFFFFFFFF);
|
||||||
/// Zero value sequence.
|
/// Zero value sequence.
|
||||||
///
|
///
|
||||||
/// This sequence number enables replace-by-fee and lock-time.
|
/// This sequence number enables replace-by-fee and absolute lock time.
|
||||||
pub const ZERO: Self = Sequence(0);
|
pub const ZERO: Self = Sequence(0);
|
||||||
/// The sequence number that enables absolute lock-time but disables replace-by-fee
|
/// The sequence number that enables absolute lock time but disables replace-by-fee
|
||||||
/// and relative lock-time.
|
/// and relative lock time.
|
||||||
pub const ENABLE_LOCKTIME_NO_RBF: Self = Sequence::MIN_NO_RBF;
|
pub const ENABLE_LOCKTIME_NO_RBF: Self = Sequence::MIN_NO_RBF;
|
||||||
/// The sequence number that enables replace-by-fee and absolute lock-time but
|
/// The sequence number that enables replace-by-fee and absolute lock time but
|
||||||
/// disables relative lock-time.
|
/// disables relative lock time.
|
||||||
pub const ENABLE_RBF_NO_LOCKTIME: Self = Sequence(0xFFFFFFFD);
|
pub const ENABLE_RBF_NO_LOCKTIME: Self = Sequence(0xFFFFFFFD);
|
||||||
|
|
||||||
/// The lowest sequence number that does not opt-in for replace-by-fee.
|
/// The lowest sequence number that does not opt-in for replace-by-fee.
|
||||||
|
@ -283,9 +283,9 @@ impl Sequence {
|
||||||
///
|
///
|
||||||
/// [BIP-125]: <https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki]>
|
/// [BIP-125]: <https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki]>
|
||||||
const MIN_NO_RBF: Self = Sequence(0xFFFFFFFE);
|
const MIN_NO_RBF: Self = Sequence(0xFFFFFFFE);
|
||||||
/// BIP-68 relative lock-time disable flag mask
|
/// BIP-68 relative lock time disable flag mask.
|
||||||
const LOCK_TIME_DISABLE_FLAG_MASK: u32 = 0x80000000;
|
const LOCK_TIME_DISABLE_FLAG_MASK: u32 = 0x80000000;
|
||||||
/// BIP-68 relative lock-time type flag mask
|
/// BIP-68 relative lock time type flag mask.
|
||||||
const LOCK_TYPE_MASK: u32 = 0x00400000;
|
const LOCK_TYPE_MASK: u32 = 0x00400000;
|
||||||
|
|
||||||
/// Retuns `true` if the sequence number indicates that the transaction is finalised.
|
/// Retuns `true` if the sequence number indicates that the transaction is finalised.
|
||||||
|
|
Loading…
Reference in New Issue