]> Untitled Git - bdk/commit
fix: SpkIterator::new_with_range takes wildcards..
authorDaniela Brozzoni <danielabrozzoni@protonmail.com>
Thu, 24 Aug 2023 14:53:50 +0000 (16:53 +0200)
committerDaniela Brozzoni <danielabrozzoni@protonmail.com>
Thu, 31 Aug 2023 14:48:20 +0000 (16:48 +0200)
commitcc1a43c495639f0dbe6da52501cb48f17b8cbbd2
treec3aa5ad6afb0f4c73eb7f77e5506fb47fce6aa07
parent93e8eaf7ee950d988abf994916d78ee3192f14ed
fix: SpkIterator::new_with_range takes wildcards..
..into account

When you pass a non-wildcard descriptor in `new_with_range`, we make
sure that the range length is at most 1; if that's not the case, we
shorten it.
We would previously use `new_with_range` without this check and with a
non-wildcard descriptor in `spks_of_all_keychains`, this meant creating
a spkiterator that would go on producing the same spks over and over
again, causing some issues with syncing on electrum/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
```
crates/chain/src/spk_iter.rs
crates/chain/tests/test_keychain_txout_index.rs