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

miner: fix empty mempool case for waitNext()

Public commit record

What the developer wrote

Authored by Sjors Provoost

78/100 · Adequate
miner: fix empty mempool case for waitNext()

Block template fees are calculated by looping over new_tmpl->vTxFees
and return (early) once the fee_threshold is exceeded.

This left an edge case when the mempool is empty, which this commit
fixes and adds a test for. It does so by using std::accumulate instead
of manual loops.

Also update interface_ipc.py to account for the new behavior.

Co-authored-by: Raimo33 <claudio.raimondi@protonmail.com>
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit fixes a small logic bug in Bitcoin Core's block-template waiting code. When the mempool is empty, the code that decides whether a newly created block template is 'better' than the old one would never finish its comparison loop, so it could fail to return a result or behave unexpectedly. The fix replaces the manual loop with a simple sum of all fees, and adds tests for the empty-mempool case. It is a correctness fix rather than a critical security vulnerability.

Recommended action

No immediate action required beyond normal review and merge. The change is a straightforward bug fix with accompanying tests. Operators using the mining IPC interface should ensure they run a version containing this fix to avoid unexpected waitNext() behavior when the mempool is empty.

Security signals we found

01

Logic bug in fee-threshold comparison loop

02

Empty mempool edge case left unhandled

03

Potential denial-of-service or hang in miner IPC interface

04

Fix verified by new unit and functional tests

Risk score

Why this scored 23/100

Our methodology →
Potential impact 4/30
Exploitability 2/25
Stealth signal 3/15
Affected reach 3/15
Confidence 7/10
Evidence quality 4/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.