Skip to content

Commit

Permalink
invoice: force inclusion of min_final_cltv_expiry for compatibility
Browse files Browse the repository at this point in the history
As reported by @wtogami, LND nodes are using a default
min_final_cltv_expiry_delta of 9, which makes them unable to pay invoices
using the modern spec default of 18.  Forcing inclusion of the c field
allows interoperability until broader support of the 18 block default.
Fixes: #6956

Changelog-Fixed: Default bolt11 invoices are payable by LND nodes.
  • Loading branch information
endothermicdev committed Dec 21, 2023
1 parent 56d42ea commit fb58048
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions common/bolt11.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,8 +1327,10 @@ char *bolt11_encode_(const tal_t *ctx,
* - 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
*/
if (b11->min_final_cltv_expiry != 18)
encode_c(&data, b11->min_final_cltv_expiry);
/* FIXME: Only encode if non-default once all implementations update
* default min_final_cltv_expiry_delta to 18. Forcing inclusion in the
* interrim to ensure compatibility with existing nodes. */
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 @@ -494,11 +494,11 @@ int main(int argc, char *argv[])
badstr = bolt11_encode(tmpctx, b11, false, test_sign, NULL);
assert(streq(badstr, "lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q4psqqqqqqqqqqqqqqqqsgqtqyx5vggfcsll4wu246hz02kp85x4katwsk9639we5n5yngc3yhqkm35jnjw4len8vrnqnf5ejh0mzj9n3vz2px97evektfm2l6wqccp3y7372"));
dev_bolt11_old_order = false;
dev_bolt11_omit_c_value = false;

/* Otherwise it does it normally */
badstr = bolt11_encode(tmpctx, b11, false, test_sign, NULL);
assert(streq(badstr, "lnbc25m1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdees9q4psqqqqqqqqqqqqqqqqsgq8w9mkdh2n9pmrsg5natjffcgjpp5caamstsq5pm03v2c7ca5ej3plyrfe3vyzl76v6wex4r8rd6rdvys4a35983n6wrzegcwfl2gl4qqxh98vj"));
dev_bolt11_omit_c_value = false;

/* Empty set of allowed bits, ensures this fails! */
fset = tal(tmpctx, struct feature_set);
Expand Down

0 comments on commit fb58048

Please sign in to comment.