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

lightningd: store raw failure message so waitsendpay always has raw_message

Public commit record

What the developer wrote

Authored by Ken Sedgwick

91/100 · Strong
lightningd: store raw failure message so waitsendpay always has raw_message

If a payment's HTLC failure completes before waitsendpay is called,
wait_payment() rebuilds the error from the database, which did not
persist the raw BOLT4 failure message: a 2019 FIXME in that path set
fail->msg = NULL, silently dropping raw_message from the error data.
This is the cause of the test_error_returns_blockheight CI flake -
the test loses the race occasionally, calls waitsendpay after the
failure has landed, and KeyErrors on the missing raw_message.

Add a failmsg column to the payments table (with a downgrade drop),
persist fail->msg when recording the failure, and read it back in
wait_payment. Local and self-payment failures store NULL as before,
since no onion failure message exists for them; failed payments
recorded before this migration also return NULL, matching the old
behavior.

The flaky test now also calls waitsendpay a second time, which
deterministically takes the database-replay path, so the regression
is covered without any timing dependence.

Changelog-Fixed: JSON-RPC: `waitsendpay` error data now includes `raw_message` even when the payment already failed before the command was called.
Fixes: #9341
✓ 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 a bug in Core Lightning where the `waitsendpay` command could omit a `raw_message` field from error responses if the payment failure was recorded in the database before the command was called. The fix adds a new database column to store the raw failure message and reads it back when reconstructing the error. It is a data-integrity/API-correctness fix, not a vulnerability that allows attacks or unauthorized access.

Recommended action

No immediate security action required. This is a bug fix improving API correctness and test reliability. Operators and integrators relying on `waitsendpay` error data should upgrade to ensure consistent `raw_message` availability.

Security signals we found

01

Fixes missing raw_message in JSON-RPC error data (issue #9341)

02

Adds database column to persist BOLT4 failure message

03

Removes 2019 FIXME where failure message was silently dropped

04

Includes regression test for database-replay path

Risk score

Why this scored 26/100

Our methodology →
Potential impact 4/30
Exploitability 0/25
Stealth signal 3/15
Affected reach 5/15
Confidence 9/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.