MCPcopy Create free account
hub / github.com/ElementsProject/lightning / json_dev_feerate

Function json_dev_feerate

lightningd/channel_control.c:2784–2834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2782AUTODATA(json_command, &abort_channels_command);
2783
2784static struct command_result *json_dev_feerate(struct command *cmd,
2785 const char *buffer,
2786 const jsmntok_t *obj UNNEEDED,
2787 const jsmntok_t *params)
2788{
2789 u32 *feerate;
2790 struct node_id *id;
2791 struct peer *peer;
2792 struct json_stream *response;
2793 struct channel *channel;
2794 const u8 *msg;
2795 bool more_than_one;
2796
2797 if (!param_check(cmd, buffer, params,
2798 p_req("id", param_node_id, &id),
2799 p_req("feerate", param_number, &feerate),
2800 NULL))
2801 return command_param_failed();
2802
2803 peer = peer_by_id(cmd->ld, id);
2804 if (!peer)
2805 return command_fail(cmd, LIGHTNINGD, "Peer not connected");
2806
2807 channel = peer_any_channel_bystate(peer, channel_state_can_add_htlc,
2808 &more_than_one);
2809 if (!channel || !channel->owner)
2810 return command_fail(cmd, LIGHTNINGD, "Peer bad state");
2811 /* This is a dev command: fix the api if you need this! */
2812 if (more_than_one)
2813 return command_fail(cmd, LIGHTNINGD, "More than one channel");
2814
2815 if (command_check_only(cmd))
2816 return command_check_done(cmd);
2817
2818 msg = towire_channeld_feerates(NULL, *feerate,
2819 feerate_min(cmd->ld, NULL),
2820 feerate_max(cmd->ld, NULL),
2821 our_feerate_max(cmd->ld, NULL),
2822 channel->ignore_fee_limits
2823 || cmd->ld->config.ignore_fee_limits,
2824 penalty_feerate(cmd->ld->topology),
2825 opening_feerate(cmd->ld->topology),
2826 splice_feerate(cmd->ld->topology, cmd->ld));
2827 subd_send_msg(channel->owner, take(msg));
2828
2829 response = json_stream_success(cmd);
2830 json_add_node_id(response, "id", id);
2831 json_add_u32(response, "feerate", *feerate);
2832
2833 return command_success(cmd, response);
2834}
2835
2836static const struct json_command dev_feerate_command = {
2837 "dev-feerate",

Callers

nothing calls this directly

Calls 15

param_checkFunction · 0.85
peer_by_idFunction · 0.85
feerate_minFunction · 0.85
feerate_maxFunction · 0.85
our_feerate_maxFunction · 0.85
splice_feerateFunction · 0.85
json_add_node_idFunction · 0.85
json_add_u32Function · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
peer_any_channel_bystateFunction · 0.70
command_check_onlyFunction · 0.70

Tested by

no test coverage detected