BOLT 12: clarify that offer_amount must be greater than zero#1316
Conversation
t-bast
left a comment
There was a problem hiding this comment.
ACK 8605772, this is obvious and I think it's a bit spammy to explicitly spell it out, but why not.
@rustyrussell WDYT?
I agree, but I think if we have this in the spec will be obvious what to do, for instance ldk was accepting it and causing some parsing crash with cln IIRC |
|
Will create a test vector for this as Rusty suggested! |
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>
|
Here are two test vectors for {
"description": "Invalid: zero offer_amount",
"valid": false,
"bolt12": "lno1pqqq5qqkyyp4he0fg7pqje62jmnq78cr0ashv4q06qql58tyd9rhp3t2wuyugtq",
"field info": "offer_amount is 0",
"fields": [
{
"type": 8,
"length": 0,
"hex": ""
},
{
"type": 10,
"length": 0,
"hex": ""
},
{
"type": 22,
"length": 33,
"hex": "035be5e9478209674a96e60f1f037f6176540fd001fa1d64694770c56a7709c42c"
}
]
},
{
"description": "Invalid: zero offer_amount with currency",
"valid": false,
"bolt12": "lno1qcp4256ypqqq5qqkyyp4he0fg7pqje62jmnq78cr0ashv4q06qql58tyd9rhp3t2wuyugtq",
"field info": "offer_amount is 0, offer_currency is USD",
"fields": [
{
"type": 6,
"length": 3,
"hex": "555344"
},
{
"type": 8,
"length": 0,
"hex": ""
},
{
"type": 10,
"length": 0,
"hex": ""
},
{
"type": 22,
"length": 33,
"hex": "035be5e9478209674a96e60f1f037f6176540fd001fa1d64694770c56a7709c42c"
}
]
}Notes:
Generated with LDK and verified roundtrip (bech32 NoChecksum decodes back to the expected TLV bytes). |
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>
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>
Add explicit requirements that: - Writers MUST set offer_amount greater than zero when present - Readers MUST NOT respond to offers where offer_amount is zero This addresses ambiguity about whether offer_amount=0 is valid. Since omitting offer_amount indicates no minimum is required, a zero value when present would be semantically incorrect. Fixes lightning#1314
8605772 to
c092554
Compare
This doesn't make any sense, the field should be omitted if any amount is acceptable: setting it to `0` is confusing. See lightning/bolts#1316
t-bast
left a comment
There was a problem hiding this comment.
ACK c092554, added to eclair in ACINQ/eclair#3265.
|
Updated also the ldk one with the test vector, so I think we are ready to go? :-) |
Add explicit requirements that:
This addresses ambiguity about whether offer_amount=0 is valid. Since omitting offer_amount indicates no minimum is required, a zero value when present would be semantically incorrect.
Fixes #1314