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

fix: uptime RPC returns 0 on first call

Public commit record

What the developer wrote

Authored by Lőrinc

100/100 · Strong
fix: uptime RPC returns 0 on first call

The monotonic uptime fix (#34328) used a function-local static for `g_startup_time`, which was initialized on first `GetUptime()` call instead of app startup time.
This caused the first `uptime()` call to always return 0.

Move `g_startup_time` to namespace scope so it initializes at program start, ensuring the first call returns actual elapsed time. Note that we don't need to make it `static` anymore because it is just used in this single translation unit.

Test was updated to simulate some work before the first call.

Co-authored-by: Carlo Antinarella <carloantinarella@users.noreply.github.com>
✓ Descriptive subject✓ Names a concrete action or component✓ Uses a recognizable type or scope✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a minor bug in the `uptime` RPC command. Previously, the very first call to `uptime` would always report 0 seconds because the program's start time was accidentally recorded at the moment of that first call, not at actual startup. The fix moves the startup timestamp to a global variable that is set when the program begins. This is a correctness fix with no security impact.

Recommended action

No security action required. This is a routine bug fix; apply as part of normal maintenance if desired.

Security signals we found

No strong security signals were identified.

Risk score

Why this scored 18/100

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