beyond the last revealed index. In certain situations, such as when performing an initial
scan of the blockchain during wallet import, it may be uncertain or unknown what the index
of the last revealed script pubkey actually is.</p>
-</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-KeychainTxOutIndex%3CK%3E-1" class="impl has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#136-534">source</a><a href="#impl-KeychainTxOutIndex%3CK%3E-1" class="anchor">§</a><h3 class="code-header">impl<K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>> <a class="struct" href="struct.KeychainTxOutIndex.html" title="struct bdk_chain::keychain::KeychainTxOutIndex">KeychainTxOutIndex</a><K></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.inner" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#138-140">source</a><h4 class="code-header">pub fn <a href="#method.inner" class="fn">inner</a>(&self) -> &<a class="struct" href="../struct.SpkTxOutIndex.html" title="struct bdk_chain::SpkTxOutIndex">SpkTxOutIndex</a><(K, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>)></h4></section></summary><div class="docblock"><p>Return a reference to the internal <a href="../struct.SpkTxOutIndex.html" title="SpkTxOutIndex"><code>SpkTxOutIndex</code></a>.</p>
+</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-KeychainTxOutIndex%3CK%3E-1" class="impl has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#136-530">source</a><a href="#impl-KeychainTxOutIndex%3CK%3E-1" class="anchor">§</a><h3 class="code-header">impl<K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>> <a class="struct" href="struct.KeychainTxOutIndex.html" title="struct bdk_chain::keychain::KeychainTxOutIndex">KeychainTxOutIndex</a><K></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.inner" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#138-140">source</a><h4 class="code-header">pub fn <a href="#method.inner" class="fn">inner</a>(&self) -> &<a class="struct" href="../struct.SpkTxOutIndex.html" title="struct bdk_chain::SpkTxOutIndex">SpkTxOutIndex</a><(K, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>)></h4></section></summary><div class="docblock"><p>Return a reference to the internal <a href="../struct.SpkTxOutIndex.html" title="SpkTxOutIndex"><code>SpkTxOutIndex</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.outpoints" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#143-145">source</a><h4 class="code-header">pub fn <a href="#method.outpoints" class="fn">outpoints</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/set/struct.BTreeSet.html" title="struct alloc::collections::btree::set::BTreeSet">BTreeSet</a><((K, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>), OutPoint)></h4></section></summary><div class="docblock"><p>Get a reference to the set of indexed outpoints.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.keychains" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#148-150">source</a><h4 class="code-header">pub fn <a href="#method.keychains" class="fn">keychains</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html" title="struct alloc::collections::btree::map::BTreeMap">BTreeMap</a><K, Descriptor<DescriptorPublicKey>></h4></section></summary><div class="docblock"><p>Return a reference to the internal map of the keychain to descriptors.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add_keychain" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#160-170">source</a><h4 class="code-header">pub fn <a href="#method.add_keychain" class="fn">add_keychain</a>(<br> &mut self,<br> keychain: K,<br> descriptor: Descriptor<DescriptorPublicKey><br>)</h4></section></summary><div class="docblock"><p>Add a keychain to the tracker’s <code>txout_index</code> with a descriptor to derive addresses.</p>
<p>Refer to <a href="struct.KeychainTxOutIndex.html#method.new"><code>new</code></a> for more information on the <code>lookahead</code>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lookahead_to_target" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#184-189">source</a><h4 class="code-header">pub fn <a href="#method.lookahead_to_target" class="fn">lookahead_to_target</a>(&mut self, keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K, target_index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>)</h4></section></summary><div class="docblock"><p>Store lookahead scripts until <code>target_index</code>.</p>
<p>This does not change the <code>lookahead</code> setting.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.spks_of_all_keychains" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#216-228">source</a><h4 class="code-header">pub fn <a href="#method.spks_of_all_keychains" class="fn">spks_of_all_keychains</a>(<br> &self<br>) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html" title="struct alloc::collections::btree::map::BTreeMap">BTreeMap</a><K, <a class="struct" href="../struct.SpkIterator.html" title="struct bdk_chain::SpkIterator">SpkIterator</a><Descriptor<DescriptorPublicKey>>></h4></section></summary><div class="docblock"><p>Generates script pubkey iterators for every <code>keychain</code>. The iterators iterate over all
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.spks_of_all_keychains" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#218-230">source</a><h4 class="code-header">pub fn <a href="#method.spks_of_all_keychains" class="fn">spks_of_all_keychains</a>(<br> &self<br>) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html" title="struct alloc::collections::btree::map::BTreeMap">BTreeMap</a><K, <a class="struct" href="../struct.SpkIterator.html" title="struct bdk_chain::SpkIterator">SpkIterator</a><Descriptor<DescriptorPublicKey>>></h4></section></summary><div class="docblock"><p>Generates script pubkey iterators for every <code>keychain</code>. The iterators iterate over all
derivable script pubkeys.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.spks_of_keychain" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#236-243">source</a><h4 class="code-header">pub fn <a href="#method.spks_of_keychain" class="fn">spks_of_keychain</a>(<br> &self,<br> keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K<br>) -> <a class="struct" href="../struct.SpkIterator.html" title="struct bdk_chain::SpkIterator">SpkIterator</a><Descriptor<DescriptorPublicKey>> <a href="#" class="notable-traits" data-ty="SpkIterator<Descriptor<DescriptorPublicKey>>">ⓘ</a></h4></section></summary><div class="docblock"><p>Generates a script pubkey iterator for the given <code>keychain</code>’s descriptor (if it exists). The
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.spks_of_keychain" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#238-245">source</a><h4 class="code-header">pub fn <a href="#method.spks_of_keychain" class="fn">spks_of_keychain</a>(<br> &self,<br> keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K<br>) -> <a class="struct" href="../struct.SpkIterator.html" title="struct bdk_chain::SpkIterator">SpkIterator</a><Descriptor<DescriptorPublicKey>> <a href="#" class="notable-traits" data-ty="SpkIterator<Descriptor<DescriptorPublicKey>>">ⓘ</a></h4></section></summary><div class="docblock"><p>Generates a script pubkey iterator for the given <code>keychain</code>’s descriptor (if it exists). The
iterator iterates over all derivable scripts of the keychain’s descriptor.</p>
<h5 id="panics-1"><a href="#panics-1">Panics</a></h5>
<p>This will panic if the <code>keychain</code> does not exist.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.revealed_spks_of_all_keychains" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#248-255">source</a><h4 class="code-header">pub fn <a href="#method.revealed_spks_of_all_keychains" class="fn">revealed_spks_of_all_keychains</a>(<br> &self<br>) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html" title="struct alloc::collections::btree::map::BTreeMap">BTreeMap</a><K, impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a><Item = (<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, &Script)> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>></h4></section></summary><div class="docblock"><p>Convenience method to get <a href="struct.KeychainTxOutIndex.html#method.revealed_spks_of_keychain"><code>revealed_spks_of_keychain</code></a> of all keychains.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.revealed_spks_of_keychain" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#258-267">source</a><h4 class="code-header">pub fn <a href="#method.revealed_spks_of_keychain" class="fn">revealed_spks_of_keychain</a>(<br> &self,<br> keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K<br>) -> impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/double_ended/trait.DoubleEndedIterator.html" title="trait core::iter::traits::double_ended::DoubleEndedIterator">DoubleEndedIterator</a><Item = (<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, &Script)> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a></h4></section></summary><div class="docblock"><p>Iterates over the script pubkeys revealed by this index under <code>keychain</code>.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.next_index" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#283-303">source</a><h4 class="code-header">pub fn <a href="#method.next_index" class="fn">next_index</a>(&self, keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K) -> (<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>)</h4></section></summary><div class="docblock"><p>Get the next derivation index for <code>keychain</code>. The next index is the index after the last revealed
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.revealed_spks_of_all_keychains" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#250-257">source</a><h4 class="code-header">pub fn <a href="#method.revealed_spks_of_all_keychains" class="fn">revealed_spks_of_all_keychains</a>(<br> &self<br>) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html" title="struct alloc::collections::btree::map::BTreeMap">BTreeMap</a><K, impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a><Item = (<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, &Script)> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>></h4></section></summary><div class="docblock"><p>Convenience method to get <a href="struct.KeychainTxOutIndex.html#method.revealed_spks_of_keychain"><code>revealed_spks_of_keychain</code></a> of all keychains.</p>
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.revealed_spks_of_keychain" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#260-269">source</a><h4 class="code-header">pub fn <a href="#method.revealed_spks_of_keychain" class="fn">revealed_spks_of_keychain</a>(<br> &self,<br> keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K<br>) -> impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/double_ended/trait.DoubleEndedIterator.html" title="trait core::iter::traits::double_ended::DoubleEndedIterator">DoubleEndedIterator</a><Item = (<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, &Script)> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a></h4></section></summary><div class="docblock"><p>Iterates over the script pubkeys revealed by this index under <code>keychain</code>.</p>
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.next_index" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#285-305">source</a><h4 class="code-header">pub fn <a href="#method.next_index" class="fn">next_index</a>(&self, keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K) -> (<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>)</h4></section></summary><div class="docblock"><p>Get the next derivation index for <code>keychain</code>. The next index is the index after the last revealed
derivation index.</p>
<p>The second field in the returned tuple represents whether the next derivation index is new.
There are two scenarios where the next derivation index is reused (not new):</p>
<p>Not checking the second field of the tuple may result in address reuse.</p>
<h5 id="panics-2"><a href="#panics-2">Panics</a></h5>
<p>Panics if the <code>keychain</code> does not exist.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.last_revealed_indices" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#308-310">source</a><h4 class="code-header">pub fn <a href="#method.last_revealed_indices" class="fn">last_revealed_indices</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html" title="struct alloc::collections::btree::map::BTreeMap">BTreeMap</a><K, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the last derivation index that is revealed for each keychain.</p>
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.last_revealed_indices" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#310-312">source</a><h4 class="code-header">pub fn <a href="#method.last_revealed_indices" class="fn">last_revealed_indices</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html" title="struct alloc::collections::btree::map::BTreeMap">BTreeMap</a><K, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the last derivation index that is revealed for each keychain.</p>
<p>Keychains with no revealed indices will not be included in the returned <a href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html" title="BTreeMap"><code>BTreeMap</code></a>.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.last_revealed_index" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#313-315">source</a><h4 class="code-header">pub fn <a href="#method.last_revealed_index" class="fn">last_revealed_index</a>(&self, keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the last derivation index revealed for <code>keychain</code>.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.reveal_to_target_multi" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#318-337">source</a><h4 class="code-header">pub fn <a href="#method.reveal_to_target_multi" class="fn">reveal_to_target_multi</a>(<br> &mut self,<br> keychains: &<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html" title="struct alloc::collections::btree::map::BTreeMap">BTreeMap</a><K, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>><br>) -> (<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html" title="struct alloc::collections::btree::map::BTreeMap">BTreeMap</a><K, <a class="struct" href="../struct.SpkIterator.html" title="struct bdk_chain::SpkIterator">SpkIterator</a><Descriptor<DescriptorPublicKey>>>, <a class="struct" href="struct.ChangeSet.html" title="struct bdk_chain::keychain::ChangeSet">ChangeSet</a><K>)</h4></section></summary><div class="docblock"><p>Convenience method to call <a href="struct.KeychainTxOutIndex.html#method.reveal_to_target" title="Self::reveal_to_target"><code>Self::reveal_to_target</code></a> on multiple keychains.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.reveal_to_target" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#353-410">source</a><h4 class="code-header">pub fn <a href="#method.reveal_to_target" class="fn">reveal_to_target</a>(<br> &mut self,<br> keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K,<br> target_index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><br>) -> (<a class="struct" href="../struct.SpkIterator.html" title="struct bdk_chain::SpkIterator">SpkIterator</a><Descriptor<DescriptorPublicKey>>, <a class="struct" href="struct.ChangeSet.html" title="struct bdk_chain::keychain::ChangeSet">ChangeSet</a><K>)</h4></section></summary><div class="docblock"><p>Reveals script pubkeys of the <code>keychain</code>’s descriptor <strong>up to and including</strong> the
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.last_revealed_index" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#315-317">source</a><h4 class="code-header">pub fn <a href="#method.last_revealed_index" class="fn">last_revealed_index</a>(&self, keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the last derivation index revealed for <code>keychain</code>.</p>
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.reveal_to_target_multi" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#320-339">source</a><h4 class="code-header">pub fn <a href="#method.reveal_to_target_multi" class="fn">reveal_to_target_multi</a>(<br> &mut self,<br> keychains: &<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html" title="struct alloc::collections::btree::map::BTreeMap">BTreeMap</a><K, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>><br>) -> (<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html" title="struct alloc::collections::btree::map::BTreeMap">BTreeMap</a><K, <a class="struct" href="../struct.SpkIterator.html" title="struct bdk_chain::SpkIterator">SpkIterator</a><Descriptor<DescriptorPublicKey>>>, <a class="struct" href="struct.ChangeSet.html" title="struct bdk_chain::keychain::ChangeSet">ChangeSet</a><K>)</h4></section></summary><div class="docblock"><p>Convenience method to call <a href="struct.KeychainTxOutIndex.html#method.reveal_to_target" title="Self::reveal_to_target"><code>Self::reveal_to_target</code></a> on multiple keychains.</p>
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.reveal_to_target" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#355-406">source</a><h4 class="code-header">pub fn <a href="#method.reveal_to_target" class="fn">reveal_to_target</a>(<br> &mut self,<br> keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K,<br> target_index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><br>) -> (<a class="struct" href="../struct.SpkIterator.html" title="struct bdk_chain::SpkIterator">SpkIterator</a><Descriptor<DescriptorPublicKey>>, <a class="struct" href="struct.ChangeSet.html" title="struct bdk_chain::keychain::ChangeSet">ChangeSet</a><K>)</h4></section></summary><div class="docblock"><p>Reveals script pubkeys of the <code>keychain</code>’s descriptor <strong>up to and including</strong> the
<code>target_index</code>.</p>
<p>If the <code>target_index</code> cannot be reached (due to the descriptor having no wildcard and/or
the <code>target_index</code> is in the hardened index range), this method will make a best-effort and
pubkeys are revealed, then both of these will be empty.</p>
<h5 id="panics-3"><a href="#panics-3">Panics</a></h5>
<p>Panics if <code>keychain</code> does not exist.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.reveal_next_spk" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#426-434">source</a><h4 class="code-header">pub fn <a href="#method.reveal_next_spk" class="fn">reveal_next_spk</a>(&mut self, keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K) -> ((<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, &Script), <a class="struct" href="struct.ChangeSet.html" title="struct bdk_chain::keychain::ChangeSet">ChangeSet</a><K>)</h4></section></summary><div class="docblock"><p>Attempts to reveal the next script pubkey for <code>keychain</code>.</p>
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.reveal_next_spk" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#422-430">source</a><h4 class="code-header">pub fn <a href="#method.reveal_next_spk" class="fn">reveal_next_spk</a>(&mut self, keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K) -> ((<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, &Script), <a class="struct" href="struct.ChangeSet.html" title="struct bdk_chain::keychain::ChangeSet">ChangeSet</a><K>)</h4></section></summary><div class="docblock"><p>Attempts to reveal the next script pubkey for <code>keychain</code>.</p>
<p>Returns the derivation index of the revealed script pubkey, the revealed script pubkey and a
<a href="struct.ChangeSet.html" title="super::ChangeSet"><code>super::ChangeSet</code></a> which represents changes in the last revealed index (if any).</p>
<p>When a new script cannot be revealed, we return the last revealed script and an empty
</ol>
<h5 id="panics-4"><a href="#panics-4">Panics</a></h5>
<p>Panics if the <code>keychain</code> does not exist.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.next_unused_spk" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#448-461">source</a><h4 class="code-header">pub fn <a href="#method.next_unused_spk" class="fn">next_unused_spk</a>(&mut self, keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K) -> ((<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, &Script), <a class="struct" href="struct.ChangeSet.html" title="struct bdk_chain::keychain::ChangeSet">ChangeSet</a><K>)</h4></section></summary><div class="docblock"><p>Gets the next unused script pubkey in the keychain. I.e., the script pubkey with the lowest
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.next_unused_spk" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#444-457">source</a><h4 class="code-header">pub fn <a href="#method.next_unused_spk" class="fn">next_unused_spk</a>(&mut self, keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K) -> ((<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, &Script), <a class="struct" href="struct.ChangeSet.html" title="struct bdk_chain::keychain::ChangeSet">ChangeSet</a><K>)</h4></section></summary><div class="docblock"><p>Gets the next unused script pubkey in the keychain. I.e., the script pubkey with the lowest
index that has not been used yet.</p>
<p>This will derive and reveal a new script pubkey if no more unused script pubkeys exist.</p>
<p>If the descriptor has no wildcard and already has a used script pubkey or if a descriptor
returned.</p>
<h5 id="panics-5"><a href="#panics-5">Panics</a></h5>
<p>Panics if <code>keychain</code> has never been added to the index</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.mark_used" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#473-475">source</a><h4 class="code-header">pub fn <a href="#method.mark_used" class="fn">mark_used</a>(&mut self, keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K, index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Marks the script pubkey at <code>index</code> as used even though the tracker hasn’t seen an output with it.
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.mark_used" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#469-471">source</a><h4 class="code-header">pub fn <a href="#method.mark_used" class="fn">mark_used</a>(&mut self, keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K, index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Marks the script pubkey at <code>index</code> as used even though the tracker hasn’t seen an output with it.
This only has an effect when the <code>index</code> had been added to <code>self</code> already and was unused.</p>
<p>Returns whether the <code>index</code> was initially present as <code>unused</code>.</p>
<p>This is useful when you want to reserve a script pubkey for something but don’t want to add
the transaction output using it to the index yet. Other callers will consider <code>index</code> on
<code>keychain</code> used until you call <a href="struct.KeychainTxOutIndex.html#method.unmark_used"><code>unmark_used</code></a>.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.unmark_used" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#484-486">source</a><h4 class="code-header">pub fn <a href="#method.unmark_used" class="fn">unmark_used</a>(&mut self, keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K, index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Undoes the effect of <a href="struct.KeychainTxOutIndex.html#method.mark_used"><code>mark_used</code></a>. Returns whether the <code>index</code> is inserted back into
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.unmark_used" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#480-482">source</a><h4 class="code-header">pub fn <a href="#method.unmark_used" class="fn">unmark_used</a>(&mut self, keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K, index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Undoes the effect of <a href="struct.KeychainTxOutIndex.html#method.mark_used"><code>mark_used</code></a>. Returns whether the <code>index</code> is inserted back into
<code>unused</code>.</p>
<p>Note that if <code>self</code> has scanned an output with this script pubkey, then this will have no
effect.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.unused_spks_of_keychain" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#489-498">source</a><h4 class="code-header">pub fn <a href="#method.unused_spks_of_keychain" class="fn">unused_spks_of_keychain</a>(<br> &self,<br> keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K<br>) -> impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/double_ended/trait.DoubleEndedIterator.html" title="trait core::iter::traits::double_ended::DoubleEndedIterator">DoubleEndedIterator</a><Item = (<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, &Script)></h4></section></summary><div class="docblock"><p>Iterates over all unused script pubkeys for a <code>keychain</code> stored in the index.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.txouts_of_keychain" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#502-509">source</a><h4 class="code-header">pub fn <a href="#method.txouts_of_keychain" class="fn">txouts_of_keychain</a>(<br> &self,<br> keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K<br>) -> impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/double_ended/trait.DoubleEndedIterator.html" title="trait core::iter::traits::double_ended::DoubleEndedIterator">DoubleEndedIterator</a><Item = (<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, OutPoint)> + '_</h4></section></summary><div class="docblock"><p>Iterates over all the [<code>OutPoint</code>] that have a <code>TxOut</code> with a script pubkey derived from
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.unused_spks_of_keychain" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#485-494">source</a><h4 class="code-header">pub fn <a href="#method.unused_spks_of_keychain" class="fn">unused_spks_of_keychain</a>(<br> &self,<br> keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K<br>) -> impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/double_ended/trait.DoubleEndedIterator.html" title="trait core::iter::traits::double_ended::DoubleEndedIterator">DoubleEndedIterator</a><Item = (<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, &Script)></h4></section></summary><div class="docblock"><p>Iterates over all unused script pubkeys for a <code>keychain</code> stored in the index.</p>
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.txouts_of_keychain" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#498-505">source</a><h4 class="code-header">pub fn <a href="#method.txouts_of_keychain" class="fn">txouts_of_keychain</a>(<br> &self,<br> keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K<br>) -> impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/double_ended/trait.DoubleEndedIterator.html" title="trait core::iter::traits::double_ended::DoubleEndedIterator">DoubleEndedIterator</a><Item = (<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, OutPoint)> + '_</h4></section></summary><div class="docblock"><p>Iterates over all the [<code>OutPoint</code>] that have a <code>TxOut</code> with a script pubkey derived from
<code>keychain</code>.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.last_used_index" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#513-515">source</a><h4 class="code-header">pub fn <a href="#method.last_used_index" class="fn">last_used_index</a>(&self, keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Returns the highest derivation index of the <code>keychain</code> where <a href="struct.KeychainTxOutIndex.html" title="KeychainTxOutIndex"><code>KeychainTxOutIndex</code></a> has
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.last_used_index" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#509-511">source</a><h4 class="code-header">pub fn <a href="#method.last_used_index" class="fn">last_used_index</a>(&self, keychain: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Returns the highest derivation index of the <code>keychain</code> where <a href="struct.KeychainTxOutIndex.html" title="KeychainTxOutIndex"><code>KeychainTxOutIndex</code></a> has
found a [<code>TxOut</code>] with it’s script pubkey.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.last_used_indices" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#519-527">source</a><h4 class="code-header">pub fn <a href="#method.last_used_indices" class="fn">last_used_indices</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html" title="struct alloc::collections::btree::map::BTreeMap">BTreeMap</a><K, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Returns the highest derivation index of each keychain that <a href="struct.KeychainTxOutIndex.html" title="KeychainTxOutIndex"><code>KeychainTxOutIndex</code></a> has found
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.last_used_indices" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#515-523">source</a><h4 class="code-header">pub fn <a href="#method.last_used_indices" class="fn">last_used_indices</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html" title="struct alloc::collections::btree::map::BTreeMap">BTreeMap</a><K, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Returns the highest derivation index of each keychain that <a href="struct.KeychainTxOutIndex.html" title="KeychainTxOutIndex"><code>KeychainTxOutIndex</code></a> has found
a [<code>TxOut</code>] with it’s script pubkey.</p>
-</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.apply_changeset" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#531-533">source</a><h4 class="code-header">pub fn <a href="#method.apply_changeset" class="fn">apply_changeset</a>(&mut self, changeset: <a class="struct" href="struct.ChangeSet.html" title="struct bdk_chain::keychain::ChangeSet">ChangeSet</a><K>)</h4></section></summary><div class="docblock"><p>Applies the derivation changeset to the <a href="struct.KeychainTxOutIndex.html" title="KeychainTxOutIndex"><code>KeychainTxOutIndex</code></a>, extending the number of
+</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.apply_changeset" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/keychain/txout_index.rs.html#527-529">source</a><h4 class="code-header">pub fn <a href="#method.apply_changeset" class="fn">apply_changeset</a>(&mut self, changeset: <a class="struct" href="struct.ChangeSet.html" title="struct bdk_chain::keychain::ChangeSet">ChangeSet</a><K>)</h4></section></summary><div class="docblock"><p>Applies the derivation changeset to the <a href="struct.KeychainTxOutIndex.html" title="KeychainTxOutIndex"><code>KeychainTxOutIndex</code></a>, extending the number of
derived scripts per keychain, as specified in the <code>changeset</code>.</p>
</div></details></div></details></div><h2 id="deref-methods-SpkTxOutIndex%3C(K%2C%20u32)%3E" class="small-section-header"><span>Methods from <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a><Target = <a class="struct" href="../struct.SpkTxOutIndex.html" title="struct bdk_chain::SpkTxOutIndex">SpkTxOutIndex</a><(K, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>)>></span><a href="#deref-methods-SpkTxOutIndex%3C(K%2C%20u32)%3E" class="anchor">§</a></h2><div id="deref-methods-SpkTxOutIndex%3C(K%2C%20u32)%3E-1"><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.outpoints-1" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/spk_txout_index.rs.html#113-115">source</a><h4 class="code-header">pub fn <a href="#method.outpoints-1" class="fn">outpoints</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/set/struct.BTreeSet.html" title="struct alloc::collections::btree::set::BTreeSet">BTreeSet</a><(I, OutPoint)></h4></section></summary><div class="docblock"><p>Get a reference to the set of indexed outpoints.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.txouts" class="method has-srclink"><a class="srclink rightside" href="../../src/bdk_chain/spk_txout_index.rs.html#118-124">source</a><h4 class="code-header">pub fn <a href="#method.txouts" class="fn">txouts</a>(<br> &self<br>) -> impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/double_ended/trait.DoubleEndedIterator.html" title="trait core::iter::traits::double_ended::DoubleEndedIterator">DoubleEndedIterator</a><Item = (<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>I, OutPoint, &TxOut)> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/exact_size/trait.ExactSizeIterator.html" title="trait core::iter::traits::exact_size::ExactSizeIterator">ExactSizeIterator</a></h4></section></summary><div class="docblock"><p>Iterate over all known txouts that spend to tracked script pubkeys.</p>
<a href="#528" id="528">528</a>
<a href="#529" id="529">529</a>
<a href="#530" id="530">530</a>
-<a href="#531" id="531">531</a>
-<a href="#532" id="532">532</a>
-<a href="#533" id="533">533</a>
-<a href="#534" id="534">534</a>
</pre><pre class="rust"><code><span class="kw">use crate</span>::{
collections::<span class="kw-2">*</span>,
indexed_tx_graph::Indexer,
<span class="kw">fn </span>next_store_index(<span class="kw-2">&</span><span class="self">self</span>, keychain: <span class="kw-2">&</span>K) -> u32 {
<span class="self">self</span>.inner()
.all_spks()
- .range((keychain.clone(), u32::MIN)..(keychain.clone(), u32::MAX))
+ <span class="comment">// This range is filtering out the spks with a keychain different than
+ // `keychain`. We don't use filter here as range is more optimized.
+ </span>.range((keychain.clone(), u32::MIN)..(keychain.clone(), u32::MAX))
.last()
- .map_or(<span class="number">0</span>, |((<span class="kw">_</span>, v), <span class="kw">_</span>)| <span class="kw-2">*</span>v + <span class="number">1</span>)
+ .map_or(<span class="number">0</span>, |((<span class="kw">_</span>, index), <span class="kw">_</span>)| <span class="kw-2">*</span>index + <span class="number">1</span>)
}
<span class="doccomment">/// Generates script pubkey iterators for every `keychain`. The iterators iterate over all
<span class="kw">let </span>has_wildcard = descriptor.has_wildcard();
<span class="kw">let </span>target_index = <span class="kw">if </span>has_wildcard { target_index } <span class="kw">else </span>{ <span class="number">0 </span>};
- <span class="kw">let </span>next_reveal_index = <span class="self">self</span>.last_revealed.get(keychain).map_or(<span class="number">0</span>, |v| <span class="kw-2">*</span>v + <span class="number">1</span>);
+ <span class="kw">let </span>next_reveal_index = <span class="self">self
+ </span>.last_revealed
+ .get(keychain)
+ .map_or(<span class="number">0</span>, |index| <span class="kw-2">*</span>index + <span class="number">1</span>);
<span class="macro">debug_assert!</span>(next_reveal_index + <span class="self">self</span>.lookahead >= <span class="self">self</span>.next_store_index(keychain));
- <span class="comment">// if we need to reveal new indices, the latest revealed index goes here
- </span><span class="kw">let </span><span class="kw-2">mut </span>reveal_to_index = <span class="prelude-val">None</span>;
-
- <span class="comment">// if the target is not yet revealed, but is already stored (due to lookahead), we need to
- // set the `reveal_to_index` as target here (as the `for` loop below only updates
- // `reveal_to_index` for indexes that are NOT stored)
- </span><span class="kw">if </span>next_reveal_index <= target_index && target_index < next_reveal_index + <span class="self">self</span>.lookahead {
- reveal_to_index = <span class="prelude-val">Some</span>(target_index);
+ <span class="comment">// If the target_index is already revealed, we are done
+ </span><span class="kw">if </span>next_reveal_index > target_index {
+ <span class="kw">return </span>(
+ SpkIterator::new_with_range(
+ descriptor.clone(),
+ next_reveal_index..next_reveal_index,
+ ),
+ <span class="kw">super</span>::ChangeSet::default(),
+ );
}
- <span class="comment">// we range over indexes that are not stored
+ <span class="comment">// We range over the indexes that are not stored and insert their spks in the index.
+ // Indexes from next_reveal_index to next_reveal_index + lookahead are already stored (due
+ // to lookahead), so we only range from next_reveal_index + lookahead to target + lookahead
</span><span class="kw">let </span>range = next_reveal_index + <span class="self">self</span>.lookahead..=target_index + <span class="self">self</span>.lookahead;
<span class="kw">for </span>(new_index, new_spk) <span class="kw">in </span>SpkIterator::new_with_range(descriptor, range) {
<span class="kw">let </span>_inserted = <span class="self">self
</span>.inner
.insert_spk((keychain.clone(), new_index), new_spk);
- <span class="macro">debug_assert!</span>(_inserted, <span class="string">"must not have existing spk"</span>,);
-
- <span class="comment">// everything after `target_index` is stored for lookahead only
- </span><span class="kw">if </span>new_index <= target_index {
- reveal_to_index = <span class="prelude-val">Some</span>(new_index);
- }
+ <span class="macro">debug_assert!</span>(_inserted, <span class="string">"must not have existing spk"</span>);
+ <span class="macro">debug_assert!</span>(
+ has_wildcard || new_index == <span class="number">0</span>,
+ <span class="string">"non-wildcard descriptors must not iterate past index 0"
+ </span>);
}
- <span class="kw">match </span>reveal_to_index {
- <span class="prelude-val">Some</span>(index) => {
- <span class="kw">let </span>_old_index = <span class="self">self</span>.last_revealed.insert(keychain.clone(), index);
- <span class="macro">debug_assert!</span>(_old_index < <span class="prelude-val">Some</span>(index));
- (
- SpkIterator::new_with_range(descriptor.clone(), next_reveal_index..index + <span class="number">1</span>),
- <span class="kw">super</span>::ChangeSet(core::iter::once((keychain.clone(), index)).collect()),
- )
- }
- <span class="prelude-val">None </span>=> (
- SpkIterator::new_with_range(
- descriptor.clone(),
- next_reveal_index..next_reveal_index,
- ),
- <span class="kw">super</span>::ChangeSet::default(),
- ),
- }
+ <span class="kw">let </span>_old_index = <span class="self">self</span>.last_revealed.insert(keychain.clone(), target_index);
+ <span class="macro">debug_assert!</span>(_old_index < <span class="prelude-val">Some</span>(target_index));
+ (
+ SpkIterator::new_with_range(descriptor.clone(), next_reveal_index..target_index + <span class="number">1</span>),
+ <span class="kw">super</span>::ChangeSet(core::iter::once((keychain.clone(), target_index)).collect()),
+ )
}
<span class="doccomment">/// Attempts to reveal the next script pubkey for `keychain`.