]> Untitled Git - bitcoindevkit.org/commitdiff
Publish autogenerated nightly docs
authorgithub-actions <github-actions@github.com>
Wed, 3 Aug 2022 18:17:32 +0000 (18:17 +0000)
committergithub-actions <github-actions@github.com>
Wed, 3 Aug 2022 18:17:32 +0000 (18:17 +0000)
docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/coin_selection/index.html
docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/coin_selection/struct.BranchAndBoundCoinSelection.html
docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/coin_selection/trait.CoinSelectionAlgorithm.html
docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/wallet/coin_selection.rs.html

index a558f29beb81bcaf247126ea6a3a0397079df350..b217046f052a8dba972a5aa3f62e7e0c68b2cbe3 100644 (file)
@@ -6,7 +6,7 @@
                     <img src="https://github.com/bitcoindevkit/bdk/raw/master/static/bdk.png" alt="logo"></div>
         </a><h2 class="location"><a href="#">Module coin_selection</a></h2><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="#traits">Traits</a></li><li><a href="#functions">Functions</a></li><li><a href="#types">Type Definitions</a></li></ul></div><div id="sidebar-vars" data-name="coin_selection" data-ty="mod" data-relpath="./"></div><script defer src="./sidebar-items.js"></script></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../../bdk/index.html">
                         <img src="https://github.com/bitcoindevkit/bdk/raw/master/static/bdk.png" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="main-heading">
-    <h1 class="fqn"><span class="in-band">Module <a href="../../index.html">bdk</a>::<wbr><a href="../index.html">wallet</a>::<wbr><a class="mod" href="#">coin_selection</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#12-1490" title="goto source code">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Coin selection</p>
+    <h1 class="fqn"><span class="in-band">Module <a href="../../index.html">bdk</a>::<wbr><a href="../index.html">wallet</a>::<wbr><a class="mod" href="#">coin_selection</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#12-1596" title="goto source code">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Coin selection</p>
 <p>This module provides the trait <a href="trait.CoinSelectionAlgorithm.html" title="CoinSelectionAlgorithm"><code>CoinSelectionAlgorithm</code></a> that can be implemented to
 define custom coin selection algorithms.</p>
 <p>You can specify a custom coin selection algorithm through the <a href="../tx_builder/struct.TxBuilder.html#method.coin_selection"><code>coin_selection</code></a> method on
index f637808b800eee7ba98676f46470b2509167acf7..ef15844bea50d0e7032131ff926b45b4d1147b5b 100644 (file)
@@ -9,7 +9,7 @@
     <h1 class="fqn"><span class="in-band">Struct <a href="../../index.html">bdk</a>::<wbr><a href="../index.html">wallet</a>::<wbr><a href="index.html">coin_selection</a>::<wbr><a class="struct" href="#">BranchAndBoundCoinSelection</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#403-405" title="goto source code">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><pre class="rust struct"><code>pub struct BranchAndBoundCoinSelection { /* private fields */ }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Branch and bound coin selection</p>
 <p>Code adapted from Bitcoin Core’s implementation and from Mark Erhardt Master’s Thesis: <a href="http://murch.one/wp-content/uploads/2016/11/erhardt2016coinselection.pdf">http://murch.one/wp-content/uploads/2016/11/erhardt2016coinselection.pdf</a></p>
 </div></details><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#416-421" title="goto source code">source</a></div><a href="#impl" class="anchor"></a><h3 class="code-header in-band">impl <a class="struct" href="struct.BranchAndBoundCoinSelection.html" title="struct bdk::wallet::coin_selection::BranchAndBoundCoinSelection">BranchAndBoundCoinSelection</a></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.new" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#418-420" title="goto source code">source</a></div><a href="#method.new" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.new" class="fnname">new</a>(size_of_change: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -&gt; Self</h4></div></summary><div class="docblock"><p>Create new instance with target size for change output</p>
