Skip to content

Commit

Permalink
bolt11: update to BOLT 7dda8f84edb8655766d83619cb41110c1bf43f85 "Bolt…
Browse files Browse the repository at this point in the history
…11: min_final_cltv_expiry_delta is optional, not required (ElementsProject#1100)"

Since we changed the default, it used to be required to set it.  That was a while ago, though, so we can make it optional again.

Changelog-Changed: Protocol: `invoice` no longer explicitly encodes `c` if it's the default (18)
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Sep 20, 2023
1 parent af5bb32 commit 1d475f1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CCANDIR := ccan

# Where we keep the BOLT RFCs
BOLTDIR := ../bolts/
DEFAULT_BOLTVERSION := 17ceba42dc6607b637a713a9bc051f63c1357edd
DEFAULT_BOLTVERSION := 7dda8f84edb8655766d83619cb41110c1bf43f85
# Can be overridden on cmdline.
BOLTVERSION := $(DEFAULT_BOLTVERSION)

Expand Down
12 changes: 9 additions & 3 deletions common/bolt11.c
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ static void push_field(u5 **data, char type, const void *src, size_t nbits)
*
* - if `x` is included:
* - SHOULD use the minimum `data_length` possible.
* - MUST include one `c` field (`min_final_cltv_expiry_delta`).
* - SHOULD include one `c` field (`min_final_cltv_expiry_delta`).
*...
* - SHOULD use the minimum `data_length` possible.
*/
Expand Down Expand Up @@ -1312,9 +1312,15 @@ char *bolt11_encode_(const tal_t *ctx,
encode_x(&data, b11->expiry);

/* BOLT #11:
* - MUST include one `c` field (`min_final_cltv_expiry_delta`).
* - SHOULD include one `c` field (`min_final_cltv_expiry_delta`).
*...
* A reader:
*...
* - if the `c` field (`min_final_cltv_expiry_delta`) is not provided:
* - MUST use an expiry delta of at least 18 when making the payment
*/
encode_c(&data, b11->min_final_cltv_expiry);
if (b11->min_final_cltv_expiry != 18)
encode_c(&data, b11->min_final_cltv_expiry);

for (size_t i = 0; i < tal_count(b11->fallbacks); i++)
encode_f(&data, b11->fallbacks[i]);
Expand Down
2 changes: 1 addition & 1 deletion common/test/run-bolt11.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ int main(int argc, char *argv[])
#if DEVELOPER
assert(streq(badstr, "lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q4psqqqqqqqqqqqqqqqqsgqtqyx5vggfcsll4wu246hz02kp85x4katwsk9639we5n5yngc3yhqkm35jnjw4len8vrnqnf5ejh0mzj9n3vz2px97evektfm2l6wqccp3y7372"));
#else
assert(streq(badstr, "lnbc25m1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeescqpj9q4psqqqqqqqqqqqqqqqqsgqf0nf0agw8xncpemlreh8wl0z5exhz3pky094lu7pf62nvcxq2vljzhhw69xfdftrgm0jklut3h25nlsfw5prz4c0pjy46xyer0k85hqpnathfq"));
assert(streq(badstr, "lnbc25m1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdees9q4psqqqqqqqqqqqqqqqqsgq8w9mkdh2n9pmrsg5natjffcgjpp5caamstsq5pm03v2c7ca5ej3plyrfe3vyzl76v6wex4r8rd6rdvys4a35983n6wrzegcwfl2gl4qqxh98vj"));
#endif

/* Empty set of allowed bits, ensures this fails! */
Expand Down

0 comments on commit 1d475f1

Please sign in to comment.