]> Untitled Git - bdk/commit
Merge bitcoindevkit/bdk#2380: fix(chain)!: reject changesets that alter the genesis...
authormerge-script <hello@evanlinjin.me>
Mon, 19 Oct 2026 23:45:49 +0000 (10:45 +1100)
committermerge-script <hello@evanlinjin.me>
Mon, 19 Oct 2026 23:45:49 +0000 (10:45 +1100)
commitd4e486a1ff9a18e8441dd0b040ca02a6a2bc8ed5
tree3ebf26703bbbbbfa932a1320a8f2b8ec1e16a984
parent0ff6ade70b9a7c3d3288519aff69a01240794ece
parent7fc1c530fd07a8748509072811dfee2f954a4ed4
Merge bitcoindevkit/bdk#2380: fix(chain)!: reject changesets that alter the genesis block

7fc1c530fd07a8748509072811dfee2f954a4ed4 test(chain): cover `Display` for `ApplyChangeSetError` and `InsertBlockError` (志宇)
ae236638b881894a7f19530ef37f031f3bcfb31a fix(chain)!: report `prev_blockhash` mismatches from `insert_block` (志宇)
4629f55138da1ee946bd49f7332ccbf0cd5af646 fix(chain)!: reject changesets that alter the genesis block (志宇)

Pull request description:

  Fixes #2309. Alternative to #2331.

  ### Description

  `LocalChain::apply_changeset` could replace the genesis block. Genesis is now only checked when the changeset has no point of agreement below it (the only path that reaches height 0), and the chain extends from the existing genesis checkpoint.

  `apply_changeset` returns a new `ApplyChangeSetError` instead of `ApplyBlockError`, since `MissingGenesis` doesn't apply to a chain that already has genesis.

  The second commit fixes `insert_block`, which reported every `prev_blockhash` mismatch as "failed to remove block at height 0". It now returns `InsertBlockError`, and `AlterCheckPointError` is removed.

  ### Changelog notice

  ```
  ### Fixed
  - `LocalChain::apply_changeset` no longer replaces or removes the genesis block. #2309
  - `LocalChain::insert_block` reports `prev_blockhash` mismatches instead of a bogus genesis error.

  ### Changed
  - Breaking: `LocalChain::apply_changeset` returns `ApplyChangeSetError`.
  - Breaking: `LocalChain::insert_block` returns `InsertBlockError`.

  ### Removed
  - Breaking: `AlterCheckPointError`.
  ```

  ### Checklists

  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] This pull request breaks the existing API
  * [x] I've added tests to reproduce the issue which are now passing
  * [x] I'm linking the issue being fixed by this PR

  🤖 Generated with [Claude Code](https://claude.com/claude-code)

ACKs for top commit:
  oleonardolima:
    utACK 7fc1c530fd07a8748509072811dfee2f954a4ed4

Tree-SHA512: b962f455f1376cc55e30ff63384729f72404efa5ea2561dfa9d21e37451b42133c3d66af03f41dd5afe1f7f94b948abe7096bfc4b3b5012f339e66e7532895fb