| 3705 | } |
| 3706 | |
| 3707 | static struct command_result *json_setchannel(struct command *cmd, |
| 3708 | const char *buffer, |
| 3709 | const jsmntok_t *obj UNNEEDED, |
| 3710 | const jsmntok_t *params) |
| 3711 | { |
| 3712 | struct json_stream *response; |
| 3713 | struct peer *peer; |
| 3714 | struct channel **channels; |
| 3715 | u32 *base, *ppm, *delaysecs; |
| 3716 | struct amount_msat *htlc_min, *htlc_max; |
| 3717 | bool *ignore_fee_limits; |
| 3718 | |
| 3719 | /* Parse the JSON command */ |
| 3720 | if (!param_check(cmd, buffer, params, |
| 3721 | p_req("id", param_channel_or_all, &channels), |
| 3722 | p_opt("feebase", param_msat_u32, &base), |
| 3723 | p_opt("feeppm", param_number, &ppm), |
| 3724 | p_opt("htlcmin", param_msat, &htlc_min), |
| 3725 | p_opt("htlcmax", param_msat, &htlc_max), |
| 3726 | p_opt_def("enforcedelay", param_number, &delaysecs, 600), |
| 3727 | p_opt("ignorefeelimits", param_bool, &ignore_fee_limits), |
| 3728 | NULL)) |
| 3729 | return command_param_failed(); |
| 3730 | |
| 3731 | /* Prevent obviously incorrect things! */ |
| 3732 | if (htlc_min && htlc_max |
| 3733 | && amount_msat_less(*htlc_max, *htlc_min)) { |
| 3734 | return command_fail(cmd, LIGHTNINGD, |
| 3735 | "htlcmax cannot be less than htlcmin"); |
| 3736 | } |
| 3737 | |
| 3738 | if (command_check_only(cmd)) |
| 3739 | return command_check_done(cmd); |
| 3740 | |
| 3741 | /* Open JSON response object for later iteration */ |
| 3742 | response = json_stream_success(cmd); |
| 3743 | json_array_start(response, "channels"); |
| 3744 | |
| 3745 | /* If the users requested 'all' channels we need to iterate */ |
| 3746 | if (channels == NULL) { |
| 3747 | struct peer_node_id_map_iter it; |
| 3748 | |
| 3749 | for (peer = peer_node_id_map_first(cmd->ld->peers, &it); |
| 3750 | peer; |
| 3751 | peer = peer_node_id_map_next(cmd->ld->peers, &it)) { |
| 3752 | struct channel *channel; |
| 3753 | list_for_each(&peer->channels, channel, list) { |
| 3754 | /* cppcheck-suppress uninitvar - false positive on channel */ |
| 3755 | if (!channel_state_can_setchannel(channel->state)) |
| 3756 | continue; |
| 3757 | set_channel_config(cmd, channel, base, ppm, |
| 3758 | htlc_min, htlc_max, |
| 3759 | *delaysecs, ignore_fee_limits, |
| 3760 | response); |
| 3761 | } |
| 3762 | } |
| 3763 | /* single peer should be updated */ |
| 3764 | } else { |
nothing calls this directly
no test coverage detected