| 3983 | } |
| 3984 | |
| 3985 | static struct command_result *json_setchannel(struct command *cmd, |
| 3986 | const char *buffer, |
| 3987 | const jsmntok_t *obj UNNEEDED, |
| 3988 | const jsmntok_t *params) |
| 3989 | { |
| 3990 | struct json_stream *response; |
| 3991 | struct peer *peer; |
| 3992 | struct channel **channels; |
| 3993 | u32 *base, *ppm, *delaysecs; |
| 3994 | struct amount_msat *htlc_min, *htlc_max; |
| 3995 | bool *ignore_fee_limits; |
| 3996 | |
| 3997 | /* Parse the JSON command */ |
| 3998 | if (!param_check(cmd, buffer, params, |
| 3999 | p_req("id", param_channel_or_all, &channels), |
| 4000 | p_opt("feebase", param_msat_u32, &base), |
| 4001 | p_opt("feeppm", param_number, &ppm), |
| 4002 | p_opt("htlcmin", param_msat, &htlc_min), |
| 4003 | p_opt("htlcmax", param_msat, &htlc_max), |
| 4004 | p_opt_def("enforcedelay", param_number, &delaysecs, 600), |
| 4005 | p_opt("ignorefeelimits", param_bool, &ignore_fee_limits), |
| 4006 | NULL)) |
| 4007 | return command_param_failed(); |
| 4008 | |
| 4009 | /* Prevent obviously incorrect things! */ |
| 4010 | if (htlc_min && htlc_max |
| 4011 | && amount_msat_less(*htlc_max, *htlc_min)) { |
| 4012 | return command_fail(cmd, LIGHTNINGD, |
| 4013 | "htlcmax cannot be less than htlcmin"); |
| 4014 | } |
| 4015 | |
| 4016 | if (command_check_only(cmd)) |
| 4017 | return command_check_done(cmd); |
| 4018 | |
| 4019 | /* Open JSON response object for later iteration */ |
| 4020 | response = json_stream_success(cmd); |
| 4021 | json_array_start(response, "channels"); |
| 4022 | |
| 4023 | /* If the users requested 'all' channels we need to iterate */ |
| 4024 | if (channels == NULL) { |
| 4025 | struct peer_node_id_map_iter it; |
| 4026 | |
| 4027 | for (peer = peer_node_id_map_first(cmd->ld->peers, &it); |
| 4028 | peer; |
| 4029 | peer = peer_node_id_map_next(cmd->ld->peers, &it)) { |
| 4030 | struct channel *channel; |
| 4031 | list_for_each(&peer->channels, channel, list) { |
| 4032 | /* cppcheck-suppress uninitvar - false positive on channel */ |
| 4033 | if (!channel_state_can_setchannel(channel->state)) |
| 4034 | continue; |
| 4035 | set_channel_config(cmd, channel, base, ppm, |
| 4036 | htlc_min, htlc_max, |
| 4037 | *delaysecs, ignore_fee_limits, |
| 4038 | response); |
| 4039 | } |
| 4040 | } |
| 4041 | /* single peer should be updated */ |
| 4042 | } else { |
nothing calls this directly
no test coverage detected