pub struct Xpub {
pub network: NetworkKind,
pub depth: u8,
pub parent_fingerprint: Fingerprint,
pub child_number: ChildNumber,
pub public_key: PublicKey,
pub chain_code: ChainCode,
}Expand description
Extended public key
Fields§
§network: NetworkKindThe network kind this key is to be used on
depth: u8How many derivations this key is from the master (which is 0)
parent_fingerprint: FingerprintFingerprint of the parent key
child_number: ChildNumberChild number of the key used to derive from parent (0 for master)
public_key: PublicKeyPublic key
chain_code: ChainCodeChain code
Implementations§
Source§impl Xpub
impl Xpub
Sourcepub fn from_priv(sk: &Xpriv) -> Self
👎Deprecating in a future version: use from_xpriv() instead
pub fn from_priv(sk: &Xpriv) -> Self
use from_xpriv() instead
Constructs a new extended public key from an extended private key.
Sourcepub fn from_xpriv(xpriv: &Xpriv) -> Self
pub fn from_xpriv(xpriv: &Xpriv) -> Self
Constructs a new extended public key from an extended private key.
Sourcepub fn to_pub(self) -> FullPublicKey
👎Deprecating in a future version: use to_public_key() instead
pub fn to_pub(self) -> FullPublicKey
use to_public_key() instead
Constructs a new ECDSA compressed public key matching internal public key representation.
Sourcepub fn to_public_key(self) -> FullPublicKey
pub fn to_public_key(self) -> FullPublicKey
Constructs a new ECDSA compressed public key matching internal public key representation.
Sourcepub fn to_x_only_pub(self) -> XOnlyPublicKey
👎Deprecating in a future version: use to_x_only_public_key() instead
pub fn to_x_only_pub(self) -> XOnlyPublicKey
use to_x_only_public_key() instead
Constructs a new BIP-0340 x-only public key for BIP-0340 signatures and Taproot use matching the internal public key representation.
Sourcepub fn to_x_only_public_key(self) -> XOnlyPublicKey
pub fn to_x_only_public_key(self) -> XOnlyPublicKey
Constructs a new BIP-0340 x-only public key for BIP-0340 signatures and Taproot use matching the internal public key representation.
Sourcepub fn derive_pub<P: AsRef<[ChildNumber]>>(
&self,
path: P,
) -> Result<Self, DerivationError>
👎Deprecating in a future version: use derive_xpub() instead
pub fn derive_pub<P: AsRef<[ChildNumber]>>( &self, path: P, ) -> Result<Self, DerivationError>
use derive_xpub() instead
Attempts to derive an extended public key from a path.
The path argument can be any type implementing AsRef<[ChildNumber]>, such as RelativeDerivationPath, for instance.
§Errors
See derive_xpub.
Sourcepub fn derive_xpub<P: AsRef<[ChildNumber]>>(
&self,
path: P,
) -> Result<Self, DerivationError>
pub fn derive_xpub<P: AsRef<[ChildNumber]>>( &self, path: P, ) -> Result<Self, DerivationError>
Attempts to derive an extended public key from a path.
The path argument can be any type implementing AsRef<[ChildNumber]>, such as
RelativeDerivationPath, for instance.
§Errors
Returns an error if any of the ChildNumbers are hardened.
Sourcepub fn ckd_pub_tweak(
&self,
i: ChildNumber,
) -> Result<(SecretKey, ChainCode), DerivationError>
pub fn ckd_pub_tweak( &self, i: ChildNumber, ) -> Result<(SecretKey, ChainCode), DerivationError>
Computes the scalar tweak added to this key to get a child key
§Errors
Returns an error if the given ChildNumber is hardened.
Sourcepub fn ckd_pub(&self, i: ChildNumber) -> Result<Self, DerivationError>
pub fn ckd_pub(&self, i: ChildNumber) -> Result<Self, DerivationError>
Public->Public child key derivation
§Errors
Returns an error if the given ChildNumber is hardened, or if next key exceeds
the maximum derivation depth.
Sourcepub fn decode(data: &[u8]) -> Result<Self, ParseError>
pub fn decode(data: &[u8]) -> Result<Self, ParseError>
Decoding extended public key from binary data according to BIP-0032
§Errors
ParseError::UnknownVersionif the decoded network value is not main or testnet.ParseError::Secp256k1if the public key bytes are not a valid secp public key.ParseError::WrongExtendedKeyLengthif the data is not the correct length.ParseError::NonZeroParentFingerprintForMasterKeyif the depth is 0 and the master key fingerprint is non-zero.ParseError::NonZeroChildNumberForMasterKeyif the depth is 0 and the child number is non-zero.
Sourcepub fn identifier(&self) -> XKeyIdentifier
pub fn identifier(&self) -> XKeyIdentifier
Returns the HASH160 of the public key component of the xpub
Sourcepub fn fingerprint(&self) -> Fingerprint
pub fn fingerprint(&self) -> Fingerprint
Returns the first four bytes of the identifier
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for Xpub
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for Xpub
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 more