htlcswitch/hop: require total_amount_msat for blinded final hops#10597
htlcswitch/hop: require total_amount_msat for blinded final hops#10597erickcestari wants to merge 2 commits intolightningnetwork:masterfrom
Conversation
Summary of ChangesHello @erickcestari, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the robustness and compliance of the HTLC switch by introducing a critical validation step for blinded payments. It ensures that final hops carrying encrypted recipient data correctly include the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly implements the BOLT 4 requirement that total_amount_msat (TLV type 18) must be present when encrypted_recipient_data (TLV type 10) is provided on a final node. The changes are well-integrated into the existing ValidateParsedPayloadTypes function and follow the established coding patterns in the lnd repository. The validation logic accurately targets the final hop of a blinded path and returns the appropriate ErrInvalidPayload error with an OmittedViolation. The review was conducted with reference to the LND Repository Style Guide, specifically ensuring adherence to line length limits, logical code segmentation, and clear commenting of intentions.
Per BOLT 4, when encrypted_recipient_data is present on a final node, total_amount_msat MUST be present. This adds explicit validation at payload parsing time. Found by differential fuzzing using bitcoinfuzz.
27029b7 to
774960d
Compare
|
This would fail further down the pipeline, correct? |
|
Yes, it would be caught further down the pipeline, but only indirectly. Blinded payments go through So while the HTLC would be rejected, the error reason is misleading — it implies the amount is too low rather than that a required field is missing. Adding the check at payload parsing time gives a precise |
| 0x0a, 0x03, 0x03, 0x02, 0x01, | ||
| // total_amount | ||
| 0x12, 0x00, | ||
| }, |
There was a problem hiding this comment.
Nit: the zero-length value here (0x12, 0x00) — type 18, length 0 — decodes as 0 for a tuint64, but is enough to mark the field as present in the parsed type map, which is all this layer checks. Worth a short comment to make that intent clear.
|
As a follow-up, it might also be worth adding this validation on the sending side in |
|
@erickcestari, remember to re-request review from reviewers when ready |
Per BOLT 4, when encrypted_recipient_data is present on a final node, total_amount_msat MUST be present. This adds explicit validation at payload parsing time.
Found by differential fuzzing using bitcoinfuzz.