]> Untitled Git - bdk/commit
Merge bitcoindevkit/bdk#2334: fix(electrum): error on batch response length mismatch master github/master
authormerge-script <hello@evanlinjin.me>
Sun, 18 Oct 2026 13:37:17 +0000 (00:37 +1100)
committermerge-script <hello@evanlinjin.me>
Sun, 18 Oct 2026 13:37:17 +0000 (00:37 +1100)
commit841b427e6217b794051ff57ebc4f514dffa5f426
treee70e82af18f5e8de876108e34df0b139003c1485
parent007d4e8ba56895206d617b2203a483e073171571
parent3f6c74cd25a055d86f8dbffdcad3703e55e18595
Merge bitcoindevkit/bdk#2334: fix(electrum): error on batch response length mismatch

3f6c74cd25a055d86f8dbffdcad3703e55e18595 fix(electrum): check batch response lengths before pairing (Brijesh-Thakkar)

Pull request description:

  ### Description

  `BdkElectrumClient` pairs each batch request with its response using `zip`, without checking that the lengths match. With a short response, trailing scripts, txids and anchors are silently dropped while `sync` returns `Ok`. A short `batch_block_header` response makes `height_to_hash[&h]` panic.

  This adds a `check_batch_len` helper, called after each of the five batch calls. It returns `Error::Message` on a length mismatch. No public API changes.

  Fixes #2305

  ### Notes to the reviewers

  The stock `electrum_client::Client` can't return a short batch (its `batch_call` waits for every request id), so this only hardens custom `ElectrumApi` implementations. No tests: a mock `ElectrumApi` takes ~180 lines of stubs to guard five one-line checks.

  This issue was found by AI, and I used Claude Code to assist with this PR.

  ### Changelog notice

  Fixed: `bdk_electrum` returns an error instead of silently truncating results or panicking when an Electrum batch response length doesn't match the request.

  ### Checklists

  #### All Submissions:

  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)

  #### Bugfixes:

  * [ ] This pull request breaks the existing API
  * [ ] I've added tests to reproduce the issue which are now passing
  * [x] I'm linking the issue being fixed by this PR

ACKs for top commit:
  evanlinjin:
    ACK 3f6c74cd25a055d86f8dbffdcad3703e55e18595

Tree-SHA512: 19dc656dd5635b4209e974d2025fc42c39b0ac09c40beddcf7d51872d953ae209dccc9fb912f2809ac911670f1eaa53f809db7c9032235f3a654efd179e4e4f2