AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 24 Bitcoin

coins: pack `Coin` height/coinbase consistently

Public commit record

What the developer wrote

Authored by Lőrinc

80/100 · Strong
coins: pack `Coin` height/coinbase consistently

Serialize `Coin` metadata using the canonical (height << 1) | coinbase packing across `Coin` serialization, undo records, and coinstats hashing.

Cast the 31-bit `nHeight` bitfield to `uint32_t` before shifting to avoid signed promotion undefined behaviour.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode
The short version

What changed, and why it matters

This commit tidies up how Bitcoin Core packs two pieces of coin metadata—block height and whether the coin came from a coinbase transaction—into a single serialized number. It makes three different code paths use the exact same bit-packing formula and explicitly converts a signed height value to unsigned before shifting, which removes a technical C++ undefined-behavior risk. The actual serialized bytes do not change for normal values, so this is primarily a code-correctness and consistency fix rather than a fix for an active exploit.

Recommended action

Treat as a low-risk hardening/cleanup commit. Reviewers should verify that the new expression is bit-identical to the old one for the full range of nHeight (0..2^31-1) and that the undo compatibility branch (nHeight > 0) remains intact. No urgent deployment action is warranted.

Security signals we found

01

Undefined behavior removed: explicit uint32_t cast before left shift of signed bitfield

02

Serialization consistency: three independent code paths now use the same packing formula

03

No format change: old and new expressions are equivalent for all valid nHeight values

04

Comment-only documentation update in src/coins.h to match code

Risk score

Why this scored 24/100

Our methodology →
Potential impact 5/30
Exploitability 2/25
Stealth signal 3/15
Affected reach 4/15
Confidence 7/10
Evidence quality 3/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.