Skip to content

Commit b827359

Browse files
fix: spks_of_all_keychains() shouldn't return an..
..infinite iterator for non-wildcard descriptors We would previously use `new_with_range`, which didn't check if the descriptor had a wildcard or not. This meant that for non-wildcard descriptors we created a spkiterator that would go on producing the same spk over and over again; this caused some scanning issues with electrum and esplora. To reproduce the bug, run in `example-crates/example_electrum`: ``` cargo run "sh(wsh(or_d(c:pk_k(cPGudvRLDSgeV4hH9NUofLvYxYBSRjju3cpiXmBg9K8G9k1ikCMp),c:pk_k(cSBSBHRrzqSXFmrBhLkZMzQB9q4P9MnAq92v8d9a5UveBc9sLX32))))#zp9pcfs9" scan ```
1 parent 6125062 commit b827359

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

crates/chain/src/keychain/txout_index.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
270270
) -> BTreeMap<K, SpkIterator<Descriptor<DescriptorPublicKey>>> {
271271
self.keychains
272272
.iter()
273-
.map(|(keychain, descriptor)| {
274-
(
275-
keychain.clone(),
276-
SpkIterator::new_with_range(descriptor.clone(), 0..),
277-
)
278-
})
273+
.map(|(keychain, descriptor)| (keychain.clone(), SpkIterator::new(descriptor.clone())))
279274
.collect()
280275
}
281276

@@ -291,7 +286,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
291286
.get(keychain)
292287
.expect("keychain must exist")
293288
.clone();
294-
SpkIterator::new_with_range(descriptor, 0..)
289+
SpkIterator::new(descriptor)
295290
}
296291

297292
/// Convenience method to get [`revealed_spks_of_keychain`] of all keychains.

0 commit comments

Comments
 (0)