Skip to content

Conversation

@ziggie1984
Copy link
Collaborator

Older payments might have a invalid tlv stream, we now catch this
case.

@ziggie1984 ziggie1984 linked an issue Oct 31, 2025 that may be closed by this pull request
2 tasks
@ziggie1984 ziggie1984 self-assigned this Oct 31, 2025
@ziggie1984 ziggie1984 marked this pull request as ready for review October 31, 2025 21:52
@ziggie1984 ziggie1984 force-pushed the fix-decoding-extra-tlv-data branch from 4d5ac7f to 32a4bef Compare November 1, 2025 07:38
@ziggie1984 ziggie1984 requested a review from guggero November 1, 2025 07:41
Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK, LGTM 🎉

Thanks a lot for the quick fix!

Copy link
Collaborator

@starius starius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🏆
Please add a regression test (draft sent privately).

@ziggie1984 ziggie1984 force-pushed the fix-decoding-extra-tlv-data branch from 801f34c to 7e028dc Compare November 2, 2025 09:06
@ziggie1984
Copy link
Collaborator Author

unit test added !

@yyforyongyu yyforyongyu added this to the v0.20.0 milestone Nov 3, 2025
@ziggie1984 ziggie1984 force-pushed the fix-decoding-extra-tlv-data branch from 7e028dc to e74fa5b Compare November 3, 2025 07:15
@yyforyongyu
Copy link
Member

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a change to gracefully handle invalid TLV data when decoding payments, which can occur with older payments. This is achieved by wrapping TLV parsing errors in lnwire.ChannelUpdate1.Decode and then specifically checking for this error type in payments/db/kv_store.go:deserializeHTLCFailInfo. Instead of failing, it now logs a warning and continues, making the system more robust to legacy data formats. The changes are well-tested with a new unit test that constructs a corrupted TLV stream to verify the new behavior. The logic is sound and the implementation is correct. I have one suggestion to improve the readability of the error handling logic.

Copy link
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last thing about the %w: %w usage, otherwise good to go!

Older payments might have a invalid tlv stream, we now catch this
case and add a unit test.
@ziggie1984 ziggie1984 force-pushed the fix-decoding-extra-tlv-data branch from e74fa5b to 870d603 Compare November 3, 2025 11:54
@ziggie1984
Copy link
Collaborator Author

@guggero I wonder how often this happened in case of your node, maybe we do some have some older version which produces wrong InboundFee tlv values which we need to investigate.

@yyforyongyu yyforyongyu enabled auto-merge November 3, 2025 13:37
@yyforyongyu yyforyongyu merged commit c7c8073 into lightningnetwork:master Nov 3, 2025
34 checks passed
@github-project-automation github-project-automation bot moved this to Done in lnd v0.20 Nov 3, 2025
@guggero
Copy link
Collaborator

guggero commented Nov 5, 2025

@guggero I wonder how often this happened in case of your node, maybe we do some have some older version which produces wrong InboundFee tlv values which we need to investigate.

I only seem to have a single payment with such a failure. So I don't think any further investigation is necessary, seems to have been a fluke.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[bug]: ListPayments returns "unable to decode error update" for old payments

4 participants