-</div></details></div></details><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-CoinSelectionAlgorithm%3CD%3E" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#425-511" title="goto source code">source</a></div><a href="#impl-CoinSelectionAlgorithm%3CD%3E" class="anchor"></a><h3 class="code-header in-band">impl&lt;D:&nbsp;<a class="trait" href="../../database/trait.Database.html" title="trait bdk::database::Database">Database</a>&gt; <a class="trait" href="trait.CoinSelectionAlgorithm.html" title="trait bdk::wallet::coin_selection::CoinSelectionAlgorithm">CoinSelectionAlgorithm</a>&lt;D&gt; for <a class="struct" href="struct.BranchAndBoundCoinSelection.html" title="struct bdk::wallet::coin_selection::BranchAndBoundCoinSelection">BranchAndBoundCoinSelection</a></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.coin_select" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#426-510" title="goto source code">source</a></div><a href="#method.coin_select" class="anchor"></a><h4 class="code-header">fn <a href="trait.CoinSelectionAlgorithm.html#tymethod.coin_select" class="fnname">coin_select</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;_database: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>D, <br>&nbsp;&nbsp;&nbsp;&nbsp;required_utxos: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="struct" href="../../struct.WeightedUtxo.html" title="struct bdk::WeightedUtxo">WeightedUtxo</a>&gt;, <br>&nbsp;&nbsp;&nbsp;&nbsp;optional_utxos: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="struct" href="../../struct.WeightedUtxo.html" title="struct bdk::WeightedUtxo">WeightedUtxo</a>&gt;, <br>&nbsp;&nbsp;&nbsp;&nbsp;fee_rate: <a class="struct" href="../../struct.FeeRate.html" title="struct bdk::FeeRate">FeeRate</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;target_amount: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;drain_script: &amp;Script<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.CoinSelectionResult.html" title="struct bdk::wallet::coin_selection::CoinSelectionResult">CoinSelectionResult</a>, <a class="enum" href="../../enum.Error.html" title="enum bdk::Error">Error</a>&gt;</h4></div></summary><div class='docblock'><p>Perform the coin selection <a href="trait.CoinSelectionAlgorithm.html#tymethod.coin_select">Read more</a></p>
+</div></details></div></details><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-CoinSelectionAlgorithm%3CD%3E" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#425-535" title="goto source code">source</a></div><a href="#impl-CoinSelectionAlgorithm%3CD%3E" class="anchor"></a><h3 class="code-header in-band">impl&lt;D:&nbsp;<a class="trait" href="../../database/trait.Database.html" title="trait bdk::database::Database">Database</a>&gt; <a class="trait" href="trait.CoinSelectionAlgorithm.html" title="trait bdk::wallet::coin_selection::CoinSelectionAlgorithm">CoinSelectionAlgorithm</a>&lt;D&gt; for <a class="struct" href="struct.BranchAndBoundCoinSelection.html" title="struct bdk::wallet::coin_selection::BranchAndBoundCoinSelection">BranchAndBoundCoinSelection</a></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.coin_select" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#426-534" title="goto source code">source</a></div><a href="#method.coin_select" class="anchor"></a><h4 class="code-header">fn <a href="trait.CoinSelectionAlgorithm.html#tymethod.coin_select" class="fnname">coin_select</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;_database: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>D, <br>&nbsp;&nbsp;&nbsp;&nbsp;required_utxos: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="struct" href="../../struct.WeightedUtxo.html" title="struct bdk::WeightedUtxo">WeightedUtxo</a>&gt;, <br>&nbsp;&nbsp;&nbsp;&nbsp;optional_utxos: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="struct" href="../../struct.WeightedUtxo.html" title="struct bdk::WeightedUtxo">WeightedUtxo</a>&gt;, <br>&nbsp;&nbsp;&nbsp;&nbsp;fee_rate: <a class="struct" href="../../struct.FeeRate.html" title="struct bdk::FeeRate">FeeRate</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;target_amount: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;drain_script: &amp;Script<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.CoinSelectionResult.html" title="struct bdk::wallet::coin_selection::CoinSelectionResult">CoinSelectionResult</a>, <a class="enum" href="../../enum.Error.html" title="enum bdk::Error">Error</a>&gt;</h4></div></summary><div class='docblock'><p>Perform the coin selection <a href="trait.CoinSelectionAlgorithm.html#tymethod.coin_select">Read more</a></p>
 </div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-Debug" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#402" title="goto source code">source</a></div><a href="#impl-Debug" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.BranchAndBoundCoinSelection.html" title="struct bdk::wallet::coin_selection::BranchAndBoundCoinSelection">BranchAndBoundCoinSelection</a></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.fmt" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#402" title="goto source code">source</a></div><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></div></summary><div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
 </div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-Default" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#407-414" title="goto source code">source</a></div><a href="#impl-Default" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="struct.BranchAndBoundCoinSelection.html" title="struct bdk::wallet::coin_selection::BranchAndBoundCoinSelection">BranchAndBoundCoinSelection</a></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.default" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#408-413" title="goto source code">source</a></div><a href="#method.default" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default" class="fnname">default</a>() -&gt; Self</h4></div></summary><div class='docblock'><p>Returns the “default value” for a type. <a href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default">Read more</a></p>
 </div></details></div></details></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><div id="impl-RefUnwindSafe" class="impl has-srclink"><div class="rightside"></div><a href="#impl-RefUnwindSafe" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.BranchAndBoundCoinSelection.html" title="struct bdk::wallet::coin_selection::BranchAndBoundCoinSelection">BranchAndBoundCoinSelection</a></h3></div><div id="impl-Send" class="impl has-srclink"><div class="rightside"></div><a href="#impl-Send" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.BranchAndBoundCoinSelection.html" title="struct bdk::wallet::coin_selection::BranchAndBoundCoinSelection">BranchAndBoundCoinSelection</a></h3></div><div id="impl-Sync" class="impl has-srclink"><div class="rightside"></div><a href="#impl-Sync" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.BranchAndBoundCoinSelection.html" title="struct bdk::wallet::coin_selection::BranchAndBoundCoinSelection">BranchAndBoundCoinSelection</a></h3></div><div id="impl-Unpin" class="impl has-srclink"><div class="rightside"></div><a href="#impl-Unpin" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.BranchAndBoundCoinSelection.html" title="struct bdk::wallet::coin_selection::BranchAndBoundCoinSelection">BranchAndBoundCoinSelection</a></h3></div><div id="impl-UnwindSafe" class="impl has-srclink"><div class="rightside"></div><a href="#impl-UnwindSafe" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.BranchAndBoundCoinSelection.html" title="struct bdk::wallet::coin_selection::BranchAndBoundCoinSelection">BranchAndBoundCoinSelection</a></h3></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-Any" class="impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#132-136" title="goto source code">source</a></div><a href="#impl-Any" class="anchor"></a><h3 class="code-header in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.type_id" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#133" title="goto source code">source</a></div><a href="#method.type_id" class="anchor"></a><h4 class="code-header">pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></div></summary><div class='docblock'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
