[0.2] Reject offer_amount of 0 as invalid per BOLT 12#4488
Conversation
|
I've assigned @jkczyz as a reviewer! |
|
No new issues found beyond the previously noted misleading test comment at line 1710. The logic changes are correct: deserialization properly rejects zero amounts (with and without currency), and the builder's silent 0→None conversion integrates cleanly with downstream checks (e.g., the description auto-set at build line 416). |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 0.2 #4488 +/- ##
=======================================
Coverage 86.11% 86.11%
=======================================
Files 156 156
Lines 99922 99952 +30
Branches 99922 99952 +30
=======================================
+ Hits 86051 86077 +26
- Misses 11377 11382 +5
+ Partials 2494 2493 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Per the spec clarification in lightning/bolts#1316: - Writers MUST set offer_amount greater than zero when present - Readers MUST NOT respond to offers where offer_amount is zero Reject amount_msats(0) in the builder with InvalidAmount, and reject parsed offers with amount=0 (with or without currency) during TLV deserialization. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Backport of a06c446 Conflicts resolved in: * lightning/src/offers/offer.rs Compared to the upstream commit, this instead allows downstream code to pass a 0 amount but converts it to no-amount to ensure upgraded readers of the built offer will accept it. This avoids changing the API in a backport.
c442d2c to
cb5cdd8
Compare
| if amount_msats == 0 { | ||
| $self.offer.amount = None; | ||
| } |
There was a problem hiding this comment.
IIUC, newly created Offers will be fine. But they won't be able to parse previously created Offers or corresponding InvoiceRequests that used Some(0) for the amount.
Per the spec clarification in lightning/bolts#1316:
Reject amount_msats(0) in the builder with InvalidAmount, and reject parsed offers with amount=0 (with or without currency) during TLV deserialization.
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
Backport of a06c446
Conflicts resolved in:
Compared to the upstream commit, this instead allows downstream code to pass a 0 amount but converts it to no-amount to ensure upgraded readers of the built offer will accept it. This avoids changing the API in a backport.
Backport of #4324