Skip to content

Commit

Permalink
fix: spks_of_all_keychains() shouldn't return an..
Browse files Browse the repository at this point in the history
..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
```
  • Loading branch information
danielabrozzoni committed Aug 24, 2023
1 parent 6125062 commit ef01631
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/chain/src/keychain/txout_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
.map(|(keychain, descriptor)| {
(
keychain.clone(),
SpkIterator::new_with_range(descriptor.clone(), 0..),
SpkIterator::new(descriptor.clone()),
)
})
.collect()
Expand All @@ -291,7 +291,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
.get(keychain)
.expect("keychain must exist")
.clone();
SpkIterator::new_with_range(descriptor, 0..)
SpkIterator::new(descriptor)
}

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

0 comments on commit ef01631

Please sign in to comment.