From 6e3ddc8aa7100664a8ce694f58bf47dc7436a81c Mon Sep 17 00:00:00 2001 From: f3r10 Date: Mon, 27 Jan 2025 14:13:19 -0500 Subject: [PATCH] fix(chain): handle changeset where the index is greater that BIP32_MAX_INDEX --- crates/chain/src/indexer/keychain_txout.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/chain/src/indexer/keychain_txout.rs b/crates/chain/src/indexer/keychain_txout.rs index a3e33415e..4736e958c 100644 --- a/crates/chain/src/indexer/keychain_txout.rs +++ b/crates/chain/src/indexer/keychain_txout.rs @@ -793,7 +793,12 @@ impl KeychainTxOutIndex { pub fn apply_changeset(&mut self, changeset: ChangeSet) { for (&desc_id, &index) in &changeset.last_revealed { let v = self.last_revealed.entry(desc_id).or_default(); - *v = index.max(*v); + let sanitized_index = if index > BIP32_MAX_INDEX { + BIP32_MAX_INDEX + } else { + index + }; + *v = sanitized_index.max(*v); self.replenish_inner_index_did(desc_id, self.lookahead); } }