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

Function shadow_route_cb

plugins/libplugin-pay.c:3455–3476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3453}
3454
3455static struct command_result *shadow_route_cb(struct shadow_route_data *d,
3456 struct payment *p)
3457{
3458 if (!d->use_shadow)
3459 return payment_continue(p);
3460
3461 if (p->step != PAYMENT_STEP_INITIALIZED)
3462 return payment_continue(p);
3463
3464 d->destination = *p->route_destination;
3465
3466 /* Allow shadowroutes to consume up to 1/4th of our budget. */
3467 d->constraints.cltv_budget = p->constraints.cltv_budget / 4;
3468 d->constraints.fee_budget
3469 = amount_msat_div(p->constraints.fee_budget, 4);
3470
3471 if (pseudorand(2) == 0) {
3472 return payment_continue(p);
3473 } else {
3474 return shadow_route_extend(d, p);
3475 }
3476}
3477
3478REGISTER_PAYMENT_MODIFIER(shadowroute, struct shadow_route_data *,
3479 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