Skip to content

txdb: handle malformed first coin cursor key - #35248

Closed
CruzMolina wants to merge 1 commit into
bitcoin:masterfrom
CruzMolina:txdb-cursor-malformed-key
Closed

CruzMolina wants to merge 1 commit into
bitcoin:masterfrom
CruzMolina:txdb-cursor-malformed-key

Conversation

@CruzMolina

Copy link
Copy Markdown

Motivation

CCoinsViewDB::Cursor() caches the first coin key after seeking to the coin
prefix. It checked that the underlying LevelDB iterator was valid, but ignored
whether deserializing the first key succeeded.

CCoinsViewDBCursor::Next() already treats a failed key decode as an invalid
cursor. The initial cursor setup should do the same.

Change

Make CCoinsViewDB::Cursor() mark the cursor invalid if the first key cannot
be decoded.

Add a regression test covering a malformed first coin key.

Test

cmake --build build --target test_bitcoin
build/bin/test_bitcoin --run_test=coins_tests_dbbase

CCoinsViewDB::Cursor() caches the first coin key after seeking to the coin prefix. It checked that the underlying LevelDB iterator was valid, but ignored whether deserializing the key succeeded.

CCoinsViewDBCursor::Next() already treats a failed key decode as an invalid cursor. Mirror that behavior during initial cursor setup so a malformed first coin key cannot leave the cursor reporting itself as valid with a stale cached key.

Add a regression test for the malformed first-key case.
@DrahtBot

DrahtBot commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35248.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

@maflcko

maflcko commented May 9, 2026

Copy link
Copy Markdown
Member

ai slop: A bot re-creating previous pull requests without any reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants