MCPcopy Create free account
hub / github.com/ElementsProject/lightning / shadow_route_cb

Function shadow_route_cb

plugins/libplugin-pay.c:3439–3460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3437}
3438
3439static struct command_result *shadow_route_cb(struct shadow_route_data *d,
3440 struct payment *p)
3441{
3442 if (!d->use_shadow)
3443 return payment_continue(p);
3444
3445 if (p->step != PAYMENT_STEP_INITIALIZED)
3446 return payment_continue(p);
3447
3448 d->destination = *p->route_destination;
3449
3450 /* Allow shadowroutes to consume up to 1/4th of our budget. */
3451 d->constraints.cltv_budget = p->constraints.cltv_budget / 4;
3452 d->constraints.fee_budget
3453 = amount_msat_div(p->constraints.fee_budget, 4);
3454
3455 if (pseudorand(2) == 0) {
3456 return payment_continue(p);
3457 } else {
3458 return shadow_route_extend(d, p);
3459 }
3460}
3461
3462REGISTER_PAYMENT_MODIFIER(shadowroute, struct shadow_route_data *,
3463 shadow_route_init, shadow_route_cb);

Callers

nothing calls this directly

Calls 3

amount_msat_divFunction · 0.85
shadow_route_extendFunction · 0.85
payment_continueFunction · 0.70

Tested by

no test coverage detected