Merge bitcoindevkit/bdk#2320: fix(electrum): refresh header cache with headers fetched for the chain update
6c5e9771814fe07fe13b1a401d06b7cc7b420cd7 test(electrum): cover tx re-mined at the same height after a reorg (志宇)
b4343702e7da3f3d634559b5cbdb12dbe419c94f fix(electrum): refresh header cache with headers fetched for the chain update (志宇)
Pull request description:
### Description
Forward-port of #2319 to `master`.
`block_header_cache` was only written by `batch_fetch_anchors`, so after a reorg it kept the pre-reorg header for that height. A tx re-mined at the same height then hit the anchor cache under the stale block hash, skipped proof validation, and was never re-anchored to the replacement block. This happens even for a 1-block reorg.
`fetch_tip_and_latest_blocks` now writes the headers it fetches (the chain suffix and the agreement-walk checkpoints) into the header cache.
### Notes to the reviewers
Only differences from #2319: the `fetch_tip_and_latest_blocks` signature keeps master's `CheckPoint<BlockHash>`, and the test uses master's `TestEnv` / `LocalChain` APIs. The test fails on `master` without the fix.
Related: #2312.
### Changelog notice
- Fixed `bdk_electrum` returning a stale anchor for a transaction re-mined at the same height after a reorg.
### 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
* [x] I've added tests to reproduce the issue which are now passing
* [ ] I'm linking the issue being fixed by this PR
🤖 Generated with [Claude Code](https://claude.com/claude-code)
ACKs for top commit:
noahjoeris:
tACK
6c5e9771814fe07fe13b1a401d06b7cc7b420cd7
Tree-SHA512: 9e9aa3c654a9898dfefa27acf99de13a7563802d7d22577437cf8ac064542074e8ee893646b1f22580da9cccfd444be7bdd348bcc4b760f5991d00cca1d41eee