paymod: Allow callers to opt out of shadow routing amount fuzzing

With MPP we require that the sum of parts is equal to the `total_msat` amount
declared in the onion. Since that can't be changed once the first part arrives
we need a way to disable amount fuzzing for MPP.
This commit is contained in:
Christian Decker
2020-07-06 19:21:33 +02:00
parent 406d0d09cf
commit 7f53ade64b
2 changed files with 17 additions and 5 deletions

View File

@@ -1700,10 +1700,13 @@ REGISTER_PAYMENT_MODIFIER(exemptfee, struct exemptfee_data *,
static struct shadow_route_data *shadow_route_init(struct payment *p)
{
if (p->parent != NULL)
if (p->parent != NULL) {
return payment_mod_shadowroute_get_data(p->parent);
else
return tal(p, struct shadow_route_data);
} else {
struct shadow_route_data *d = tal(p, struct shadow_route_data);
d->fuzz_amount = true;
return d;
}
}
/* Mutual recursion */
@@ -1810,8 +1813,12 @@ static struct command_result *shadow_route_listchannels(struct command *cmd,
/* And now the thing that caused all of this: adjust the call
* to getroute. */
ok &= amount_msat_add(&p->getroute->amount, p->getroute->amount,
best_fee);
if (d->fuzz_amount) {
/* Only fuzz the amount to route to the destination if
* we didn't opt-out earlier. */
ok &= amount_msat_add(&p->getroute->amount,
p->getroute->amount, best_fee);
}
p->getroute->cltv += best->cltv_expiry_delta;
assert(ok);
}