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

Function direct_pay_listpeerchannels

plugins/libplugin-pay.c:3515–3559  ·  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

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

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