Enum bdk_wallet::keys::ExtendedKey

source ·
pub enum ExtendedKey<Ctx: ScriptContext = Legacy> {
    Private((Xpriv, PhantomData<Ctx>)),
    Public((Xpub, PhantomData<Ctx>)),
}
Expand description

Enum for extended keys that can be either xprv or xpub

An instance of ExtendedKey can be constructed from an Xpriv or an Xpub by using the From trait.

Defaults to the Legacy context.

Variants§

§

Private((Xpriv, PhantomData<Ctx>))

A private extended key, aka an xprv

§

Public((Xpub, PhantomData<Ctx>))

A public extended key, aka an xpub

Implementations§

source§

impl<Ctx: ScriptContext> ExtendedKey<Ctx>

source

pub fn has_secret(&self) -> bool

Return whether or not the key contains the private data

source

pub fn into_xprv(self, network: Network) -> Option<Xpriv>

Transform the ExtendedKey into an Xpriv for the given [Network], if the key contains the private data

source

pub fn into_xpub<C: Signing>( self, network: Network, secp: &Secp256k1<C> ) -> Xpub

Transform the ExtendedKey into an Xpub for the given [Network]

Trait Implementations§

source§

impl<Ctx: ScriptContext> DerivableKey<Ctx> for ExtendedKey<Ctx>

Identity conversion

source§

fn into_extended_key(self) -> Result<ExtendedKey<Ctx>, KeyError>

Consume self and turn it into an ExtendedKey
source§

fn into_descriptor_key( self, origin: Option<KeySource>, derivation_path: DerivationPath ) -> Result<DescriptorKey<Ctx>, KeyError>

Consume self and turn it into a DescriptorKey by adding the extra metadata, such as key origin and derivation path
source§

impl<Ctx: ScriptContext> From<Xpriv> for ExtendedKey<Ctx>

source§

fn from(xprv: Xpriv) -> Self

Converts to this type from the input type.
source§

impl<Ctx: ScriptContext> From<Xpub> for ExtendedKey<Ctx>

source§

fn from(xpub: Xpub) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<Ctx> Freeze for ExtendedKey<Ctx>

§

impl<Ctx> RefUnwindSafe for ExtendedKey<Ctx>
where Ctx: RefUnwindSafe,

§

impl<Ctx> Send for ExtendedKey<Ctx>
where Ctx: Send,

§

impl<Ctx> Sync for ExtendedKey<Ctx>
where Ctx: Sync,

§

impl<Ctx> Unpin for ExtendedKey<Ctx>
where Ctx: Unpin,

§

impl<Ctx> UnwindSafe for ExtendedKey<Ctx>
where Ctx: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V