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

Function direct_pay_listpeerchannels

plugins/libplugin-pay.c:3531–3575  ·  view source on GitHub ↗

Now that we have the listpeerchannels result for the root payment, let's search * for a direct channel that is a) connected and b) in state normal. We will * check the capacity based on the channel_hints in the override. */

Source from the content-addressed store, hash-verified

3529 * for a direct channel that is a) connected and b) in state normal. We will
3530 * check the capacity based on the channel_hints in the override. */
3531static struct command_result *direct_pay_listpeerchannels(struct command *cmd,
3532 const char *method,
3533 const char *buffer,
3534 const jsmntok_t *toks,
3535 struct payment *p)
3536{
3537 struct listpeers_channel **channels = json_to_listpeers_channels(tmpctx, buffer, toks);
3538 struct direct_pay_data *d = payment_mod_directpay_get_data(p);
3539
3540 for (size_t i=0; i<tal_count(channels); i++) {
3541 struct listpeers_channel *chan = channels[i];
3542
3543 if (!node_id_eq(&chan->id, p->route_destination))
3544 continue;
3545
3546 if (!chan->connected)
3547 continue;
3548
3549 if (!streq(chan->state, "CHANNELD_NORMAL")
3550 && !streq(chan->state, "CHANNELD_AWAITING_SPLICE"))
3551 continue;
3552
3553 /* Must have either a local alias for zeroconf
3554 * channels or a final scid. */
3555 assert(chan->alias[LOCAL] || chan->scid);
3556 tal_free(d->chan);
3557 d->chan = tal(d, struct short_channel_id_dir);
3558 if (chan->scid) {
3559 d->chan->scid = *chan->scid;
3560 } else {
3561 d->chan->scid = *chan->alias[LOCAL];
3562 }
3563 d->chan->dir = chan->direction;
3564 }
3565
3566 /* We may still need local mods! */
3567 if (!p->mods)
3568 p->mods = gossmods_from_listpeerchannels(p, p->local_id,
3569 buffer, toks, true,
3570 gossmod_add_localchan,
3571 NULL);
3572
3573 return direct_pay_override(p);
3574
3575}
3576
3577static struct command_result *direct_pay_cb(struct direct_pay_data *d, struct payment *p)
3578{

Callers

nothing calls this directly

Calls 4

node_id_eqFunction · 0.85
tal_freeFunction · 0.85
direct_pay_overrideFunction · 0.85

Tested by

no test coverage detected