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 `ToPublicKey` trait in crate `bdk`."><meta name="keywords" content="rust, rustlang, rust-lang, ToPublicKey"><title>bdk::descriptor::ToPublicKey - 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 ToPublicKey</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.hash_to_hash160">hash_to_hash160</a><a href="#tymethod.to_public_key">to_public_key</a></div><a class="sidebar-title" href="#provided-methods">Provided Methods</a><div class="sidebar-links"><a href="#method.serialized_len">serialized_len</a></div><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-ToPublicKey%3CNullCtx%3E-for-DummyKey">DummyKey</a><a href="#impl-ToPublicKey%3CNullCtx%3E-for-PublicKey">PublicKey</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">descriptor</a></p><script>window.sidebarCurrent = {name: "ToPublicKey", 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></span><span class="in-band">Trait <a href="../index.html">bdk</a>::<wbr><a href="index.html">descriptor</a>::<wbr><a class="trait" href="">ToPublicKey</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait ToPublicKey<ToPkCtx>: <a class="trait" href="../../bdk/descriptor/trait.MiniscriptKey.html" title="trait bdk::descriptor::MiniscriptKey">MiniscriptKey</a> <span class="where fmt-newline">where<br> ToPkCtx: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a>, </span>{
5 pub fn <a href="#tymethod.to_public_key" class="fnname">to_public_key</a>(&self, to_pk_ctx: ToPkCtx) -> PublicKey;
6 <div class="item-spacer"></div> pub fn <a href="#tymethod.hash_to_hash160" class="fnname">hash_to_hash160</a>(hash: &Self::<a class="type" href="../../bdk/descriptor/trait.MiniscriptKey.html#associatedtype.Hash" title="type bdk::descriptor::MiniscriptKey::Hash">Hash</a>, to_pk_ctx: ToPkCtx) -> Hash;
8 pub fn <a href="#method.serialized_len" class="fnname">serialized_len</a>(&self, to_pk_ctx: ToPkCtx) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a> { ... }
9 }</pre></div><div class="docblock"><p>Trait describing public key types which can be converted to bitcoin pubkeys
10 The trait relies on Copy trait because in all practical usecases <code>ToPkCtx</code>
11 should contain references to objects which should be cheap to <code>Copy</code>.</p>
12 </div><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.to_public_key" class="method"><code>pub fn <a href="#tymethod.to_public_key" class="fnname">to_public_key</a>(&self, to_pk_ctx: ToPkCtx) -> PublicKey</code></h3><div class="docblock"><p>Converts an object to a public key
13 C represents additional context information that maybe
14 required for deriving a bitcoin::PublicKey from MiniscriptKey
15 You may require secp context for crypto operations
16 or additional information for substituting the wildcard in
18 </div><h3 id="tymethod.hash_to_hash160" class="method"><code>pub fn <a href="#tymethod.hash_to_hash160" class="fnname">hash_to_hash160</a>(hash: &Self::<a class="type" href="../../bdk/descriptor/trait.MiniscriptKey.html#associatedtype.Hash" title="type bdk::descriptor::MiniscriptKey::Hash">Hash</a>, to_pk_ctx: ToPkCtx) -> Hash</code></h3><div class="docblock"><p>Converts a hashed version of the public key to a <code>hash160</code> hash.</p>
19 <p>This method must be consistent with <code>to_public_key</code>, in the sense
20 that calling <code>MiniscriptKey::to_pubkeyhash</code> followed by this function
21 should give the same result as calling <code>to_public_key</code> and hashing
22 the result directly.</p>
23 </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.serialized_len" class="method"><code>pub fn <a href="#method.serialized_len" class="fnname">serialized_len</a>(&self, to_pk_ctx: ToPkCtx) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></h3><div class="docblock"><p>Computes the size of a public key when serialized in a script,
24 including the length bytes</p>
25 </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-ToPublicKey%3CNullCtx%3E-for-DummyKey" class="impl"><code class="in-band">impl <a class="trait" href="../../bdk/descriptor/trait.ToPublicKey.html" title="trait bdk::descriptor::ToPublicKey">ToPublicKey</a><NullCtx> for DummyKey</code><a href="#impl-ToPublicKey%3CNullCtx%3E-for-DummyKey" class="anchor"></a></h3><div class="impl-items"><h4 id="method.to_public_key" class="method hidden"><code>pub fn <a href="#method.to_public_key" class="fnname">to_public_key</a>(&self, _ctx: NullCtx) -> PublicKey</code></h4><h4 id="method.hash_to_hash160" class="method hidden"><code>pub fn <a href="#method.hash_to_hash160" class="fnname">hash_to_hash160</a>(&DummyKeyHash, _ctx: NullCtx) -> Hash</code></h4></div><h3 id="impl-ToPublicKey%3CNullCtx%3E-for-PublicKey" class="impl"><code class="in-band">impl <a class="trait" href="../../bdk/descriptor/trait.ToPublicKey.html" title="trait bdk::descriptor::ToPublicKey">ToPublicKey</a><NullCtx> for PublicKey</code><a href="#impl-ToPublicKey%3CNullCtx%3E-for-PublicKey" class="anchor"></a></h3><div class="impl-items"><h4 id="method.to_public_key-1" class="method hidden"><code>pub fn <a href="#method.to_public_key" class="fnname">to_public_key</a>(&self, _ctx: NullCtx) -> PublicKey</code></h4><h4 id="method.hash_to_hash160-1" class="method hidden"><code>pub fn <a href="#method.hash_to_hash160" class="fnname">hash_to_hash160</a>(hash: &Hash, _ctx: NullCtx) -> Hash</code></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"><h3 id="impl-ToPublicKey%3CDescriptorPublicKeyCtx%3C%27secp%2C%20C%3E%3E" class="impl"><code class="in-band">impl<'secp, C> ToPublicKey<DescriptorPublicKeyCtx<'secp, C>> for <a class="enum" href="../../bdk/keys/enum.DescriptorPublicKey.html" title="enum bdk::keys::DescriptorPublicKey">DescriptorPublicKey</a> <span class="where fmt-newline">where<br> C: Verification, </span></code><a href="#impl-ToPublicKey%3CDescriptorPublicKeyCtx%3C%27secp%2C%20C%3E%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.to_public_key-2" class="method hidden"><code>pub fn <a href="#method.to_public_key-2" class="fnname">to_public_key</a>(<br> &self, <br> to_pk_ctx: DescriptorPublicKeyCtx<'secp, C><br>) -> PublicKey</code></h4><h4 id="method.hash_to_hash160-2" class="method hidden"><code>pub fn <a href="#method.hash_to_hash160-2" class="fnname">hash_to_hash160</a>(<br> hash: &<<a class="enum" href="../../bdk/keys/enum.DescriptorPublicKey.html" title="enum bdk::keys::DescriptorPublicKey">DescriptorPublicKey</a> as <a class="trait" href="../../bdk/descriptor/trait.MiniscriptKey.html" title="trait bdk::descriptor::MiniscriptKey">MiniscriptKey</a>>::<a class="type" href="../../bdk/descriptor/trait.MiniscriptKey.html#associatedtype.Hash" title="type bdk::descriptor::MiniscriptKey::Hash">Hash</a>, <br> to_pk_ctx: DescriptorPublicKeyCtx<'secp, C><br>) -> Hash</code></h4></div></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../../implementors/miniscript/trait.ToPublicKey.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>