| 2682 | AUTODATA(json_command, &abort_channels_command); |
| 2683 | |
| 2684 | static struct command_result *json_dev_feerate(struct command *cmd, |
| 2685 | const char *buffer, |
| 2686 | const jsmntok_t *obj UNNEEDED, |
| 2687 | const jsmntok_t *params) |
| 2688 | { |
| 2689 | u32 *feerate; |
| 2690 | struct node_id *id; |
| 2691 | struct peer *peer; |
| 2692 | struct json_stream *response; |
| 2693 | struct channel *channel; |
| 2694 | const u8 *msg; |
| 2695 | bool more_than_one; |
| 2696 | |
| 2697 | if (!param_check(cmd, buffer, params, |
| 2698 | p_req("id", param_node_id, &id), |
| 2699 | p_req("feerate", param_number, &feerate), |
| 2700 | NULL)) |
| 2701 | return command_param_failed(); |
| 2702 | |
| 2703 | peer = peer_by_id(cmd->ld, id); |
| 2704 | if (!peer) |
| 2705 | return command_fail(cmd, LIGHTNINGD, "Peer not connected"); |
| 2706 | |
| 2707 | channel = peer_any_channel_bystate(peer, channel_state_can_add_htlc, |
| 2708 | &more_than_one); |
| 2709 | if (!channel || !channel->owner) |
| 2710 | return command_fail(cmd, LIGHTNINGD, "Peer bad state"); |
| 2711 | /* This is a dev command: fix the api if you need this! */ |
| 2712 | if (more_than_one) |
| 2713 | return command_fail(cmd, LIGHTNINGD, "More than one channel"); |
| 2714 | |
| 2715 | if (command_check_only(cmd)) |
| 2716 | return command_check_done(cmd); |
| 2717 | |
| 2718 | msg = towire_channeld_feerates(NULL, *feerate, |
| 2719 | feerate_min(cmd->ld, NULL), |
| 2720 | feerate_max(cmd->ld, NULL), |
| 2721 | penalty_feerate(cmd->ld->topology), |
| 2722 | opening_feerate(cmd->ld->topology), |
| 2723 | splice_feerate(cmd->ld->topology, cmd->ld)); |
| 2724 | subd_send_msg(channel->owner, take(msg)); |
| 2725 | |
| 2726 | response = json_stream_success(cmd); |
| 2727 | json_add_node_id(response, "id", id); |
| 2728 | json_add_u32(response, "feerate", *feerate); |
| 2729 | |
| 2730 | return command_success(cmd, response); |
| 2731 | } |
| 2732 | |
| 2733 | static const struct json_command dev_feerate_command = { |
| 2734 | "dev-feerate", |
nothing calls this directly
no test coverage detected