]> Untitled Git - bdk/commit
fix(electrum): check batch response lengths before pairing
authorBrijesh-Thakkar <brijeshthakkariitian5126@gmail.com>
Wed, 30 Sep 2026 19:21:08 +0000 (00:51 +0530)
committer志宇 <hello@evanlinjin.me>
Sun, 18 Oct 2026 13:11:41 +0000 (00:11 +1100)
commit3f6c74cd25a055d86f8dbffdcad3703e55e18595
treee70e82af18f5e8de876108e34df0b139003c1485
parent007d4e8ba56895206d617b2203a483e073171571
fix(electrum): check batch response lengths before pairing

`BdkElectrumClient` paired every batch request with its response via
`zip` without checking that the response had one entry per request. A
short response (possible with any non-stock `ElectrumApi` implementation)
silently dropped trailing scripts, txids and anchors while `sync` still
returned `Ok`, and a short `batch_block_header` response left
`height_to_hash` incomplete so `height_to_hash[&h]` panicked.

Add `check_batch_len` and call it after each of the five batch calls
(`batch_script_get_history` x3, `batch_block_header`,
`batch_transaction_get_merkle`), returning `Error::Message` on any
length mismatch, in line with the other server-misbehaviour checks in
this crate.

Fixes #2305
crates/electrum/src/bdk_electrum_client.rs