Skip to content

fix(bitcoind_rpc): surface RPC error on genesis mismatch - #2365

Open
Mac-5 wants to merge 1 commit into
bitcoindevkit:masterfrom
Mac-5:fix/emitter-genesis-mismatch
Open

Mac-5 wants to merge 1 commit into
bitcoindevkit:masterfrom
Mac-5:fix/emitter-genesis-mismatch

Conversation

@Mac-5

@Mac-5 Mac-5 commented Oct 10, 2026 •

Copy link
Copy Markdown

Description

Fixes #2290.

Emitter silently discarded the RPC "block not found" error when it couldn't find our genesis on the node, then reset to the node's own genesis and kept emitting — so a network mismatch (e.g. mainnet checkpoints vs. a regtest node) produced no error, just a chain that silently stopped connecting to what the caller gave it.

This PR propagates that error instead of swallowing it. No API changes.

Scope: covers the reported case and the common path (last_cp from LocalChain, which always has genesis). Doesn't cover a hand-built sparse CheckPoint with no genesis entry — fixing that needs a breaking EmitterError type, which PR #2244 is already pursuing as part of a larger rewrite; kept this one small and non-breaking on purpose.

Verified: added test_next_block_errors_on_genesis_mismatch (fails pre-fix, passes post-fix against a real regtest node via TestEnv), plus manually confirmed the exact RPC response (error code: -5, "Block not found") against a hand-run regtest bitcoind.

Changelog notice

  • Fixed bdk_bitcoind_rpc's Emitter silently discarding the caller's chain and adopting the R the node doesn't recognize it (e.g. a network mismatch). next_block()/mempool() now returnthe underlying RPC error instead.

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

`Emitter`'s poll loop silently discarded the RPC "block not found" error
when it couldn't locate our chain's genesis on the node, then fabricated
a reset to the node's own genesis and continued emitting. A caller
pointed at a node on a different network (e.g. mainnet checkpoints
against a regtest node) got no error back from `next_block()`, even
though the emitted checkpoints no longer connected to the chain it was
given.

Propagate the original error instead of discarding it, so a genesis
mismatch is reported to the caller rather than silently papered over.

Fixes bitcoindevkit#2290
@Mac-5
Mac-5 requested a review from a team as a code owner October 10, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

Emitter silently replaces the caller’s genesis on a network mismatch

1 participant