Struct bitcoin_blockchain::locks::LockTime
source · pub struct LockTime(_);
Expand description
Value for a transaction nTimeLock
field, which can be either a timestamp
(>=500000000) or a block height (<500000000). See alse LockTimestamp
and
LockHeight
types.
Implementations§
source§impl LockTime
impl LockTime
sourcepub fn from_height(height: u32) -> Option<Self>
pub fn from_height(height: u32) -> Option<Self>
Creates absolute time lock with the given block height.
Block height must be strictly less than 0x1DCD6500
, otherwise
None
is returned.
sourcepub fn from_unix_timestamp(timestamp: u32) -> Option<Self>
pub fn from_unix_timestamp(timestamp: u32) -> Option<Self>
Creates absolute time lock with the given UNIX timestamp value.
Timestamp value must be greater or equal to 0x1DCD6500
, otherwise
None
is returned.
sourcepub fn from_consensus(value: u32) -> Self
pub fn from_consensus(value: u32) -> Self
Constructs timelock from a bitcoin consensus 32-bit timelock value.
sourcepub fn is_height_based(self) -> bool
pub fn is_height_based(self) -> bool
Checks if the absolute timelock provided by the nLockTime
value
specifies height-based lock
sourcepub fn is_time_based(self) -> bool
pub fn is_time_based(self) -> bool
Checks if the absolute timelock provided by the nLockTime
value
specifies time-based lock
sourcepub fn into_consensus(self) -> u32
pub fn into_consensus(self) -> u32
Converts into full u32 representation of nSeq
value as it is
serialized in bitcoin transaction.
Trait Implementations§
source§impl From<LockHeight> for LockTime
impl From<LockHeight> for LockTime
source§fn from(v: LockHeight) -> Self
fn from(v: LockHeight) -> Self
source§impl From<LockTimestamp> for LockTime
impl From<LockTimestamp> for LockTime
source§fn from(v: LockTimestamp) -> Self
fn from(v: LockTimestamp) -> Self
source§impl PartialEq<LockTime> for LockTime
impl PartialEq<LockTime> for LockTime
source§impl PartialOrd<LockTime> for LockTime
impl PartialOrd<LockTime> for LockTime
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 moresource§impl StrictDecode for LockTime
impl StrictDecode for LockTime
source§fn strict_decode<D: Read>(d: D) -> Result<Self, Error>
fn strict_decode<D: Read>(d: D) -> Result<Self, Error>
std::io::Read
instance; must either
construct an instance or return implementation-specific error type.source§fn strict_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
fn strict_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
StrictDecode::strict_decode
. If there are some data remains in the
buffer once deserialization is completed, fails with
Error::DataNotEntirelyConsumed
. Use io::Cursor
over the buffer and
StrictDecode::strict_decode
to avoid such failures.source§fn strict_file_load(path: impl AsRef<Path>) -> Result<Self, Error>
fn strict_file_load(path: impl AsRef<Path>) -> Result<Self, Error>
path
and reconstructs object from it. Fails
with Error::DataNotEntirelyConsumed
if file contains remaining
data after the object reconstruction.source§impl StrictEncode for LockTime
impl StrictEncode for LockTime
source§fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>
fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>
std::io::Write
instance; must return result
with either amount of bytes encoded – or implementation-specific
error type.source§fn strict_serialize(&self) -> Result<Vec<u8, Global>, Error>
fn strict_serialize(&self) -> Result<Vec<u8, Global>, Error>
StrictEncode::strict_encode
function