Skip to content

Commit

Permalink
renepay: calculate fee and delay accumulation correctly.
Browse files Browse the repository at this point in the history
1. When we add a shadow amount, we were using the wrong channel for
   the fee calculation.
2. Similarly, when calculating the delay amount.

The result is that we can get WIRE_INCORRECT_CLTV_EXPIRY repeatedly
from nodes.

Reported-by: https://github.com/Sjors
Fixes: #6620
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changlog-Experimental: Fixed: `renepay` handles ctlv correctly when it varies along a path.
  • Loading branch information
rustyrussell committed Aug 31, 2023
1 parent 0135d56 commit 7a92eb2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 3 additions & 3 deletions plugins/renepay/pay_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ static bool add_to_amounts(const struct gossmap *gossmap,
for (int i = num-2; i >= 0; i--) {
amounts[i] = amounts[i+1];
if (!amount_msat_add_fee(&amounts[i],
flow_edge(f, i)->base_fee,
flow_edge(f, i)->proportional_fee))
flow_edge(f, i+1)->base_fee,
flow_edge(f, i+1)->proportional_fee))
return false;
}

Expand Down Expand Up @@ -322,7 +322,7 @@ static void convert_and_attach_flows(struct payment *payment,
pf->cltv_delays[plen-1] = final_cltvs[i];
for (int j = (int)plen-2; j >= 0; j--) {
pf->cltv_delays[j] = pf->cltv_delays[j+1]
+ f->path[j]->half[f->dirs[j]].delay;
+ f->path[j+1]->half[f->dirs[j+1]].delay;
}
pf->amounts = tal_steal(pf, f->amounts);
pf->success_prob = f->success_prob;
Expand Down
1 change: 0 additions & 1 deletion tests/test_renepay.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def test_simple(node_factory):
assert details['destination'] == l2.info['id']


@pytest.mark.xfail(strict=True)
def test_direction_matters(node_factory):
'''Make sure we use correct delay and fees for the direction we're going.'''
l1, l2, l3 = node_factory.line_graph(3,
Expand Down

0 comments on commit 7a92eb2

Please sign in to comment.