Trait bdk_wallet::descriptor::template::DescriptorTemplate

source ·
pub trait DescriptorTemplate {
    // Required method
    fn build(
        self,
        network: Network
    ) -> Result<DescriptorTemplateOut, DescriptorError>;
}
Expand description

Trait for descriptor templates that can be built into a full descriptor

Since IntoWalletDescriptor is implemented for any DescriptorTemplate, they can also be passed directly to the Wallet constructor.

§Example

use bdk_wallet::descriptor::error::Error as DescriptorError;
use bdk_wallet::keys::{IntoDescriptorKey, KeyError};
use bdk_wallet::miniscript::Legacy;
use bdk_wallet::template::{DescriptorTemplate, DescriptorTemplateOut};
use bitcoin::Network;

struct MyP2PKH<K: IntoDescriptorKey<Legacy>>(K);

impl<K: IntoDescriptorKey<Legacy>> DescriptorTemplate for MyP2PKH<K> {
    fn build(self, network: Network) -> Result<DescriptorTemplateOut, DescriptorError> {
        Ok(bdk_wallet::descriptor!(pkh(self.0))?)
    }
}

Required Methods§

source

fn build( self, network: Network ) -> Result<DescriptorTemplateOut, DescriptorError>

Build the complete descriptor

Implementors§