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

Function command_find_channel

lightningd/peer_control.c:2816–2852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2814AUTODATA(json_command, &listpeerchannels_command);
2815
2816struct command_result *
2817command_find_channel(struct command *cmd,
2818 const char *name,
2819 const char *buffer, const jsmntok_t *tok,
2820 struct channel **channel)
2821{
2822 struct lightningd *ld = cmd->ld;
2823 struct channel_id cid;
2824 struct short_channel_id scid;
2825 struct peer *peer;
2826
2827 if (json_tok_channel_id(buffer, tok, &cid)) {
2828 struct peer_node_id_map_iter it;
2829
2830 for (peer = peer_node_id_map_first(ld->peers, &it);
2831 peer;
2832 peer = peer_node_id_map_next(ld->peers, &it)) {
2833 list_for_each(&peer->channels, (*channel), list) {
2834 if (!channel_state_wants_peercomms((*channel)->state))
2835 continue;
2836 if (channel_id_eq(&(*channel)->cid, &cid))
2837 return NULL;
2838 }
2839 }
2840 return command_fail_badparam(cmd, name, buffer, tok,
2841 "Channel id not found");
2842 } else if (json_to_short_channel_id(buffer, tok, &scid)) {
2843 *channel = any_channel_by_scid(ld, scid, true);
2844 if (!*channel)
2845 return command_fail_badparam(cmd, name, buffer, tok,
2846 "Short channel id not found");
2847 return NULL;
2848 } else {
2849 return command_fail_badparam(cmd, name, buffer, tok,
2850 "should be a channel ID or short channel ID");
2851 }
2852}
2853
2854static void setup_peer(struct peer *peer)
2855{

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