bdk_wallet::keys

Enum 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>,

Source§

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>,

Source§

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