pub struct Bip84Public<K: DerivableKey<Segwitv0>>(pub K, pub Fingerprint, pub KeychainKind);
Expand description

BIP84 public template. Expands to wpkh(key/{0,1}/*)

This assumes that the key used has already been derived with m/84'/0'/0'.

This template requires the parent fingerprint to populate correctly the metadata of PSBTs.

See Bip84 for a template that does the full derivation, but requires private data for the key.

Example

use bdk::template::Bip84Public;

let key = bitcoin::util::bip32::ExtendedPubKey::from_str("tpubDC2Qwo2TFsaNC4ju8nrUJ9mqVT3eSgdmy1yPqhgkjwmke3PRXutNGRYAUo6RCHTcVQaDR3ohNU9we59brGHuEKPvH1ags2nevW5opEE9Z5Q")?;
let fingerprint = bitcoin::util::bip32::Fingerprint::from_str("c55b303f")?;
let wallet = Wallet::new(
    Bip84Public(key.clone(), fingerprint, KeychainKind::External),
    Some(Bip84Public(key, fingerprint, KeychainKind::Internal)),
    Network::Testnet,
    MemoryDatabase::default()
)?;

assert_eq!(wallet.get_address(New)?.to_string(), "tb1qedg9fdlf8cnnqfd5mks6uz5w4kgpk2pr6y4qc7");
assert_eq!(wallet.public_descriptor(KeychainKind::External)?.unwrap().to_string(), "wpkh([c55b303f/84\'/0\'/0\']tpubDC2Qwo2TFsaNC4ju8nrUJ9mqVT3eSgdmy1yPqhgkjwmke3PRXutNGRYAUo6RCHTcVQaDR3ohNU9we59brGHuEKPvH1ags2nevW5opEE9Z5Q/0/*)#nkk5dtkg");

Tuple Fields

0: K1: Fingerprint2: KeychainKind

Trait Implementations

Build the complete descriptor

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Convert to wallet descriptor
The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.