Skip to content

Conversation

wqxoxo
Copy link

@wqxoxo wqxoxo commented Sep 26, 2025

Summary

Fixes #6978 where BOLT11 invoice annotations were lost after lightning node restart.

Problem

HTLCs cannot be linked back to their originating payment records after restart. The channel_htlcs table lacks a direct foreign key reference to payments, making BOLT11 annotations appear "lost".

Solution

Add payment_id column to channel_htlcs table with proper foreign key relationship to maintain HTLC-payment linkage through restarts.

@wqxoxo wqxoxo force-pushed the feat/issue-6978-bolt11-annotation-fix branch 2 times, most recently from 2dd3a32 to 7ad18fa Compare September 26, 2025 16:27
@rustyrussell
Copy link
Contributor

This bug report, and fix, are a mystery to me!

What is the user visible change over restart? What list command is missing what field? listhtlcs? listsendpays? listforwards? listpeerchannels? listpays?

The test tests that entries are created in the database, but so what? Users don't see the database. This doesn't test whatever this is supposed to fix, so I can't even tell that...

@wqxoxo wqxoxo force-pushed the feat/issue-6978-bolt11-annotation-fix branch 2 times, most recently from 8ba9e19 to 48ffa71 Compare October 2, 2025 11:19
Fixes ElementsProject#6978 where BOLT11 invoice annotations were lost after lightning
node restart due to broken linkage between HTLCs and payment records.

Add payment_id column to channel_htlcs table with proper foreign key
relationship to maintain HTLC-payment linkage through restarts.
@wqxoxo
Copy link
Author

wqxoxo commented Oct 2, 2025

You're right, the test was focused on the database.
Updated test: Replaced the db-query test with one that actually checks listpays output before and after restart.

User visible change: listpays (and listsendpays) lose the bolt11 field after restart.

Which commands: listpays and listsendpays are affected. The others (listhtlcs, listforwards, listpeerchannels) never showed bolt11 anyway.

The root issue is HTLCs had no link back to payment records after restart so the bolt11 annotation got lost. Added a payment_id foreign key to fix it.

Does that make more sense? @rustyrussell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing bolt11 annotation after calling pay
2 participants