Skip to content

Commit

Permalink
offers: add final node's CLTV delta in when creating blinded path pay…
Browse files Browse the repository at this point in the history
…info.

It should probably be renamed "minimum_cltv_delta" or something.

Fixes: #7179
Reported-by: @carlaKC
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and endothermicdev committed May 15, 2024
1 parent 8b5bf71 commit 121403b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/offers_invreq_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 8 additions & 2 deletions tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'])


Expand Down

0 comments on commit 121403b

Please sign in to comment.