index 81f4a9e4f831d689bf658f4b6f1b105db6811a19..16ffdf5158610da75208721fd9959fde3067ce4c 100644 (file)
@@ -25,5 +25,5 @@ weight cost</li>
 accumulated from added outputs and transaction’s header.</li>
 <li><code>drain_script</code>: the script to use in case of change</li>
 </ul>
-</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><div id="impl-CoinSelectionAlgorithm%3CD%3E" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#425-511" title="goto source code">source</a></div><a href="#impl-CoinSelectionAlgorithm%3CD%3E" class="anchor"></a><h3 class="code-header in-band">impl&lt;D:&nbsp;<a class="trait" href="../../database/trait.Database.html" title="trait bdk::database::Database">Database</a>&gt; <a class="trait" href="trait.CoinSelectionAlgorithm.html" title="trait bdk::wallet::coin_selection::CoinSelectionAlgorithm">CoinSelectionAlgorithm</a>&lt;D&gt; for <a class="struct" href="struct.BranchAndBoundCoinSelection.html" title="struct bdk::wallet::coin_selection::BranchAndBoundCoinSelection">BranchAndBoundCoinSelection</a></h3></div><div id="impl-CoinSelectionAlgorithm%3CD%3E-1" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#212-240" title="goto source code">source</a></div><a href="#impl-CoinSelectionAlgorithm%3CD%3E-1" class="anchor"></a><h3 class="code-header in-band">impl&lt;D:&nbsp;<a class="trait" href="../../database/trait.Database.html" title="trait bdk::database::Database">Database</a>&gt; <a class="trait" href="trait.CoinSelectionAlgorithm.html" title="trait bdk::wallet::coin_selection::CoinSelectionAlgorithm">CoinSelectionAlgorithm</a>&lt;D&gt; for <a class="struct" href="struct.LargestFirstCoinSelection.html" title="struct bdk::wallet::coin_selection::LargestFirstCoinSelection">LargestFirstCoinSelection</a></h3></div><div id="impl-CoinSelectionAlgorithm%3CD%3E-2" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#249-299" title="goto source code">source</a></div><a href="#impl-CoinSelectionAlgorithm%3CD%3E-2" class="anchor"></a><h3 class="code-header in-band">impl&lt;D:&nbsp;<a class="trait" href="../../database/trait.Database.html" title="trait bdk::database::Database">Database</a>&gt; <a class="trait" href="trait.CoinSelectionAlgorithm.html" title="trait bdk::wallet::coin_selection::CoinSelectionAlgorithm">CoinSelectionAlgorithm</a>&lt;D&gt; for <a class="struct" href="struct.OldestFirstCoinSelection.html" title="struct bdk::wallet::coin_selection::OldestFirstCoinSelection">OldestFirstCoinSelection</a></h3></div></div><script type="text/javascript" src="../../../implementors/bdk/wallet/coin_selection/trait.CoinSelectionAlgorithm.js" async></script></section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="bdk" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.60.0-nightly (51126be1b 2022-01-24)" ></div>
+</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><div id="impl-CoinSelectionAlgorithm%3CD%3E" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#425-535" title="goto source code">source</a></div><a href="#impl-CoinSelectionAlgorithm%3CD%3E" class="anchor"></a><h3 class="code-header in-band">impl&lt;D:&nbsp;<a class="trait" href="../../database/trait.Database.html" title="trait bdk::database::Database">Database</a>&gt; <a class="trait" href="trait.CoinSelectionAlgorithm.html" title="trait bdk::wallet::coin_selection::CoinSelectionAlgorithm">CoinSelectionAlgorithm</a>&lt;D&gt; for <a class="struct" href="struct.BranchAndBoundCoinSelection.html" title="struct bdk::wallet::coin_selection::BranchAndBoundCoinSelection">BranchAndBoundCoinSelection</a></h3></div><div id="impl-CoinSelectionAlgorithm%3CD%3E-1" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#212-240" title="goto source code">source</a></div><a href="#impl-CoinSelectionAlgorithm%3CD%3E-1" class="anchor"></a><h3 class="code-header in-band">impl&lt;D:&nbsp;<a class="trait" href="../../database/trait.Database.html" title="trait bdk::database::Database">Database</a>&gt; <a class="trait" href="trait.CoinSelectionAlgorithm.html" title="trait bdk::wallet::coin_selection::CoinSelectionAlgorithm">CoinSelectionAlgorithm</a>&lt;D&gt; for <a class="struct" href="struct.LargestFirstCoinSelection.html" title="struct bdk::wallet::coin_selection::LargestFirstCoinSelection">LargestFirstCoinSelection</a></h3></div><div id="impl-CoinSelectionAlgorithm%3CD%3E-2" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../../../src/bdk/wallet/coin_selection.rs.html#249-299" title="goto source code">source</a></div><a href="#impl-CoinSelectionAlgorithm%3CD%3E-2" class="anchor"></a><h3 class="code-header in-band">impl&lt;D:&nbsp;<a class="trait" href="../../database/trait.Database.html" title="trait bdk::database::Database">Database</a>&gt; <a class="trait" href="trait.CoinSelectionAlgorithm.html" title="trait bdk::wallet::coin_selection::CoinSelectionAlgorithm">CoinSelectionAlgorithm</a>&lt;D&gt; for <a class="struct" href="struct.OldestFirstCoinSelection.html" title="struct bdk::wallet::coin_selection::OldestFirstCoinSelection">OldestFirstCoinSelection</a></h3></div></div><script type="text/javascript" src="../../../implementors/bdk/wallet/coin_selection/trait.CoinSelectionAlgorithm.js" async></script></section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="bdk" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.60.0-nightly (51126be1b 2022-01-24)" ></div>
 </body></html>
