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 `GeneratableKey` trait in crate `bdk`."><meta name="keywords" content="rust, rustlang, rust-lang, GeneratableKey"><title>bdk::keys::GeneratableKey - 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 trait"><!--[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">☰</div><a href='../../bdk/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Trait GeneratableKey</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-types">Associated Types</a><div class="sidebar-links"><a href="#associatedtype.Entropy">Entropy</a><a href="#associatedtype.Error">Error</a><a href="#associatedtype.Options">Options</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.generate_with_entropy">generate_with_entropy</a></div><a class="sidebar-title" href="#provided-methods">Provided Methods</a><div class="sidebar-links"><a href="#method.generate">generate</a></div><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-GeneratableKey%3CCtx%3E-for-ExtendedPrivKey">ExtendedPrivKey</a><a href="#impl-GeneratableKey%3CCtx%3E-for-Mnemonic">Mnemonic</a><a href="#impl-GeneratableKey%3CCtx%3E-for-PrivateKey">PrivateKey</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../index.html">bdk</a>::<wbr><a href="index.html">keys</a></p><script>window.sidebarCurrent = {name: "GeneratableKey", ty: "trait", 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">−</span>]</a></span><a class="srclink" href="../../src/bdk/keys/mod.rs.html#421-444" title="goto source code">[src]</a></span><span class="in-band">Trait <a href="../index.html">bdk</a>::<wbr><a href="index.html">keys</a>::<wbr><a class="trait" href="">GeneratableKey</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait GeneratableKey<Ctx: <a class="trait" href="../../bdk/keys/trait.ScriptContext.html" title="trait bdk::keys::ScriptContext">ScriptContext</a>>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
5 type <a href="#associatedtype.Entropy" class="type">Entropy</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsMut.html" title="trait core::convert::AsMut">AsMut</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>;
6 type <a href="#associatedtype.Options" class="type">Options</a>;
7 type <a href="#associatedtype.Error" class="type">Error</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>;
8 pub fn <a href="#tymethod.generate_with_entropy" class="fnname">generate_with_entropy</a>(<br> options: Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Options" title="type bdk::keys::GeneratableKey::Options">Options</a>, <br> entropy: Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Entropy" title="type bdk::keys::GeneratableKey::Entropy">Entropy</a><br> ) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../bdk/keys/struct.GeneratedKey.html" title="struct bdk::keys::GeneratedKey">GeneratedKey</a><Self, Ctx>, Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Error" title="type bdk::keys::GeneratableKey::Error">Error</a>>;
10 pub fn <a href="#method.generate" class="fnname">generate</a>(<br> options: Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Options" title="type bdk::keys::GeneratableKey::Options">Options</a><br> ) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../bdk/keys/struct.GeneratedKey.html" title="struct bdk::keys::GeneratedKey">GeneratedKey</a><Self, Ctx>, Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Error" title="type bdk::keys::GeneratableKey::Error">Error</a>> { ... }
11 }</pre></div><div class="docblock"><p>Trait for keys that can be generated</p>
12 <p>The same rules about <a href="../../bdk/keys/trait.ScriptContext.html" title="ScriptContext"><code>ScriptContext</code></a> and <a href="../../bdk/keys/type.ValidNetworks.html" title="ValidNetworks"><code>ValidNetworks</code></a> from <a href="../../bdk/keys/trait.ToDescriptorKey.html" title="ToDescriptorKey"><code>ToDescriptorKey</code></a> apply.</p>
13 <p>This trait is particularly useful when combined with <a href="../../bdk/keys/trait.DerivableKey.html" title="DerivableKey"><code>DerivableKey</code></a>: if <code>Self</code>
14 implements it, the returned <a href="../../bdk/keys/struct.GeneratedKey.html" title="GeneratedKey"><code>GeneratedKey</code></a> will also implement it. The same is true for
15 <a href="../../bdk/keys/trait.ToDescriptorKey.html" title="ToDescriptorKey"><code>ToDescriptorKey</code></a>: the generated keys can be directly used in descriptors if <code>Self</code> is also
16 <a href="../../bdk/keys/trait.ToDescriptorKey.html" title="ToDescriptorKey"><code>ToDescriptorKey</code></a>.</p>
17 </div><h2 id="associated-types" class="small-section-header">Associated Types<a href="#associated-types" class="anchor"></a></h2><div class="methods"><h3 id="associatedtype.Entropy" class="method"><code>type <a href="#associatedtype.Entropy" class="type">Entropy</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsMut.html" title="trait core::convert::AsMut">AsMut</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a></code><a class="srclink" href="../../src/bdk/keys/mod.rs.html#423" title="goto source code">[src]</a></h3><div class="docblock"><p>Type specifying the amount of entropy required e.g. [u8;32]</p>
18 </div><h3 id="associatedtype.Options" class="method"><code>type <a href="#associatedtype.Options" class="type">Options</a></code><a class="srclink" href="../../src/bdk/keys/mod.rs.html#426" title="goto source code">[src]</a></h3><div class="docblock"><p>Extra options required by the <code>generate_with_entropy</code></p>
19 </div><h3 id="associatedtype.Error" class="method"><code>type <a href="#associatedtype.Error" class="type">Error</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a></code><a class="srclink" href="../../src/bdk/keys/mod.rs.html#428" title="goto source code">[src]</a></h3><div class="docblock"><p>Returned error in case of failure</p>
20 </div></div><span class="loading-content">Loading content...</span><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.generate_with_entropy" class="method"><code>pub fn <a href="#tymethod.generate_with_entropy" class="fnname">generate_with_entropy</a>(<br> options: Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Options" title="type bdk::keys::GeneratableKey::Options">Options</a>, <br> entropy: Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Entropy" title="type bdk::keys::GeneratableKey::Entropy">Entropy</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../bdk/keys/struct.GeneratedKey.html" title="struct bdk::keys::GeneratedKey">GeneratedKey</a><Self, Ctx>, Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Error" title="type bdk::keys::GeneratableKey::Error">Error</a>></code><a class="srclink" href="../../src/bdk/keys/mod.rs.html#431-434" title="goto source code">[src]</a></h3><div class="docblock"><p>Generate a key given the extra options and the entropy</p>
21 </div></div><span class="loading-content">Loading content...</span><h2 id="provided-methods" class="small-section-header">Provided methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><h3 id="method.generate" class="method"><code>pub fn <a href="#method.generate" class="fnname">generate</a>(<br> options: Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Options" title="type bdk::keys::GeneratableKey::Options">Options</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../bdk/keys/struct.GeneratedKey.html" title="struct bdk::keys::GeneratedKey">GeneratedKey</a><Self, Ctx>, Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Error" title="type bdk::keys::GeneratableKey::Error">Error</a>></code><a class="srclink" href="../../src/bdk/keys/mod.rs.html#437-443" title="goto source code">[src]</a></h3><div class="docblock"><p>Generate a key given the options with a random entropy</p>
22 </div></div><span class="loading-content">Loading content...</span><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor"></a></h2><h3 id="impl-GeneratableKey%3CCtx%3E-for-Mnemonic" class="impl"><code class="in-band">impl<Ctx: <a class="trait" href="../../bdk/keys/trait.ScriptContext.html" title="trait bdk::keys::ScriptContext">ScriptContext</a>> <a class="trait" href="../../bdk/keys/trait.GeneratableKey.html" title="trait bdk::keys::GeneratableKey">GeneratableKey</a><Ctx> for Mnemonic</code><a href="#impl-GeneratableKey%3CCtx%3E-for-Mnemonic" class="anchor"></a><a class="srclink" href="../../src/bdk/keys/bip39.rs.html#84-99" title="goto source code">[src]</a></h3><div class="item-info"><div class="stab portability">This is supported on <strong>crate feature <code>keys-bip39</code></strong> only.</div></div><div class="impl-items"><h4 id="associatedtype.Entropy-1" class="type"><code>type <a href="#associatedtype.Entropy" class="type">Entropy</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 32]</a></code></h4><h4 id="associatedtype.Options-1" class="type"><code>type <a href="#associatedtype.Options" class="type">Options</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>MnemonicType, Language<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></h4><h4 id="associatedtype.Error-1" class="type"><code>type <a href="#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><ErrorKind></code></h4><h4 id="method.generate_with_entropy" class="method hidden"><code>pub fn <a href="#method.generate_with_entropy" class="fnname">generate_with_entropy</a>(<br> (mnemonic_type, language): Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Options" title="type bdk::keys::GeneratableKey::Options">Options</a>, <br> entropy: Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Entropy" title="type bdk::keys::GeneratableKey::Entropy">Entropy</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../bdk/keys/struct.GeneratedKey.html" title="struct bdk::keys::GeneratedKey">GeneratedKey</a><Self, Ctx>, Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Error" title="type bdk::keys::GeneratableKey::Error">Error</a>></code><a class="srclink" href="../../src/bdk/keys/bip39.rs.html#90-98" title="goto source code">[src]</a></h4></div><h3 id="impl-GeneratableKey%3CCtx%3E-for-ExtendedPrivKey" class="impl"><code class="in-band">impl<Ctx: <a class="trait" href="../../bdk/keys/trait.ScriptContext.html" title="trait bdk::keys::ScriptContext">ScriptContext</a>> <a class="trait" href="../../bdk/keys/trait.GeneratableKey.html" title="trait bdk::keys::GeneratableKey">GeneratableKey</a><Ctx> for ExtendedPrivKey</code><a href="#impl-GeneratableKey%3CCtx%3E-for-ExtendedPrivKey" class="anchor"></a><a class="srclink" href="../../src/bdk/keys/mod.rs.html#477-491" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Entropy-2" class="type"><code>type <a href="#associatedtype.Entropy" class="type">Entropy</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 32]</a></code></h4><h4 id="associatedtype.Options-2" class="type"><code>type <a href="#associatedtype.Options" class="type">Options</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a></code></h4><h4 id="associatedtype.Error-2" class="type"><code>type <a href="#associatedtype.Error" class="type">Error</a> = Error</code></h4><h4 id="method.generate_with_entropy-1" class="method hidden"><code>pub fn <a href="#method.generate_with_entropy" class="fnname">generate_with_entropy</a>(<br> _: Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Options" title="type bdk::keys::GeneratableKey::Options">Options</a>, <br> entropy: Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Entropy" title="type bdk::keys::GeneratableKey::Entropy">Entropy</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../bdk/keys/struct.GeneratedKey.html" title="struct bdk::keys::GeneratedKey">GeneratedKey</a><Self, Ctx>, Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Error" title="type bdk::keys::GeneratableKey::Error">Error</a>></code><a class="srclink" href="../../src/bdk/keys/mod.rs.html#483-490" title="goto source code">[src]</a></h4></div><h3 id="impl-GeneratableKey%3CCtx%3E-for-PrivateKey" class="impl"><code class="in-band">impl<Ctx: <a class="trait" href="../../bdk/keys/trait.ScriptContext.html" title="trait bdk::keys::ScriptContext">ScriptContext</a>> <a class="trait" href="../../bdk/keys/trait.GeneratableKey.html" title="trait bdk::keys::GeneratableKey">GeneratableKey</a><Ctx> for PrivateKey</code><a href="#impl-GeneratableKey%3CCtx%3E-for-PrivateKey" class="anchor"></a><a class="srclink" href="../../src/bdk/keys/mod.rs.html#508-528" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Entropy-3" class="type"><code>type <a href="#associatedtype.Entropy" class="type">Entropy</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 32]</a></code></h4><h4 id="associatedtype.Options-3" class="type"><code>type <a href="#associatedtype.Options" class="type">Options</a> = <a class="struct" href="../../bdk/keys/struct.PrivateKeyGenerateOptions.html" title="struct bdk::keys::PrivateKeyGenerateOptions">PrivateKeyGenerateOptions</a></code></h4><h4 id="associatedtype.Error-3" class="type"><code>type <a href="#associatedtype.Error" class="type">Error</a> = Error</code></h4><h4 id="method.generate_with_entropy-2" class="method hidden"><code>pub fn <a href="#method.generate_with_entropy" class="fnname">generate_with_entropy</a>(<br> options: Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Options" title="type bdk::keys::GeneratableKey::Options">Options</a>, <br> entropy: Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Entropy" title="type bdk::keys::GeneratableKey::Entropy">Entropy</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../bdk/keys/struct.GeneratedKey.html" title="struct bdk::keys::GeneratedKey">GeneratedKey</a><Self, Ctx>, Self::<a class="type" href="../../bdk/keys/trait.GeneratableKey.html#associatedtype.Error" title="type bdk::keys::GeneratableKey::Error">Error</a>></code><a class="srclink" href="../../src/bdk/keys/mod.rs.html#514-527" title="goto source code">[src]</a></h4></div><span class="loading-content">Loading content...</span><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../../implementors/bdk/keys/trait.GeneratableKey.js" async></script></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>