pub struct Height(/* private fields */);Expand description
An absolute block height, guaranteed to always contain a valid height value.
Implementations§
Source§impl Height
impl Height
Sourcepub fn from_hex(s: &str) -> Result<Self, ParseHeightError>
pub fn from_hex(s: &str) -> Result<Self, ParseHeightError>
Sourcepub const fn from_u32(n: u32) -> Result<Self, ConversionError>
pub const fn from_u32(n: u32) -> Result<Self, ConversionError>
Constructs a new block height directly from a u32 value.
§Errors
If n does not represent a block height within the valid range for a locktime:
[0, 499_999_999].
§Examples
use bitcoin_units::locktime::absolute;
let h: u32 = 741521;
let height = absolute::Height::from_u32(h)?;
assert_eq!(height.to_u32(), h);Sourcepub fn is_satisfied_by(self, height: Self) -> bool
pub fn is_satisfied_by(self, height: Self) -> bool
Returns true if a transaction with this locktime can be included in the next block.
self is value of the LockTime and if height is the current chain tip then
a transaction with this lock can be broadcast for inclusion in the next block.
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for Height
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for Height
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl From<Height> for BlockHeight
impl From<Height> for BlockHeight
Source§fn from(h: Height) -> Self
fn from(h: Height) -> Self
Converts a locktime::absolute::Height to a BlockHeight.
An absolute locktime block height has a maximum value of absolute::LOCK_TIME_THRESHOLD
minus one, while BlockHeight may take the full range of u32.
Source§impl Ord for Height
impl Ord for Height
Source§impl PartialOrd for Height
impl PartialOrd for Height
Source§impl TryFrom<BlockHeight> for Height
impl TryFrom<BlockHeight> for Height
Source§fn try_from(h: BlockHeight) -> Result<Self, Self::Error>
fn try_from(h: BlockHeight) -> Result<Self, Self::Error>
Converts a BlockHeight to a locktime::absolute::Height.
An absolute locktime block height has a maximum value of absolute::LOCK_TIME_THRESHOLD
minus one, while BlockHeight may take the full range of u32.