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

payments/db/migration1: sync bugfixes from main sql_store

Public commit record

What the developer wrote

Authored by ziggie

73/100 · Adequate
payments/db/migration1: sync bugfixes from main sql_store

In this commit, we backport two bugfixes from the main sql_store into
the frozen migration1 snapshot that were accidentally missed when
arranging the commits.

The first fix corrects the resolution timestamps for settled and failed
HTLC attempts. The old code passed time.Now() instead of
settleInfo.SettleTime.UTC() and failInfo.FailTime.UTC(), which would
have overwritten the historical timestamps with the current wall clock
on write.

The second fix adds a deterministic sort by SequenceNum after
QueryPayments collects results from the map, ensuring a stable ordering
across calls.

Note that neither SettleAttempt, FailAttempt, nor QueryPayments are
invoked by the migration code itself — the migration only writes
historical KV data into SQL and reads it back for validation. These
changes are included purely for completeness so the frozen snapshot
doesn't silently carry known bugs.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes two bugs in a frozen copy of LND's payment database code used during data migration. One bug would overwrite historical success/failure timestamps with the current time when updating old payment attempts. The other bug made payment list ordering non-deterministic. The commit message explicitly states these fixed functions are not actually called by the migration itself, so the fixes are for completeness rather than active vulnerability remediation.

Recommended action

No immediate security action required. Treat as routine code-quality/maintenance backport. If using this migration snapshot, verify that downstream tooling does not rely on the corrected functions being called during migration, since the commit message says they are not. Review whether the original missed backport indicates process gaps in migration snapshot preparation.

Security signals we found

01

Incorrect use of time.Now() instead of stored historical timestamp could corrupt audit/reconciliation data

02

Non-deterministic map iteration order could cause inconsistent query results

03

Backport of bugfixes into frozen migration snapshot suggests prior main code was already fixed

04

Functions containing fixes are stated to be unused by actual migration path

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.