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

Function command_find_channel

lightningd/peer_control.c:2031–2071  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2029
2030
2031struct command_result *
2032command_find_channel(struct command *cmd,
2033 const char *buffer, const jsmntok_t *tok,
2034 struct channel **channel)
2035{
2036 struct lightningd *ld = cmd->ld;
2037 struct channel_id cid;
2038 struct short_channel_id scid;
2039 struct peer *peer;
2040
2041 if (json_tok_channel_id(buffer, tok, &cid)) {
2042 list_for_each(&ld->peers, peer, list) {
2043 list_for_each(&peer->channels, (*channel), list) {
2044 if (!channel_active(*channel))
2045 continue;
2046 if (channel_id_eq(&(*channel)->cid, &cid))
2047 return NULL;
2048 }
2049 }
2050 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
2051 "Channel ID not found: '%.*s'",
2052 tok->end - tok->start,
2053 buffer + tok->start);
2054 } else if (json_to_short_channel_id(buffer, tok, &scid)) {
2055 *channel = any_channel_by_scid(ld, &scid, true);
2056 if (!*channel)
2057 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
2058 "Short channel ID not found: '%.*s'",
2059 tok->end - tok->start,
2060 buffer + tok->start);
2061 if (!channel_active(*channel))
2062 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
2063 "Short channel ID not active: '%.*s'",
2064 tok->end - tok->start,
2065 buffer + tok->start);
2066 return NULL;
2067 } else {
2068 return command_fail_badparam(cmd, "id", buffer, tok,
2069 "should be a channel ID or short channel ID");
2070 }
2071}
2072
2073static void setup_peer(struct peer *peer, u32 delay)
2074{

Callers 2

param_channel_or_allFunction · 0.85
param_channel_or_peerFunction · 0.85

Calls 6

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

Tested by

no test coverage detected