| 3479 | shadow_route_init, shadow_route_cb); |
| 3480 | |
| 3481 | static struct command_result *direct_pay_override(struct payment *p) |
| 3482 | { |
| 3483 | /* The root has performed the search for a direct channel. */ |
| 3484 | struct payment *root = payment_root(p); |
| 3485 | struct direct_pay_data *d; |
| 3486 | struct channel_hint *hint = NULL; |
| 3487 | |
| 3488 | /* If we were unable to find a direct channel we don't need to do |
| 3489 | * anything. */ |
| 3490 | d = payment_mod_directpay_get_data(root); |
| 3491 | |
| 3492 | if (d->chan == NULL) |
| 3493 | return payment_continue(p); |
| 3494 | |
| 3495 | /* If we have a channel we need to make sure that it still has |
| 3496 | * sufficient capacity. Look it up in the channel_hints. */ |
| 3497 | hint = channel_hint_set_find(root->hints, d->chan); |
| 3498 | if (hint && hint->enabled && |
| 3499 | amount_msat_greater(hint->estimated_capacity, p->our_amount)) { |
| 3500 | if (p->getroute->cltv > p->constraints.cltv_budget) { |
| 3501 | paymod_log(p, LOG_DBG, |
| 3502 | "Direct channel (%s) skipped: " |
| 3503 | "CLTV delay %u exceeds budget %u.", |
| 3504 | fmt_short_channel_id_dir(tmpctx, &hint->scid), |
| 3505 | p->getroute->cltv, p->constraints.cltv_budget); |
| 3506 | return payment_continue(p); |
| 3507 | } |
| 3508 | |
| 3509 | /* Now build a route that consists only of this single hop */ |
| 3510 | p->route = tal_arr(p, struct route_hop, 1); |
| 3511 | p->route[0].amount = p->our_amount; |
| 3512 | p->route[0].delay = p->getroute->cltv; |
| 3513 | p->route[0].scid = hint->scid.scid; |
| 3514 | p->route[0].direction = hint->scid.dir; |
| 3515 | p->route[0].node_id = *p->route_destination; |
| 3516 | p->route[0].capacity = hint->capacity; |
| 3517 | paymod_log(p, LOG_DBG, |
| 3518 | "Found a direct channel (%s) with sufficient " |
| 3519 | "capacity, skipping route computation.", |
| 3520 | fmt_short_channel_id_dir(tmpctx, &hint->scid)); |
| 3521 | |
| 3522 | payment_set_step(p, PAYMENT_STEP_GOT_ROUTE); |
| 3523 | } |
| 3524 | |
| 3525 | return payment_continue(p); |
| 3526 | } |
| 3527 | |
| 3528 | /* Now that we have the listpeerchannels result for the root payment, let's search |
| 3529 | * for a direct channel that is a) connected and b) in state normal. We will |
no test coverage detected