bolt09: clarify that writers SHOULD/MUST set even/odd/no bits for assumed bits? #1307
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DISCLAIMER
I'm not sure if this is the change we want, but I think there is something inconsistent between bolt11 and bolt09 with respect to assumed bits. I'm only opening this PR to start the discussion about whether there is something that should change.1
I'm currently implementing bolt11 myself here. These are the features for the first test vector:
bolts/11-payment-encoding.md
Lines 388 to 390 in 0cf2151
Afaict, it has the 14th bit (
payment_secret) and 8th bit (var_onion_optin) set. Since both bits are even, the payee indicates that both features are required, so the payer MUST use them, as mentioned in bolt09.bolt09 also mentions that the features that can be used in bolt11 are marked with
9:bolts/09-features.md
Line 30 in 0cf2151
However, unlike for
payment_secret, even though it's also marked as assumed,var_onion_optindoes not have9in its context column:bolts/09-features.md
Lines 39 to 42 in 0cf2151
Additionally, bolt09 also mentions this:
bolts/09-features.md
Lines 72 to 73 in 0cf2151
So to me, either the test vector is wrong for two possible reasons—it shouldn't set the bit at all, because
var_onion_opintdoes not have9in its context column OR it should set the odd bit, because bolt09 specifically says it MUST support (not require!)var_onion_optin(as if there's something special about it)—OR bolt09 is inconsistent with bolt11.The explanation about assumed bits in bolt09 also confused me:
bolts/09-features.md
Line 9 in 0cf2151
I thought "can be safely ignored" not only means that a reader can just assume the bit is set, but also that a writer doesn't have to set it. So maybe even
payment_secretshouldn't be set? Or it just doesn't matter what I set? Now I was really confused.For more context, since there seems to be special treatment wrt
var_onion_optin, I looked into the history of it and found two relevant commits: 60cfb59 added "[origin node] MUST supportvar_onion_optin" for the first time in 2022, and e042c61 then marked it as assumed in 2024.So maybe there's nothing special about
var_onion_optinanymore actually, and it should also have9in the context column, and it doesn't need to specifically be mentioned wrt what the origin node should set?Anyway, I hope I was able to clarify why I am confused.
The changes I propose match what I think how writers should handle assumed bits, but they are based on my limited understanding of what any of these features even actually mean.
My changes would also mean that ALL bolt11 test vectors need to be updated to include the even bits for assumed invoice features if they don't already, and I'm not in a position yet to do that, since my implementation doesn't even pass any of the existing test vectors yet. Or maybe the test vectors don't need to be updated, because the change only says writers SHOULD, not MUST? Or would that still be confusing then, if the test vectors don't even do what a writer SHOULD do?
So. Many. Questions. 😅
Footnotes
I also keep catching myself how I don't want to suggest updates to the spec before I even read all of it, because maybe it will be more clear then? But so far, reading more of the spec (bolt11+bolt09) just confused me more, so maybe this PR does make sense. 😅 ↩