\ No newline at end of file
index 586d3c4267e3a0a0de83b9f6a5d4ffbafb5a4cc8..6099714dd2453c94fa0244146ade3c51dd51a1f5 100644 (file)
 <span id="1488">1488</span>
 <span id="1489">1489</span>
 <span id="1490">1490</span>
+<span id="1491">1491</span>
+<span id="1492">1492</span>
+<span id="1493">1493</span>
+<span id="1494">1494</span>
+<span id="1495">1495</span>
+<span id="1496">1496</span>
+<span id="1497">1497</span>
+<span id="1498">1498</span>
+<span id="1499">1499</span>
+<span id="1500">1500</span>
+<span id="1501">1501</span>
+<span id="1502">1502</span>
+<span id="1503">1503</span>
+<span id="1504">1504</span>
+<span id="1505">1505</span>
+<span id="1506">1506</span>
+<span id="1507">1507</span>
+<span id="1508">1508</span>
+<span id="1509">1509</span>
+<span id="1510">1510</span>
+<span id="1511">1511</span>
+<span id="1512">1512</span>
+<span id="1513">1513</span>
+<span id="1514">1514</span>
+<span id="1515">1515</span>
+<span id="1516">1516</span>
+<span id="1517">1517</span>
+<span id="1518">1518</span>
+<span id="1519">1519</span>
+<span id="1520">1520</span>
+<span id="1521">1521</span>
+<span id="1522">1522</span>
+<span id="1523">1523</span>
+<span id="1524">1524</span>
+<span id="1525">1525</span>
+<span id="1526">1526</span>
+<span id="1527">1527</span>
+<span id="1528">1528</span>
+<span id="1529">1529</span>
+<span id="1530">1530</span>
+<span id="1531">1531</span>
+<span id="1532">1532</span>
+<span id="1533">1533</span>
+<span id="1534">1534</span>
+<span id="1535">1535</span>
+<span id="1536">1536</span>
+<span id="1537">1537</span>
+<span id="1538">1538</span>
+<span id="1539">1539</span>
+<span id="1540">1540</span>
+<span id="1541">1541</span>
+<span id="1542">1542</span>
+<span id="1543">1543</span>
+<span id="1544">1544</span>
+<span id="1545">1545</span>
+<span id="1546">1546</span>
+<span id="1547">1547</span>
+<span id="1548">1548</span>
+<span id="1549">1549</span>
+<span id="1550">1550</span>
+<span id="1551">1551</span>
+<span id="1552">1552</span>
+<span id="1553">1553</span>
+<span id="1554">1554</span>
+<span id="1555">1555</span>
+<span id="1556">1556</span>
+<span id="1557">1557</span>
+<span id="1558">1558</span>
+<span id="1559">1559</span>
+<span id="1560">1560</span>
+<span id="1561">1561</span>
+<span id="1562">1562</span>
+<span id="1563">1563</span>
+<span id="1564">1564</span>
+<span id="1565">1565</span>
+<span id="1566">1566</span>
+<span id="1567">1567</span>
+<span id="1568">1568</span>
+<span id="1569">1569</span>
+<span id="1570">1570</span>
+<span id="1571">1571</span>
+<span id="1572">1572</span>
+<span id="1573">1573</span>
+<span id="1574">1574</span>
+<span id="1575">1575</span>
+<span id="1576">1576</span>
+<span id="1577">1577</span>
+<span id="1578">1578</span>
+<span id="1579">1579</span>
+<span id="1580">1580</span>
+<span id="1581">1581</span>
+<span id="1582">1582</span>
+<span id="1583">1583</span>
+<span id="1584">1584</span>
+<span id="1585">1585</span>
+<span id="1586">1586</span>
+<span id="1587">1587</span>
+<span id="1588">1588</span>
+<span id="1589">1589</span>
+<span id="1590">1590</span>
+<span id="1591">1591</span>
+<span id="1592">1592</span>
+<span id="1593">1593</span>
+<span id="1594">1594</span>
+<span id="1595">1595</span>
+<span id="1596">1596</span>
 </pre><pre class="rust"><code><span class="comment">// Bitcoin Dev Kit</span>
 <span class="comment">// Written in 2020 by Alekos Filini &lt;alekos.filini@gmail.com&gt;</span>
 <span class="comment">//</span>
             .<span class="ident">map</span>(<span class="op">|</span><span class="ident">u</span><span class="op">|</span> <span class="ident">OutputGroup::new</span>(<span class="ident">u</span>, <span class="ident">fee_rate</span>))
             .<span class="ident">collect</span>();
 
