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

units: Fix off-by-one error in satisfied by height

Public commit record

What the developer wrote

Authored by Tobin C. Harding

91/100 · Strong
units: Fix off-by-one error in satisfied by height

In #6384 we fixed an off-by-one error in the satisfied by time logic.
I swear I checked the satisfied by height code at that time but
apparently not. While reviewing #6581 I saw the same bug.

The problem is we both +1 to height _and_ use `<=`. Either of these on
its own is correct since we know the next block has height one higher
and the check is 'lower than the height of the next block'.

The unit boundary test was wrong too.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes an off-by-one error in how the rust-bitcoin library decides whether a Bitcoin transaction's height-based locktime is satisfied. Because the code both added 1 to the current chain tip height and used a 'less than or equal to' comparison, it considered a locktime satisfied one block too early. A transaction that should only be spendable after block 101 could have been treated as spendable once block 100 was the chain tip. The same kind of bug was also present in relative height locktime checks. The fix removes the extra +1 and switches to a strict 'less than' comparison for absolute height locks, and removes the +1 for relative height locks.

Recommended action

Review any downstream code that relies on these locktime satisfaction helpers, especially wallet or mempool logic that might have accepted transactions one block too early. Consider whether the previous behavior could have caused invalid transactions to be constructed or accepted, and add regression tests for the corrected boundary.

Security signals we found

01

Off-by-one in locktime satisfaction logic

02

Incorrect boundary unit test reinforced the bug

03

Same class of bug previously fixed for time-based locktimes in PR #6384

04

Relative and absolute height locktime checks both affected

Risk score

Why this scored 64/100

Our methodology →
Potential impact 18/30
Exploitability 12/25
Stealth signal 10/15
Affected reach 12/15
Confidence 8/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.