From 121403b5dfb5a39d5e5f531b0c6bbe92295c6a08 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 14 May 2024 21:15:57 +0930 Subject: [PATCH] offers: add final node's CLTV delta in when creating blinded path payinfo. It should probably be renamed "minimum_cltv_delta" or something. Fixes: https://github.com/ElementsProject/lightning/issues/7179 Reported-by: @carlaKC Signed-off-by: Rusty Russell --- plugins/offers_invreq_hook.c | 2 +- tests/test_pay.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/offers_invreq_hook.c b/plugins/offers_invreq_hook.c index 0716437cc19e..b0fe68cc2055 100644 --- a/plugins/offers_invreq_hook.c +++ b/plugins/offers_invreq_hook.c @@ -439,7 +439,7 @@ static struct command_result *listincoming_done(struct command *cmd, ir->inv->invoice_blindedpay[0] = tal(ir->inv->invoice_blindedpay, struct blinded_payinfo); ir->inv->invoice_blindedpay[0]->fee_base_msat = best->feebase; ir->inv->invoice_blindedpay[0]->fee_proportional_millionths = best->feeppm; - ir->inv->invoice_blindedpay[0]->cltv_expiry_delta = best->cltv; + ir->inv->invoice_blindedpay[0]->cltv_expiry_delta = best->cltv + cltv_final; ir->inv->invoice_blindedpay[0]->htlc_minimum_msat = best->htlc_min; ir->inv->invoice_blindedpay[0]->htlc_maximum_msat = best->htlc_max; ir->inv->invoice_blindedpay[0]->features = NULL; diff --git a/tests/test_pay.py b/tests/test_pay.py index f05c6e48074c..fd0bf70f94ae 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -5608,8 +5608,10 @@ def test_pay_partial_msat(node_factory, executor): def test_blindedpath_privchan(node_factory, bitcoind): - l1, l2 = node_factory.line_graph(2, wait_for_announce=True, opts={'experimental-offers': None}) - l3 = node_factory.get_node(options={'experimental-offers': None}) + l1, l2 = node_factory.line_graph(2, wait_for_announce=True, + opts={'experimental-offers': None}) + l3 = node_factory.get_node(options={'experimental-offers': None, + 'cltv-final': 120}) # Private channel. node_factory.join_nodes([l2, l3], announce_channels=False) @@ -5624,6 +5626,10 @@ def test_blindedpath_privchan(node_factory, bitcoind): assert len(decode['invoice_paths']) == 1 assert decode['invoice_paths'][0]['first_node_id'] == l2.info['id'] + # Carla points out that the path's cltv_expiry_delta *includes* + # the final node's final value. + assert decode['invoice_paths'][0]['payinfo']['cltv_expiry_delta'] == l3.config('cltv-final') + l2.config('cltv-delta') + l1.rpc.pay(inv['invoice'])