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

Function shadow_route_cb

plugins/libplugin-pay.c:3167–3190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3165}
3166
3167static void shadow_route_cb(struct shadow_route_data *d,
3168 struct payment *p)
3169{
3170#if DEVELOPER
3171 if (!d->use_shadow)
3172 return payment_continue(p);
3173#endif
3174
3175 if (p->step != PAYMENT_STEP_INITIALIZED)
3176 return payment_continue(p);
3177
3178 d->destination = *p->destination;
3179
3180 /* Allow shadowroutes to consume up to 1/4th of our budget. */
3181 d->constraints.cltv_budget = p->constraints.cltv_budget / 4;
3182 d->constraints.fee_budget
3183 = amount_msat_div(p->constraints.fee_budget, 4);
3184
3185 if (pseudorand(2) == 0) {
3186 return payment_continue(p);
3187 } else {
3188 shadow_route_extend(d, p);
3189 }
3190}
3191
3192REGISTER_PAYMENT_MODIFIER(shadowroute, struct shadow_route_data *,
3193 shadow_route_init, shadow_route_cb);

Callers

nothing calls this directly

Calls 4

payment_continueFunction · 0.85
amount_msat_divFunction · 0.85
shadow_route_extendFunction · 0.85
pseudorandFunction · 0.50

Tested by

no test coverage detected