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

Function direct_pay_override

plugins/libplugin-pay.c:3465–3510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 7

payment_rootFunction · 0.85
channel_hint_set_findFunction · 0.85
amount_msat_greaterFunction · 0.85
paymod_logFunction · 0.85
fmt_short_channel_id_dirFunction · 0.85
payment_set_stepFunction · 0.85
payment_continueFunction · 0.70

Tested by

no test coverage detected