Skip to content

fix(chain): prevent merge_chains from replacing the genesis block#2174

Open
tnull wants to merge 1 commit intobitcoindevkit:release/chain-0.23.xfrom
tnull:2026-04-genesis-protection
Open

fix(chain): prevent merge_chains from replacing the genesis block#2174
tnull wants to merge 1 commit intobitcoindevkit:release/chain-0.23.xfrom
tnull:2026-04-genesis-protection

Conversation

@tnull
Copy link
Copy Markdown
Contributor

@tnull tnull commented Apr 15, 2026

Description

Other code paths (disconnect_from, CheckPoint::insert) already protect height 0 from modification, but merge_chains allowed an update chain with a different genesis hash to silently replace the wallet's existing genesis block. Return CannotConnectError when the update attempts to change the block hash at height 0.

Co-Authored-By: HAL 9000

Checklists

All Submissions:

Bugfixes:

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

Other code paths (`disconnect_from`, `CheckPoint::insert`) already
protect height 0 from modification, but `merge_chains` allowed an
update chain with a different genesis hash to silently replace the
wallet's existing genesis block. Return `CannotConnectError` when the
update attempts to change the block hash at height 0.

Co-Authored-By: HAL 9000
Signed-off-by: Elias Rohrer <dev@tnull.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant