| 2706 | AUTODATA(json_command, &abort_channels_command); |
| 2707 | |
| 2708 | static struct command_result *json_dev_feerate(struct command *cmd, |
| 2709 | const char *buffer, |
| 2710 | const jsmntok_t *obj UNNEEDED, |
| 2711 | const jsmntok_t *params) |
| 2712 | { |
| 2713 | u32 *feerate; |
| 2714 | struct node_id *id; |
| 2715 | struct peer *peer; |
| 2716 | struct json_stream *response; |
| 2717 | struct channel *channel; |
| 2718 | const u8 *msg; |
| 2719 | bool more_than_one; |
| 2720 | |
| 2721 | if (!param_check(cmd, buffer, params, |
| 2722 | p_req("id", param_node_id, &id), |
| 2723 | p_req("feerate", param_number, &feerate), |
| 2724 | NULL)) |
| 2725 | return command_param_failed(); |
| 2726 | |
| 2727 | peer = peer_by_id(cmd->ld, id); |
| 2728 | if (!peer) |
| 2729 | return command_fail(cmd, LIGHTNINGD, "Peer not connected"); |
| 2730 | |
| 2731 | channel = peer_any_channel_bystate(peer, channel_state_can_add_htlc, |
| 2732 | &more_than_one); |
| 2733 | if (!channel || !channel->owner) |
| 2734 | return command_fail(cmd, LIGHTNINGD, "Peer bad state"); |
| 2735 | /* This is a dev command: fix the api if you need this! */ |
| 2736 | if (more_than_one) |
| 2737 | return command_fail(cmd, LIGHTNINGD, "More than one channel"); |
| 2738 | |
| 2739 | if (command_check_only(cmd)) |
| 2740 | return command_check_done(cmd); |
| 2741 | |
| 2742 | msg = towire_channeld_feerates(NULL, *feerate, |
| 2743 | feerate_min(cmd->ld, NULL), |
| 2744 | feerate_max(cmd->ld, NULL), |
| 2745 | our_feerate_max(cmd->ld, NULL), |
| 2746 | channel->ignore_fee_limits |
| 2747 | || cmd->ld->config.ignore_fee_limits, |
| 2748 | penalty_feerate(cmd->ld->topology), |
| 2749 | opening_feerate(cmd->ld->topology), |
| 2750 | splice_feerate(cmd->ld->topology, cmd->ld)); |
| 2751 | subd_send_msg(channel->owner, take(msg)); |
| 2752 | |
| 2753 | response = json_stream_success(cmd); |
| 2754 | json_add_node_id(response, "id", id); |
| 2755 | json_add_u32(response, "feerate", *feerate); |
| 2756 | |
| 2757 | return command_success(cmd, response); |
| 2758 | } |
| 2759 | |
| 2760 | static const struct json_command dev_feerate_command = { |
| 2761 | "dev-feerate", |
nothing calls this directly
no test coverage detected