| 3088 | AUTODATA(json_command, &listpeerchannels_command); |
| 3089 | |
| 3090 | struct command_result * |
| 3091 | command_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 | |
| 3128 | static void setup_peer(struct peer *peer) |
| 3129 | { |
no test coverage detected