From 294f8dbbe5797b321b340df0b3048c4dbfc845c2 Mon Sep 17 00:00:00 2001 From: Alex Myers Date: Tue, 19 Dec 2023 14:40:49 -0600 Subject: [PATCH] invoice: force inclusion of min_final_cltv_expiry for compatibility 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. --- common/bolt11.c | 6 ++++-- common/test/run-bolt11.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/common/bolt11.c b/common/bolt11.c index 1a397d339..efcd38846 100644 --- a/common/bolt11.c +++ b/common/bolt11.c @@ -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]); diff --git a/common/test/run-bolt11.c b/common/test/run-bolt11.c index 5f909f3b5..5c6d9256f 100644 --- a/common/test/run-bolt11.c +++ b/common/test/run-bolt11.c @@ -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);