#[non_exhaustive]pub struct Prefix { /* private fields */ }
Expand description
BIP32 extended key prefixes a.k.a. “versions” (e.g. xpub
, xprv
)
The BIP32 spec describes these as “versions” and gives examples for
xprv
/xpub
(mainnet) and tprv
/tpub
(testnet), however in practice
there are many more used (e.g. ypub
, zpub
).
Implementations§
source§impl Prefix
impl Prefix
sourcepub const fn from_parts_unchecked(s: &str, version: Version) -> Self
pub const fn from_parts_unchecked(s: &str, version: Version) -> Self
Create a new prefix from the given 4-character string and version number.
The main intended use case for this function is Prefix
constants
such as Prefix::XPRV
.
Warning
Use this function with care: No consistency check is performed! It is up to the caller to ensure that the version number matches the prefix.
Panics
Panics if s
is not 4 chars long, or any of the chars lie outside of
the supported range: lower case (a..=z
) or upper case (A..=Z
)
letters.
sourcepub fn from_bytes(bytes: [u8; 4]) -> Result<Self>
pub fn from_bytes(bytes: [u8; 4]) -> Result<Self>
Create a new prefix from the given encoded bytes.
These bytes represent the big endian serialization of a Version
integer.
sourcepub fn is_private(self) -> bool
pub fn is_private(self) -> bool
Is this a private key?
Trait Implementations§
source§impl Ord for Prefix
impl Ord for Prefix
source§impl PartialEq<Prefix> for Prefix
impl PartialEq<Prefix> for Prefix
source§impl PartialOrd<Prefix> for Prefix
impl PartialOrd<Prefix> for Prefix
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 more