1 <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Trait for descriptor templates that can be built into a full descriptor"><title>DescriptorTemplate in bdk_wallet::descriptor::template - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-5d1d17d0.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="bdk_wallet" data-themes="" data-resource-suffix="" data-rustdoc-version="1.86.0-nightly (f3d1d47fd 2025-01-20)" data-channel="nightly" data-search-js="search-ccb196c1.js" data-settings-js="settings-0f613d39.js" ><script src="../../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../../bdk_wallet/index.html"><img src="https://github.com/bitcoindevkit/bdk/raw/master/static/bdk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../bdk_wallet/index.html"><img src="https://github.com/bitcoindevkit/bdk/raw/master/static/bdk.png" alt="logo"></a><h2><a href="../../../bdk_wallet/index.html">bdk_<wbr>wallet</a><span class="version">1.0.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Descriptor<wbr>Template</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.build" title="build">build</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In bdk_<wbr>wallet::<wbr>descriptor::<wbr>template</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../../index.html">bdk_wallet</a>::<wbr><a href="../index.html">descriptor</a>::<wbr><a href="index.html">template</a></span><h1>Trait <span class="trait">DescriptorTemplate</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/bdk_wallet/descriptor/template.rs.html#53-56">Source</a> </span></div><pre class="rust item-decl"><code>pub trait DescriptorTemplate {
3 fn <a href="#tymethod.build" class="fn">build</a>(
6 ) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="type" href="type.DescriptorTemplateOut.html" title="type bdk_wallet::descriptor::template::DescriptorTemplateOut">DescriptorTemplateOut</a>, <a class="enum" href="../error/enum.Error.html" title="enum bdk_wallet::descriptor::error::Error">DescriptorError</a>>;
7 }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Trait for descriptor templates that can be built into a full descriptor</p>
8 <p>Since <a href="../trait.IntoWalletDescriptor.html" title="trait bdk_wallet::descriptor::IntoWalletDescriptor"><code>IntoWalletDescriptor</code></a> is implemented for any <a href="trait.DescriptorTemplate.html" title="trait bdk_wallet::descriptor::template::DescriptorTemplate"><code>DescriptorTemplate</code></a>, they can also be
9 passed directly to the <a href="../../struct.Wallet.html" title="struct bdk_wallet::Wallet"><code>Wallet</code></a> constructor.</p>
10 <h3 id="example"><a class="doc-anchor" href="#example">§</a>Example</h3>
11 <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bdk_wallet::descriptor::error::Error <span class="kw">as </span>DescriptorError;
12 <span class="kw">use </span>bdk_wallet::keys::{IntoDescriptorKey, KeyError};
13 <span class="kw">use </span>bdk_wallet::miniscript::Legacy;
14 <span class="kw">use </span>bdk_wallet::template::{DescriptorTemplate, DescriptorTemplateOut};
15 <span class="kw">use </span>bitcoin::Network;
17 <span class="kw">struct </span>MyP2PKH<K: IntoDescriptorKey<Legacy>>(K);
19 <span class="kw">impl</span><K: IntoDescriptorKey<Legacy>> DescriptorTemplate <span class="kw">for </span>MyP2PKH<K> {
20 <span class="kw">fn </span>build(<span class="self">self</span>, network: Network) -> <span class="prelude-ty">Result</span><DescriptorTemplateOut, DescriptorError> {
21 <span class="prelude-val">Ok</span>(<span class="macro">bdk_wallet::descriptor!</span>(pkh(<span class="self">self</span>.<span class="number">0</span>))<span class="question-mark">?</span>)
24 </div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.build" class="method"><a class="src rightside" href="../../../src/bdk_wallet/descriptor/template.rs.html#55">Source</a><h4 class="code-header">fn <a href="#tymethod.build" class="fn">build</a>(
27 ) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="type" href="type.DescriptorTemplateOut.html" title="type bdk_wallet::descriptor::template::DescriptorTemplateOut">DescriptorTemplateOut</a>, <a class="enum" href="../error/enum.Error.html" title="enum bdk_wallet::descriptor::error::Error">DescriptorError</a>></h4></section></summary><div class="docblock"><p>Build the complete descriptor</p>
28 </div></details></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-DescriptorTemplate-for-Bip44%3CK%3E" class="impl"><a class="src rightside" href="../../../src/bdk_wallet/descriptor/template.rs.html#237-241">Source</a><a href="#impl-DescriptorTemplate-for-Bip44%3CK%3E" class="anchor">§</a><h3 class="code-header">impl<K: <a class="trait" href="../../keys/trait.DerivableKey.html" title="trait bdk_wallet::keys::DerivableKey">DerivableKey</a><<a class="enum" href="../enum.Legacy.html" title="enum bdk_wallet::descriptor::Legacy">Legacy</a>>> <a class="trait" href="trait.DescriptorTemplate.html" title="trait bdk_wallet::descriptor::template::DescriptorTemplate">DescriptorTemplate</a> for <a class="struct" href="struct.Bip44.html" title="struct bdk_wallet::descriptor::template::Bip44">Bip44</a><K></h3></section><section id="impl-DescriptorTemplate-for-Bip44Public%3CK%3E" class="impl"><a class="src rightside" href="../../../src/bdk_wallet/descriptor/template.rs.html#276-283">Source</a><a href="#impl-DescriptorTemplate-for-Bip44Public%3CK%3E" class="anchor">§</a><h3 class="code-header">impl<K: <a class="trait" href="../../keys/trait.DerivableKey.html" title="trait bdk_wallet::keys::DerivableKey">DerivableKey</a><<a class="enum" href="../enum.Legacy.html" title="enum bdk_wallet::descriptor::Legacy">Legacy</a>>> <a class="trait" href="trait.DescriptorTemplate.html" title="trait bdk_wallet::descriptor::template::DescriptorTemplate">DescriptorTemplate</a> for <a class="struct" href="struct.Bip44Public.html" title="struct bdk_wallet::descriptor::template::Bip44Public">Bip44Public</a><K></h3></section><section id="impl-DescriptorTemplate-for-Bip49%3CK%3E" class="impl"><a class="src rightside" href="../../../src/bdk_wallet/descriptor/template.rs.html#314-318">Source</a><a href="#impl-DescriptorTemplate-for-Bip49%3CK%3E" class="anchor">§</a><h3 class="code-header">impl<K: <a class="trait" href="../../keys/trait.DerivableKey.html" title="trait bdk_wallet::keys::DerivableKey">DerivableKey</a><<a class="enum" href="../enum.Segwitv0.html" title="enum bdk_wallet::descriptor::Segwitv0">Segwitv0</a>>> <a class="trait" href="trait.DescriptorTemplate.html" title="trait bdk_wallet::descriptor::template::DescriptorTemplate">DescriptorTemplate</a> for <a class="struct" href="struct.Bip49.html" title="struct bdk_wallet::descriptor::template::Bip49">Bip49</a><K></h3></section><section id="impl-DescriptorTemplate-for-Bip49Public%3CK%3E" class="impl"><a class="src rightside" href="../../../src/bdk_wallet/descriptor/template.rs.html#353-360">Source</a><a href="#impl-DescriptorTemplate-for-Bip49Public%3CK%3E" class="anchor">§</a><h3 class="code-header">impl<K: <a class="trait" href="../../keys/trait.DerivableKey.html" title="trait bdk_wallet::keys::DerivableKey">DerivableKey</a><<a class="enum" href="../enum.Segwitv0.html" title="enum bdk_wallet::descriptor::Segwitv0">Segwitv0</a>>> <a class="trait" href="trait.DescriptorTemplate.html" title="trait bdk_wallet::descriptor::template::DescriptorTemplate">DescriptorTemplate</a> for <a class="struct" href="struct.Bip49Public.html" title="struct bdk_wallet::descriptor::template::Bip49Public">Bip49Public</a><K></h3></section><section id="impl-DescriptorTemplate-for-Bip84%3CK%3E" class="impl"><a class="src rightside" href="../../../src/bdk_wallet/descriptor/template.rs.html#391-395">Source</a><a href="#impl-DescriptorTemplate-for-Bip84%3CK%3E" class="anchor">§</a><h3 class="code-header">impl<K: <a class="trait" href="../../keys/trait.DerivableKey.html" title="trait bdk_wallet::keys::DerivableKey">DerivableKey</a><<a class="enum" href="../enum.Segwitv0.html" title="enum bdk_wallet::descriptor::Segwitv0">Segwitv0</a>>> <a class="trait" href="trait.DescriptorTemplate.html" title="trait bdk_wallet::descriptor::template::DescriptorTemplate">DescriptorTemplate</a> for <a class="struct" href="struct.Bip84.html" title="struct bdk_wallet::descriptor::template::Bip84">Bip84</a><K></h3></section><section id="impl-DescriptorTemplate-for-Bip84Public%3CK%3E" class="impl"><a class="src rightside" href="../../../src/bdk_wallet/descriptor/template.rs.html#430-437">Source</a><a href="#impl-DescriptorTemplate-for-Bip84Public%3CK%3E" class="anchor">§</a><h3 class="code-header">impl<K: <a class="trait" href="../../keys/trait.DerivableKey.html" title="trait bdk_wallet::keys::DerivableKey">DerivableKey</a><<a class="enum" href="../enum.Segwitv0.html" title="enum bdk_wallet::descriptor::Segwitv0">Segwitv0</a>>> <a class="trait" href="trait.DescriptorTemplate.html" title="trait bdk_wallet::descriptor::template::DescriptorTemplate">DescriptorTemplate</a> for <a class="struct" href="struct.Bip84Public.html" title="struct bdk_wallet::descriptor::template::Bip84Public">Bip84Public</a><K></h3></section><section id="impl-DescriptorTemplate-for-Bip86%3CK%3E" class="impl"><a class="src rightside" href="../../../src/bdk_wallet/descriptor/template.rs.html#468-472">Source</a><a href="#impl-DescriptorTemplate-for-Bip86%3CK%3E" class="anchor">§</a><h3 class="code-header">impl<K: <a class="trait" href="../../keys/trait.DerivableKey.html" title="trait bdk_wallet::keys::DerivableKey">DerivableKey</a><Tap>> <a class="trait" href="trait.DescriptorTemplate.html" title="trait bdk_wallet::descriptor::template::DescriptorTemplate">DescriptorTemplate</a> for <a class="struct" href="struct.Bip86.html" title="struct bdk_wallet::descriptor::template::Bip86">Bip86</a><K></h3></section><section id="impl-DescriptorTemplate-for-Bip86Public%3CK%3E" class="impl"><a class="src rightside" href="../../../src/bdk_wallet/descriptor/template.rs.html#507-514">Source</a><a href="#impl-DescriptorTemplate-for-Bip86Public%3CK%3E" class="anchor">§</a><h3 class="code-header">impl<K: <a class="trait" href="../../keys/trait.DerivableKey.html" title="trait bdk_wallet::keys::DerivableKey">DerivableKey</a><Tap>> <a class="trait" href="trait.DescriptorTemplate.html" title="trait bdk_wallet::descriptor::template::DescriptorTemplate">DescriptorTemplate</a> for <a class="struct" href="struct.Bip86Public.html" title="struct bdk_wallet::descriptor::template::Bip86Public">Bip86Public</a><K></h3></section><section id="impl-DescriptorTemplate-for-P2Pkh%3CK%3E" class="impl"><a class="src rightside" href="../../../src/bdk_wallet/descriptor/template.rs.html#99-103">Source</a><a href="#impl-DescriptorTemplate-for-P2Pkh%3CK%3E" class="anchor">§</a><h3 class="code-header">impl<K: <a class="trait" href="../../keys/trait.IntoDescriptorKey.html" title="trait bdk_wallet::keys::IntoDescriptorKey">IntoDescriptorKey</a><<a class="enum" href="../enum.Legacy.html" title="enum bdk_wallet::descriptor::Legacy">Legacy</a>>> <a class="trait" href="trait.DescriptorTemplate.html" title="trait bdk_wallet::descriptor::template::DescriptorTemplate">DescriptorTemplate</a> for <a class="struct" href="struct.P2Pkh.html" title="struct bdk_wallet::descriptor::template::P2Pkh">P2Pkh</a><K></h3></section><section id="impl-DescriptorTemplate-for-P2Wpkh%3CK%3E" class="impl"><a class="src rightside" href="../../../src/bdk_wallet/descriptor/template.rs.html#170-174">Source</a><a href="#impl-DescriptorTemplate-for-P2Wpkh%3CK%3E" class="anchor">§</a><h3 class="code-header">impl<K: <a class="trait" href="../../keys/trait.IntoDescriptorKey.html" title="trait bdk_wallet::keys::IntoDescriptorKey">IntoDescriptorKey</a><<a class="enum" href="../enum.Segwitv0.html" title="enum bdk_wallet::descriptor::Segwitv0">Segwitv0</a>>> <a class="trait" href="trait.DescriptorTemplate.html" title="trait bdk_wallet::descriptor::template::DescriptorTemplate">DescriptorTemplate</a> for <a class="struct" href="struct.P2Wpkh.html" title="struct bdk_wallet::descriptor::template::P2Wpkh">P2Wpkh</a><K></h3></section><section id="impl-DescriptorTemplate-for-P2Wpkh_P2Sh%3CK%3E" class="impl"><a class="src rightside" href="../../../src/bdk_wallet/descriptor/template.rs.html#135-139">Source</a><a href="#impl-DescriptorTemplate-for-P2Wpkh_P2Sh%3CK%3E" class="anchor">§</a><h3 class="code-header">impl<K: <a class="trait" href="../../keys/trait.IntoDescriptorKey.html" title="trait bdk_wallet::keys::IntoDescriptorKey">IntoDescriptorKey</a><<a class="enum" href="../enum.Segwitv0.html" title="enum bdk_wallet::descriptor::Segwitv0">Segwitv0</a>>> <a class="trait" href="trait.DescriptorTemplate.html" title="trait bdk_wallet::descriptor::template::DescriptorTemplate">DescriptorTemplate</a> for <a class="struct" href="struct.P2Wpkh_P2Sh.html" title="struct bdk_wallet::descriptor::template::P2Wpkh_P2Sh">P2Wpkh_P2Sh</a><K></h3></section><section id="impl-DescriptorTemplate-for-P2TR%3CK%3E" class="impl"><a class="src rightside" href="../../../src/bdk_wallet/descriptor/template.rs.html#205-209">Source</a><a href="#impl-DescriptorTemplate-for-P2TR%3CK%3E" class="anchor">§</a><h3 class="code-header">impl<K: <a class="trait" href="../../keys/trait.IntoDescriptorKey.html" title="trait bdk_wallet::keys::IntoDescriptorKey">IntoDescriptorKey</a><Tap>> <a class="trait" href="trait.DescriptorTemplate.html" title="trait bdk_wallet::descriptor::template::DescriptorTemplate">DescriptorTemplate</a> for <a class="struct" href="struct.P2TR.html" title="struct bdk_wallet::descriptor::template::P2TR">P2TR</a><K></h3></section></div><script src="../../../trait.impl/bdk_wallet/descriptor/template/trait.DescriptorTemplate.js" async></script></section></div></main></body></html>