-        <span class="comment">// Mapping every (UTXO, usize) to an output group.</span>
+        <span class="comment">// Mapping every (UTXO, usize) to an output group, filtering UTXOs with a negative</span>
+        <span class="comment">// effective value</span>
         <span class="kw">let</span> <span class="ident">optional_utxos</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">OutputGroup</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">optional_utxos</span>
             .<span class="ident">into_iter</span>()
             .<span class="ident">map</span>(<span class="op">|</span><span class="ident">u</span><span class="op">|</span> <span class="ident">OutputGroup::new</span>(<span class="ident">u</span>, <span class="ident">fee_rate</span>))
+            .<span class="ident">filter</span>(<span class="op">|</span><span class="ident">u</span><span class="op">|</span> <span class="ident">u</span>.<span class="ident">effective_value</span>.<span class="ident">is_positive</span>())
             .<span class="ident">collect</span>();
 
         <span class="kw">let</span> <span class="ident">curr_value</span> <span class="op">=</span> <span class="ident">required_utxos</span>
 
         <span class="kw">let</span> <span class="ident">cost_of_change</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">size_of_change</span> <span class="kw">as</span> <span class="ident">f32</span> <span class="op">*</span> <span class="ident">fee_rate</span>.<span class="ident">as_sat_vb</span>();
 
