mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
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:
@@ -1700,10 +1700,13 @@ REGISTER_PAYMENT_MODIFIER(exemptfee, struct exemptfee_data *,
|
|||||||
|
|
||||||
static struct shadow_route_data *shadow_route_init(struct payment *p)
|
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);
|
return payment_mod_shadowroute_get_data(p->parent);
|
||||||
else
|
} else {
|
||||||
return tal(p, struct shadow_route_data);
|
struct shadow_route_data *d = tal(p, struct shadow_route_data);
|
||||||
|
d->fuzz_amount = true;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mutual recursion */
|
/* 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
|
/* And now the thing that caused all of this: adjust the call
|
||||||
* to getroute. */
|
* to getroute. */
|
||||||
ok &= amount_msat_add(&p->getroute->amount, p->getroute->amount,
|
if (d->fuzz_amount) {
|
||||||
best_fee);
|
/* 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;
|
p->getroute->cltv += best->cltv_expiry_delta;
|
||||||
assert(ok);
|
assert(ok);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -307,6 +307,11 @@ struct shadow_route_data {
|
|||||||
struct payment_constraints constraints;
|
struct payment_constraints constraints;
|
||||||
struct node_id destination;
|
struct node_id destination;
|
||||||
struct route_hop *route;
|
struct route_hop *route;
|
||||||
|
|
||||||
|
/* multi-part payments require the sum of parts to be the exact
|
||||||
|
* amount, so we allow the payment flow to opt out of fuzzing the
|
||||||
|
* amount. */
|
||||||
|
bool fuzz_amount;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct direct_pay_data {
|
struct direct_pay_data {
|
||||||
|
|||||||
Reference in New Issue
Block a user