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

Function listpeerchannels_done

plugins/pay.c:709–755  ·  view source on GitHub ↗

We are the entry point, so the next hop could actually be an scid alias, * so we can't just use gossmap. */

Source from the content-addressed store, hash-verified

707/* We are the entry point, so the next hop could actually be an scid alias,
708 * so we can't just use gossmap. */
709static struct command_result *listpeerchannels_done(struct command *cmd,
710 const char *method,
711 const char *buf,
712 const jsmntok_t *result,
713 struct payment *p)
714{
715 const jsmntok_t *arr, *t;
716 size_t i;
717
718 assert(!p->blindedpath->first_node_id.is_pubkey);
719 arr = json_get_member(buf, result, "channels");
720 json_for_each_arr(i, t, arr) {
721 const jsmntok_t *alias, *local_alias, *scid;
722 struct pubkey id;
723
724 alias = json_get_member(buf, t, "alias");
725 if (alias)
726 local_alias = json_get_member(buf, alias, "local");
727 else
728 local_alias = NULL;
729
730 scid = json_get_member(buf, t, "short_channel_id");
731 if (!scidtok_eq(buf, scid, p->blindedpath->first_node_id.scidd.scid)
732 && !scidtok_eq(buf, local_alias, p->blindedpath->first_node_id.scidd.scid)) {
733 continue;
734 }
735
736 if (!json_to_pubkey(buf, json_get_member(buf, t, "peer_id"), &id))
737 plugin_err(cmd->plugin, "listpeerchannels no peer_id: %.*s",
738 json_tok_full_len(result),
739 json_tok_full(buf, result));
740
741 plugin_log(cmd->plugin, LOG_DBG,
742 "Mapped decrypted next hop from %s -> %s",
743 fmt_short_channel_id(tmpctx, p->blindedpath->first_node_id.scidd.scid),
744 fmt_pubkey(tmpctx, &id));
745 sciddir_or_pubkey_from_pubkey(&p->blindedpath->first_node_id, &id);
746 /* Fix up our destination */
747 node_id_from_pubkey(p->route_destination, &p->blindedpath->first_node_id.pubkey);
748 return start_payment(cmd, p);
749 }
750
751 return command_fail(cmd, PAY_UNPARSEABLE_ONION,
752 "Invalid next short_channel_id %s for second hop of onion",
753 fmt_short_channel_id(tmpctx,
754 p->blindedpath->first_node_id.scidd.scid));
755}
756
757static struct command_result *
758decrypt_done(struct command *cmd,

Callers

nothing calls this directly

Calls 13

json_get_memberFunction · 0.85
scidtok_eqFunction · 0.85
fmt_short_channel_idFunction · 0.85
fmt_pubkeyFunction · 0.85
node_id_from_pubkeyFunction · 0.85
start_paymentFunction · 0.85
plugin_errFunction · 0.70
plugin_logFunction · 0.70
command_failFunction · 0.70
json_to_pubkeyFunction · 0.50
json_tok_full_lenFunction · 0.50

Tested by

no test coverage detected