]> Untitled Git - bdk/commitdiff
feat(chain): debug_assert non-wildcard desc. to only cache index 0
author志宇 <hello@evanlinjin.me>
Tue, 9 Jan 2024 01:44:06 +0000 (09:44 +0800)
committerDaniela Brozzoni <danielabrozzoni@protonmail.com>
Wed, 10 Jan 2024 21:47:53 +0000 (22:47 +0100)
crates/chain/src/keychain/txout_index.rs

index 5c9eb08475b3e4a5a4d0eb9414861a5f633cb1e0..a8955b8a981d3dacc182956e183da6d40282a354 100644 (file)
@@ -390,7 +390,11 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
             let _inserted = self
                 .inner
                 .insert_spk((keychain.clone(), new_index), new_spk);
-            debug_assert!(_inserted, "must not have existing spk",);
+            debug_assert!(_inserted, "must not have existing spk");
+            debug_assert!(
+                has_wildcard || new_index == 0,
+                "non-wildcard descriptors must not iterate past index 0"
+            );
         }
 
         let _old_index = self.last_revealed.insert(keychain.clone(), target_index);