-        <span class="kw">let</span> <span class="ident">expected</span> <span class="op">=</span> (<span class="ident">curr_available_value</span> <span class="op">+</span> <span class="ident">curr_value</span>)
-            .<span class="ident">try_into</span>()
-            .<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> {
-                <span class="ident">Error::Generic</span>(<span class="string">&quot;Sum of UTXO spendable values does not fit into u64&quot;</span>.<span class="ident">to_string</span>())
-            })<span class="question-mark">?</span>;
-
-        <span class="kw">if</span> <span class="ident">expected</span> <span class="op">&lt;</span> <span class="ident">target_amount</span> {
-            <span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">Error::InsufficientFunds</span> {
-                <span class="ident">needed</span>: <span class="ident">target_amount</span>,
-                <span class="ident">available</span>: <span class="ident">expected</span>,
-            });
+        <span class="comment">// `curr_value` and `curr_available_value` are both the sum of *effective_values* of</span>
+        <span class="comment">// the UTXOs. For the optional UTXOs (curr_available_value) we filter out UTXOs with</span>
+        <span class="comment">// negative effective value, so it will always be positive.</span>
+        <span class="comment">//</span>
+        <span class="comment">// Since we are required to spend the required UTXOs (curr_value) we have to consider</span>
+        <span class="comment">// all their effective values, even when negative, which means that curr_value could</span>
+        <span class="comment">// be negative as well.</span>
+        <span class="comment">//</span>
+        <span class="comment">// If the sum of curr_value and curr_available_value is negative or lower than our target,</span>
+        <span class="comment">// we can immediately exit with an error, as it&#39;s guaranteed we will never find a solution</span>
+        <span class="comment">// if we actually run the BnB.</span>
+        <span class="kw">let</span> <span class="ident">total_value</span>: <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">u64</span>, <span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> (<span class="ident">curr_available_value</span> <span class="op">+</span> <span class="ident">curr_value</span>).<span class="ident">try_into</span>();
+        <span class="kw">match</span> <span class="ident">total_value</span> {
+            <span class="prelude-val">Ok</span>(<span class="ident">v</span>) <span class="kw">if</span> <span class="ident">v</span> <span class="op">&gt;</span><span class="op">=</span> <span class="ident">target_amount</span> =&gt; {}
+            <span class="kw">_</span> =&gt; {
+                <span class="comment">// Assume we spend all the UTXOs we can (all the required + all the optional with</span>
+                <span class="comment">// positive effective value), sum their value and their fee cost.</span>
+                <span class="kw">let</span> (<span class="ident">utxo_fees</span>, <span class="ident">utxo_value</span>) <span class="op">=</span> <span class="ident">required_utxos</span>
+                    .<span class="ident">iter</span>()
+                    .<span class="ident">chain</span>(<span class="ident">optional_utxos</span>.<span class="ident">iter</span>())
+                    .<span class="ident">fold</span>((<span class="number">0</span>, <span class="number">0</span>), <span class="op">|</span>(<span class="kw-2">mut</span> <span class="ident">fees</span>, <span class="kw-2">mut</span> <span class="ident">value</span>), <span class="ident">utxo</span><span class="op">|</span> {
+                        <span class="ident">fees</span> <span class="op">+</span><span class="op">=</span> <span class="ident">utxo</span>.<span class="ident">fee</span>;
+                        <span class="ident">value</span> <span class="op">+</span><span class="op">=</span> <span class="ident">utxo</span>.<span class="ident">weighted_utxo</span>.<span class="ident">utxo</span>.<span class="ident">txout</span>().<span class="ident">value</span>;
+
+                        (<span class="ident">fees</span>, <span class="ident">value</span>)
+                    });
+
+                <span class="comment">// Add to the target the fee cost of the UTXOs</span>
+                <span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">Error::InsufficientFunds</span> {
+                    <span class="ident">needed</span>: <span class="ident">target_amount</span> <span class="op">+</span> <span class="ident">utxo_fees</span>,
+                    <span class="ident">available</span>: <span class="ident">utxo_value</span>,
+                });
+            }
         }
 
         <span class="kw">let</span> <span class="ident">target_amount</span> <span class="op">=</span> <span class="ident">target_amount</span>
             )
             .<span class="ident">unwrap</span>();
 
