pub struct LockTime(/* private fields */);
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 PartialOrd for LockTime
impl PartialOrd for LockTime
Source§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>, Error>
fn strict_serialize(&self) -> Result<Vec<u8>, Error>
StrictEncode::strict_encode
function