renepay: calculate fee and delay accumulation correctly.

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.
This commit is contained in:
Rusty Russell 2023-08-29 14:59:16 +09:30
parent 0135d563a0
commit 7a92eb2d89
2 changed files with 3 additions and 4 deletions

View File

@ -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;
}
@ -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;

View File

@ -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,