Allow zero amount paths with MinHTLC policies
Change Description
Skip returning error when building blinded paths amount is zero and channel has a greater MinHTLC policy. This fixes #9256
Previously, building blinded paths would fail when ValueMsat was 0 (zero amount payments) and intermediate channels had MinHTLC policies greater than zero. This prevented creation of blinded path invoices for zero amount payments.
The fix adds a condition to skip MinHTLC validation during path construction when ValueMsat is 0, since zero amount indicates the sender will decide the final payment amount. MinHTLC constraints will still be validated at payment time from the sender's perspective.
Steps to Test
Added a test make unit pkg=routing/blindedpath case=TestBuildBlindedPathZeroAmount and can be tested on a regtest network running licli addinvoice --blind --amt 0
Pull Request Checklist
Testing
- [x] Your PR passes all CI checks.
- [x] Tests covering the positive and negative (error paths) are included.
- [x] Bug fixes contain tests triggering the bug to prevent regressions.
Code Style and Documentation
- [x] The change is not insubstantial. Typo fixes are not accepted to fight bot spam.
- [x] The change obeys the Code Documentation and Commenting guidelines, and lines wrap at 80.
- [x] Commits follow the Ideal Git Commit Structure.
- [ ] Any new logging statements use an appropriate subsystem and logging level.
- [ ] Any new lncli commands have appropriate tags in the comments for the rpc in the proto file.
- [ ] There is a change description in the release notes, or
[skip ci]in the commit message for small changes.
📝 Please see our Contribution Guidelines for further guidance.
/gemini review
I guess gemini is counting differently the 80 character long 👀 as example
// 2) The new minHTLC value does not violate the sender amount.
has 79 columns
Thanks for the review @Abdulkbk!
@yyforyongyu any input on this PR or maybe who can I reach out to?
I don't think a zero amount makes sense especially with BOLT12 offer where an invoice can be fetched just in time with the proper Amount, can you explain use-cases for this ?
@yyforyongyu: review reminder @a-mpch, remember to re-request review from reviewers when ready