]> Untitled Git - bitcoindevkit.org/blob
b63abf9c5bc7e8a5ffe989c4f60c6a87a25e4877
[bitcoindevkit.org] /
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="API documentation for the Rust `policy` mod in crate `bdk`."><meta name="keywords" content="rust, rustlang, rust-lang, policy"><title>bdk::descriptor::policy - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
2 <link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
3 <link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../../../bdk/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Module policy</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#types">Type Definitions</a></li></ul></div><p class="location"><a href="../../index.html">bdk</a>::<wbr><a href="../index.html">descriptor</a></p><script>window.sidebarCurrent = {name: "policy", ty: "mod", relpath: "../"};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
4 <a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/bdk/descriptor/policy.rs.html#25-1228" title="goto source code">[src]</a></span><span class="in-band">Module <a href="../../index.html">bdk</a>::<wbr><a href="../index.html">descriptor</a>::<wbr><a class="mod" href="">policy</a></span></h1><div class="docblock"><p>Descriptor policy</p>
5 <p>This module implements the logic to extract and represent the spending policies of a descriptor
6 in a more human-readable format.</p>
7 <p>This is an <strong>EXPERIMENTAL</strong> feature, API and other major changes are expected.</p>
8 <h2 id="example" class="section-header"><a href="#example">Example</a></h2>
9 <div class="example-wrap"><pre class="rust rust-example-rendered">
10 <span class="kw">let</span> <span class="ident">secp</span> <span class="op">=</span> <span class="ident">Secp256k1</span>::<span class="ident">new</span>();
11 <span class="kw">let</span> <span class="ident">desc</span> <span class="op">=</span> <span class="string">&quot;wsh(and_v(v:pk(cV3oCth6zxZ1UVsHLnGothsWNsaoxRhC6aeNi5VbSdFpwUkgkEci),or_d(pk(cVMTy7uebJgvFaSBwcgvwk8qn8xSLc97dKow4MBetjrrahZoimm2),older(12960))))&quot;</span>;
12
13 <span class="kw">let</span> (<span class="ident">extended_desc</span>, <span class="ident">key_map</span>) <span class="op">=</span> <span class="ident">ExtendedDescriptor</span>::<span class="ident">parse_descriptor</span>(<span class="ident">desc</span>)<span class="question-mark">?</span>;
14 <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">extended_desc</span>);
15
16 <span class="kw">let</span> <span class="ident">signers</span> <span class="op">=</span> <span class="ident">Arc</span>::<span class="ident">new</span>(<span class="ident">key_map</span>.<span class="ident">into</span>());
17 <span class="kw">let</span> <span class="ident">policy</span> <span class="op">=</span> <span class="ident">extended_desc</span>.<span class="ident">extract_policy</span>(<span class="kw-2">&amp;</span><span class="ident">signers</span>, <span class="kw-2">&amp;</span><span class="ident">secp</span>)<span class="question-mark">?</span>;
18 <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;policy: {}&quot;</span>, <span class="ident">serde_json</span>::<span class="ident">to_string</span>(<span class="kw-2">&amp;</span><span class="ident">policy</span>)<span class="question-mark">?</span>);</pre></div>
19 </div><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
20 <table><tr class="module-item"><td><a class="struct" href="struct.Condition.html" title="bdk::descriptor::policy::Condition struct">Condition</a></td><td class="docblock-short"><p>An extra condition that must be satisfied but that is out of control of the user</p>
21 </td></tr><tr class="module-item"><td><a class="struct" href="struct.PKOrF.html" title="bdk::descriptor::policy::PKOrF struct">PKOrF</a></td><td class="docblock-short"><p>Raw public key or extended key fingerprint</p>
22 </td></tr><tr class="module-item"><td><a class="struct" href="struct.Policy.html" title="bdk::descriptor::policy::Policy struct">Policy</a></td><td class="docblock-short"><p>Descriptor spending policy</p>
23 </td></tr></table><h2 id="enums" class="section-header"><a href="#enums">Enums</a></h2>
24 <table><tr class="module-item"><td><a class="enum" href="enum.PolicyError.html" title="bdk::descriptor::policy::PolicyError enum">PolicyError</a></td><td class="docblock-short"><p>Errors that can happen while extracting and manipulating policies</p>
25 </td></tr><tr class="module-item"><td><a class="enum" href="enum.Satisfaction.html" title="bdk::descriptor::policy::Satisfaction enum">Satisfaction</a></td><td class="docblock-short"><p>Represent if and how much a policy item is satisfied by the wallet's descriptor</p>
26 </td></tr><tr class="module-item"><td><a class="enum" href="enum.SatisfiableItem.html" title="bdk::descriptor::policy::SatisfiableItem enum">SatisfiableItem</a></td><td class="docblock-short"><p>An item that needs to be satisfied</p>
27 </td></tr></table><h2 id="types" class="section-header"><a href="#types">Type Definitions</a></h2>
28 <table><tr class="module-item"><td><a class="type" href="type.ConditionMap.html" title="bdk::descriptor::policy::ConditionMap type">ConditionMap</a></td><td class="docblock-short"><p>Type for a map of sets of <a href="../../../bdk/descriptor/policy/struct.Condition.html" title="Condition"><code>Condition</code></a> items keyed by each set's index</p>
29 </td></tr><tr class="module-item"><td><a class="type" href="type.FoldedConditionMap.html" title="bdk::descriptor::policy::FoldedConditionMap type">FoldedConditionMap</a></td><td class="docblock-short"><p>Type for a map of folded sets of <a href="../../../bdk/descriptor/policy/struct.Condition.html" title="Condition"><code>Condition</code></a> items keyed by a vector of the combined set's indexes</p>
30 </td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "bdk";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>