Struct sapio_bitcoin::util::bip32::ExtendedPubKey
source · [−]pub struct ExtendedPubKey {
pub network: Network,
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: Network
The network this key is to be used on
depth: u8
How many derivations this key is from the master (which is 0)
parent_fingerprint: Fingerprint
Fingerprint of the parent key
child_number: ChildNumber
Child number of the key used to derive from parent (0 for master)
public_key: PublicKey
Public key
chain_code: ChainCode
Chain code
Implementations
sourceimpl ExtendedPubKey
impl ExtendedPubKey
sourcepub fn from_private<C: Signing>(
secp: &Secp256k1<C>,
sk: &ExtendedPrivKey
) -> ExtendedPubKey
👎 Deprecated since 0.28.0: use ExtendedPubKey::from_priv
pub fn from_private<C: Signing>(
secp: &Secp256k1<C>,
sk: &ExtendedPrivKey
) -> ExtendedPubKey
use ExtendedPubKey::from_priv
Derives a public key from a private key
sourcepub fn from_priv<C: Signing>(
secp: &Secp256k1<C>,
sk: &ExtendedPrivKey
) -> ExtendedPubKey
pub fn from_priv<C: Signing>(
secp: &Secp256k1<C>,
sk: &ExtendedPrivKey
) -> ExtendedPubKey
Derives a public key from a private key
sourcepub fn to_pub(&self) -> PublicKey
pub fn to_pub(&self) -> PublicKey
Constructs ECDSA compressed public key matching internal public key representation.
sourcepub fn to_x_only_pub(&self) -> XOnlyPublicKey
pub fn to_x_only_pub(&self) -> XOnlyPublicKey
Constructs BIP340 x-only public key for BIP-340 signatures and Taproot use matching the internal public key representation.
sourcepub fn derive_pub<C: Verification, P: AsRef<[ChildNumber]>>(
&self,
secp: &Secp256k1<C>,
path: &P
) -> Result<ExtendedPubKey, Error>
pub fn derive_pub<C: Verification, P: AsRef<[ChildNumber]>>(
&self,
secp: &Secp256k1<C>,
path: &P
) -> Result<ExtendedPubKey, Error>
Attempts to derive an extended public key from a path.
The path
argument can be both of type DerivationPath
or Vec<ChildNumber>
.
sourcepub fn ckd_pub_tweak(
&self,
i: ChildNumber
) -> Result<(SecretKey, ChainCode), Error>
pub fn ckd_pub_tweak(
&self,
i: ChildNumber
) -> Result<(SecretKey, ChainCode), Error>
Compute the scalar tweak added to this key to get a child key
sourcepub fn ckd_pub<C: Verification>(
&self,
secp: &Secp256k1<C>,
i: ChildNumber
) -> Result<ExtendedPubKey, Error>
pub fn ckd_pub<C: Verification>(
&self,
secp: &Secp256k1<C>,
i: ChildNumber
) -> Result<ExtendedPubKey, Error>
Public->Public child key derivation
sourcepub fn decode(data: &[u8]) -> Result<ExtendedPubKey, Error>
pub fn decode(data: &[u8]) -> Result<ExtendedPubKey, Error>
Decoding extended public key from binary data according to BIP 32
sourcepub fn identifier(&self) -> XpubIdentifier
pub fn identifier(&self) -> XpubIdentifier
Returns the HASH160 of the chaincode
sourcepub fn fingerprint(&self) -> Fingerprint
pub fn fingerprint(&self) -> Fingerprint
Returns the first four bytes of the identifier
Trait Implementations
sourceimpl Clone for ExtendedPubKey
impl Clone for ExtendedPubKey
sourcefn clone(&self) -> ExtendedPubKey
fn clone(&self) -> ExtendedPubKey
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ExtendedPubKey
impl Debug for ExtendedPubKey
sourceimpl<'de> Deserialize<'de> for ExtendedPubKey
Available on crate feature serde
only.
impl<'de> Deserialize<'de> for ExtendedPubKey
serde
only.sourcefn deserialize<D>(deserializer: D) -> Result<ExtendedPubKey, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<ExtendedPubKey, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for ExtendedPubKey
impl Display for ExtendedPubKey
sourceimpl FromStr for ExtendedPubKey
impl FromStr for ExtendedPubKey
sourceimpl Hash for ExtendedPubKey
impl Hash for ExtendedPubKey
sourceimpl Ord for ExtendedPubKey
impl Ord for ExtendedPubKey
sourceimpl PartialEq<ExtendedPubKey> for ExtendedPubKey
impl PartialEq<ExtendedPubKey> for ExtendedPubKey
sourcefn eq(&self, other: &ExtendedPubKey) -> bool
fn eq(&self, other: &ExtendedPubKey) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ExtendedPubKey) -> bool
fn ne(&self, other: &ExtendedPubKey) -> bool
This method tests for !=
.
sourceimpl PartialOrd<ExtendedPubKey> for ExtendedPubKey
impl PartialOrd<ExtendedPubKey> for ExtendedPubKey
sourcefn partial_cmp(&self, other: &ExtendedPubKey) -> Option<Ordering>
fn partial_cmp(&self, other: &ExtendedPubKey) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<'de> Serialize for ExtendedPubKey
Available on crate feature serde
only.
impl<'de> Serialize for ExtendedPubKey
serde
only.impl Copy for ExtendedPubKey
impl Eq for ExtendedPubKey
impl StructuralEq for ExtendedPubKey
impl StructuralPartialEq for ExtendedPubKey
Auto Trait Implementations
impl RefUnwindSafe for ExtendedPubKey
impl Send for ExtendedPubKey
impl Sync for ExtendedPubKey
impl Unpin for ExtendedPubKey
impl UnwindSafe for ExtendedPubKey
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more