| 3165 | } |
| 3166 | |
| 3167 | static 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 | |
| 3192 | REGISTER_PAYMENT_MODIFIER(shadowroute, struct shadow_route_data *, |
| 3193 | shadow_route_init, shadow_route_cb); |
nothing calls this directly
no test coverage detected