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

Function json_dev_feerate

lightningd/channel_control.c:1113–1155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1111
1112#if DEVELOPER
1113static struct command_result *json_dev_feerate(struct command *cmd,
1114 const char *buffer,
1115 const jsmntok_t *obj UNNEEDED,
1116 const jsmntok_t *params)
1117{
1118 u32 *feerate;
1119 struct node_id *id;
1120 struct peer *peer;
1121 struct json_stream *response;
1122 struct channel *channel;
1123 const u8 *msg;
1124 bool more_than_one;
1125
1126 if (!param(cmd, buffer, params,
1127 p_req("id", param_node_id, &id),
1128 p_req("feerate", param_number, &feerate),
1129 NULL))
1130 return command_param_failed();
1131
1132 peer = peer_by_id(cmd->ld, id);
1133 if (!peer)
1134 return command_fail(cmd, LIGHTNINGD, "Peer not connected");
1135
1136 channel = peer_any_active_channel(peer, &more_than_one);
1137 if (!channel || !channel->owner || channel->state != CHANNELD_NORMAL)
1138 return command_fail(cmd, LIGHTNINGD, "Peer bad state");
1139 /* This is a dev command: fix the api if you need this! */
1140 if (more_than_one)
1141 return command_fail(cmd, LIGHTNINGD, "More than one channel");
1142
1143 msg = towire_channeld_feerates(NULL, *feerate,
1144 feerate_min(cmd->ld, NULL),
1145 feerate_max(cmd->ld, NULL),
1146 try_get_feerate(cmd->ld->topology,
1147 FEERATE_PENALTY));
1148 subd_send_msg(channel->owner, take(msg));
1149
1150 response = json_stream_success(cmd);
1151 json_add_node_id(response, "id", id);
1152 json_add_u32(response, "feerate", *feerate);
1153
1154 return command_success(cmd, response);
1155}
1156
1157static const struct json_command dev_feerate_command = {
1158 "dev-feerate",

Callers

nothing calls this directly

Calls 13

peer_by_idFunction · 0.85
feerate_minFunction · 0.85
feerate_maxFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
peer_any_active_channelFunction · 0.70
try_get_feerateFunction · 0.70
subd_send_msgFunction · 0.70
json_stream_successFunction · 0.70
command_successFunction · 0.70
paramFunction · 0.50
json_add_node_idFunction · 0.50

Tested by

no test coverage detected