-        <span class="macro">assert_eq!</span>(<span class="ident">result</span>.<span class="ident">selected</span>.<span class="ident">len</span>(), <span class="number">3</span>);
-        <span class="macro">assert_eq!</span>(<span class="ident">result</span>.<span class="ident">selected_amount</span>(), <span class="number">300010</span>);
-        <span class="macro">assert_eq!</span>(<span class="ident">result</span>.<span class="ident">fee_amount</span>, <span class="number">204</span>);
+        <span class="macro">assert_eq!</span>(<span class="ident">result</span>.<span class="ident">selected</span>.<span class="ident">len</span>(), <span class="number">2</span>);
+        <span class="macro">assert_eq!</span>(<span class="ident">result</span>.<span class="ident">selected_amount</span>(), <span class="number">300000</span>);
+        <span class="macro">assert_eq!</span>(<span class="ident">result</span>.<span class="ident">fee_amount</span>, <span class="number">136</span>);
     }
 
     <span class="attribute">#[<span class="ident">test</span>]</span>
             )
             .<span class="ident">unwrap</span>();
 
-        <span class="macro">assert_eq!</span>(<span class="ident">result</span>.<span class="ident">selected</span>.<span class="ident">len</span>(), <span class="number">3</span>);
-        <span class="macro">assert_eq!</span>(<span class="ident">result</span>.<span class="ident">selected_amount</span>(), <span class="number">300_010</span>);
-        <span class="macro">assert!</span>((<span class="ident">result</span>.<span class="ident">fee_amount</span> <span class="kw">as</span> <span class="ident">f32</span> <span class="op">-</span> <span class="number">204.0</span>).<span class="ident">abs</span>() <span class="op">&lt;</span> <span class="ident">f32::EPSILON</span>);
+        <span class="macro">assert_eq!</span>(<span class="ident">result</span>.<span class="ident">selected</span>.<span class="ident">len</span>(), <span class="number">2</span>);
+        <span class="macro">assert_eq!</span>(<span class="ident">result</span>.<span class="ident">selected_amount</span>(), <span class="number">300_000</span>);
+        <span class="macro">assert_eq!</span>(<span class="ident">result</span>.<span class="ident">fee_amount</span>, <span class="number">136</span>);
     }
 
     <span class="attribute">#[<span class="ident">test</span>]</span>
         <span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">selected_amount</span>() <span class="op">&gt;</span> <span class="ident">target_amount</span>);
         <span class="macro">assert_eq!</span>(<span class="ident">result</span>.<span class="ident">fee_amount</span>, (<span class="ident">result</span>.<span class="ident">selected</span>.<span class="ident">len</span>() <span class="op">*</span> <span class="number">68</span>) <span class="kw">as</span> <span class="ident">u64</span>);
     }
