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

Function command_find_channel

lightningd/peer_control.c:3090–3126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3088AUTODATA(json_command, &listpeerchannels_command);
3089
3090struct command_result *
3091command_find_channel(struct command *cmd,
3092 const char *name,
3093 const char *buffer, const jsmntok_t *tok,
3094 struct channel **channel)
3095{
3096 struct lightningd *ld = cmd->ld;
3097 struct channel_id cid;
3098 struct short_channel_id scid;
3099 struct peer *peer;
3100
3101 if (json_tok_channel_id(buffer, tok, &cid)) {
3102 struct peer_node_id_map_iter it;
3103
3104 for (peer = peer_node_id_map_first(ld->peers, &it);
3105 peer;
3106 peer = peer_node_id_map_next(ld->peers, &it)) {
3107 list_for_each(&peer->channels, (*channel), list) {
3108 if (!channel_state_wants_peercomms((*channel)->state))
3109 continue;
3110 if (channel_id_eq(&(*channel)->cid, &cid))
3111 return NULL;
3112 }
3113 }
3114 return command_fail_badparam(cmd, name, buffer, tok,
3115 "Channel id not found");
3116 } else if (json_to_short_channel_id(buffer, tok, &scid)) {
3117 *channel = any_channel_by_scid(ld, scid, true);
3118 if (!*channel)
3119 return command_fail_badparam(cmd, name, buffer, tok,
3120 "Short channel id not found");
3121 return NULL;
3122 } else {
3123 return command_fail_badparam(cmd, name, buffer, tok,
3124 "should be a channel ID or short channel ID");
3125 }
3126}
3127
3128static void setup_peer(struct peer *peer)
3129{

Callers 2

param_channel_or_allFunction · 0.85
param_channel_or_peerFunction · 0.85

Calls 5

json_tok_channel_idFunction · 0.85
any_channel_by_scidFunction · 0.70
command_fail_badparamFunction · 0.50
json_to_short_channel_idFunction · 0.50

Tested by

no test coverage detected