Struct Hrp
pub struct Hrp { /* private fields */ }
Expand description
The human-readable part (human readable prefix before the ‘1’ separator).
Implementations§
§impl Hrp
impl Hrp
pub fn parse(hrp: &str) -> Result<Hrp, Error>
pub fn parse(hrp: &str) -> Result<Hrp, Error>
Parses the human-readable part checking it is valid as defined by BIP-173.
This does not check that the hrp
is an in-use HRP within Bitcoin (eg, “bc”), rather it
checks that the HRP string is valid as per the specification in BIP-173:
The human-readable part, which is intended to convey the type of data, or anything else that is relevant to the reader. This part MUST contain 1 to 83 US-ASCII characters, with each character having a value in the range [33-126]. HRP validity may be further restricted by specific applications.
pub const fn parse_unchecked(hrp: &str) -> Hrp
pub const fn parse_unchecked(hrp: &str) -> Hrp
Parses the human-readable part (see Hrp::parse
for full docs).
Does not check that hrp
is valid according to BIP-173 but does check for valid ASCII
values, replacing any invalid characters with X
.
pub fn to_lowercase(&self) -> String
pub fn to_lowercase(&self) -> String
Returns this human-readable part as a lowercase string.
pub fn byte_iter(&self) -> ByteIter<'_> ⓘ
pub fn byte_iter(&self) -> ByteIter<'_> ⓘ
Creates a byte iterator over the ASCII byte values (ASCII characters) of this HRP.
If an uppercase HRP was parsed during object construction then this iterator will yield
uppercase ASCII char
s. For lowercase bytes see Self::lowercase_byte_iter
pub fn char_iter(&self) -> CharIter<'_> ⓘ
pub fn char_iter(&self) -> CharIter<'_> ⓘ
Creates a character iterator over the ASCII characters of this HRP.
If an uppercase HRP was parsed during object construction then this iterator will yield
uppercase ASCII char
s. For lowercase bytes see Self::lowercase_char_iter
.
pub fn lowercase_byte_iter(&self) -> LowercaseByteIter<'_> ⓘ
pub fn lowercase_byte_iter(&self) -> LowercaseByteIter<'_> ⓘ
Creates a lowercase iterator over the byte values (ASCII characters) of this HRP.
pub fn lowercase_char_iter(&self) -> LowercaseCharIter<'_> ⓘ
pub fn lowercase_char_iter(&self) -> LowercaseCharIter<'_> ⓘ
Creates a lowercase character iterator over the ASCII characters of this HRP.
pub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length (number of characters) of the human-readable part.
Guaranteed to be between 1 and 83 inclusive.
pub fn is_valid_segwit(&self) -> bool
pub fn is_valid_segwit(&self) -> bool
Returns true
if this HRP is valid according to the bips.
BIP-173 states that the HRP must be either “bc” or “tb”.
pub fn is_valid_on_mainnet(&self) -> bool
pub fn is_valid_on_mainnet(&self) -> bool
Returns true
if this HRP is valid on the Bitcoin network i.e., HRP is “bc”.
pub fn is_valid_on_testnet(&self) -> bool
pub fn is_valid_on_testnet(&self) -> bool
Returns true
if this HRP is valid on the Bitcoin testnet network i.e., HRP is “tb”.
pub fn is_valid_on_signet(&self) -> bool
pub fn is_valid_on_signet(&self) -> bool
Returns true
if this HRP is valid on the Bitcoin signet network i.e., HRP is “tb”.
pub fn is_valid_on_regtest(&self) -> bool
pub fn is_valid_on_regtest(&self) -> bool
Returns true
if this HRP is valid on the Bitcoin regtest network i.e., HRP is “bcrt”.
Trait Implementations§
§impl Display for Hrp
Displays the human-readable part.
impl Display for Hrp
Displays the human-readable part.
If an uppercase HRP was parsed during object construction then the returned string will be
in uppercase also. For a lowercase string see Self::to_lowercase
.
§impl Ord for Hrp
Case insensitive comparison.
impl Ord for Hrp
Case insensitive comparison.
§impl PartialOrd for Hrp
Case insensitive comparison.
impl PartialOrd for Hrp
Case insensitive comparison.