+
+    <span class="attribute">#[<span class="ident">test</span>]</span>
+    <span class="kw">fn</span> <span class="ident">test_bnb_exclude_negative_effective_value</span>() {
+        <span class="kw">let</span> <span class="ident">utxos</span> <span class="op">=</span> <span class="ident">get_test_utxos</span>();
+        <span class="kw">let</span> <span class="ident">database</span> <span class="op">=</span> <span class="ident">MemoryDatabase::default</span>();
+        <span class="kw">let</span> <span class="ident">drain_script</span> <span class="op">=</span> <span class="ident">Script::default</span>();
+
+        <span class="kw">let</span> <span class="ident">err</span> <span class="op">=</span> <span class="ident">BranchAndBoundCoinSelection::default</span>()
+            .<span class="ident">coin_select</span>(
+                <span class="kw-2">&amp;</span><span class="ident">database</span>,
+                <span class="macro">vec!</span>[],
+                <span class="ident">utxos</span>,
+                <span class="ident">FeeRate::from_sat_per_vb</span>(<span class="number">10.0</span>),
+                <span class="number">500_000</span>,
+                <span class="kw-2">&amp;</span><span class="ident">drain_script</span>,
+            )
+            .<span class="ident">unwrap_err</span>();
+
+        <span class="macro">assert!</span>(<span class="macro">matches!</span>(
+            <span class="ident">err</span>,
+            <span class="ident">Error::InsufficientFunds</span> {
+                <span class="ident">available</span>: <span class="number">300_000</span>,
+                ..
+            }
+        ));
+    }
+
+    <span class="attribute">#[<span class="ident">test</span>]</span>
+    <span class="kw">fn</span> <span class="ident">test_bnb_include_negative_effective_value_when_required</span>() {
+        <span class="kw">let</span> <span class="ident">utxos</span> <span class="op">=</span> <span class="ident">get_test_utxos</span>();
+        <span class="kw">let</span> <span class="ident">database</span> <span class="op">=</span> <span class="ident">MemoryDatabase::default</span>();
+        <span class="kw">let</span> <span class="ident">drain_script</span> <span class="op">=</span> <span class="ident">Script::default</span>();
+
+        <span class="kw">let</span> (<span class="ident">required</span>, <span class="ident">optional</span>) <span class="op">=</span> <span class="ident">utxos</span>
+            .<span class="ident">into_iter</span>()
+            .<span class="ident">partition</span>(<span class="op">|</span><span class="ident">u</span><span class="op">|</span> <span class="macro">matches!</span>(<span class="ident">u</span>, <span class="ident">WeightedUtxo</span> { <span class="ident">utxo</span>, .. } <span class="kw">if</span> <span class="ident">utxo</span>.<span class="ident">txout</span>().<span class="ident">value</span> <span class="op">&lt;</span> <span class="number">1000</span>));
+
+        <span class="kw">let</span> <span class="ident">err</span> <span class="op">=</span> <span class="ident">BranchAndBoundCoinSelection::default</span>()
+            .<span class="ident">coin_select</span>(
+                <span class="kw-2">&amp;</span><span class="ident">database</span>,
+                <span class="ident">required</span>,
+                <span class="ident">optional</span>,
+                <span class="ident">FeeRate::from_sat_per_vb</span>(<span class="number">10.0</span>),
+                <span class="number">500_000</span>,
+                <span class="kw-2">&amp;</span><span class="ident">drain_script</span>,
+            )
+            .<span class="ident">unwrap_err</span>();
+
+        <span class="macro">assert!</span>(<span class="macro">matches!</span>(
+            <span class="ident">err</span>,
+            <span class="ident">Error::InsufficientFunds</span> {
+                <span class="ident">available</span>: <span class="number">300_010</span>,
+                ..
+            }
+        ));
+    }
+
+    <span class="attribute">#[<span class="ident">test</span>]</span>
+    <span class="kw">fn</span> <span class="ident">test_bnb_sum_of_effective_value_negative</span>() {
+        <span class="kw">let</span> <span class="ident">utxos</span> <span class="op">=</span> <span class="ident">get_test_utxos</span>();
+        <span class="kw">let</span> <span class="ident">database</span> <span class="op">=</span> <span class="ident">MemoryDatabase::default</span>();
+        <span class="kw">let</span> <span class="ident">drain_script</span> <span class="op">=</span> <span class="ident">Script::default</span>();
+
+        <span class="kw">let</span> <span class="ident">err</span> <span class="op">=</span> <span class="ident">BranchAndBoundCoinSelection::default</span>()
+            .<span class="ident">coin_select</span>(
+                <span class="kw-2">&amp;</span><span class="ident">database</span>,
+                <span class="ident">utxos</span>,
+                <span class="macro">vec!</span>[],
+                <span class="ident">FeeRate::from_sat_per_vb</span>(<span class="number">10_000.0</span>),
+                <span class="number">500_000</span>,
+                <span class="kw-2">&amp;</span><span class="ident">drain_script</span>,
+            )
+            .<span class="ident">unwrap_err</span>();
+
+        <span class="macro">assert!</span>(<span class="macro">matches!</span>(
+            <span class="ident">err</span>,
+            <span class="ident">Error::InsufficientFunds</span> {
+                <span class="ident">available</span>: <span class="number">300_010</span>,
+                ..
+            }
+        ));
+    }
 }
 </code></pre></div>
 </section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="bdk" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.60.0-nightly (51126be1b 2022-01-24)" ></div>