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

Function json_listforwards

lightningd/forwards.c:187–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187static struct command_result *json_listforwards(struct command *cmd,
188 const char *buffer,
189 const jsmntok_t *obj UNNEEDED,
190 const jsmntok_t *params)
191{
192
193 struct json_stream *response;
194 struct short_channel_id *chan_in, *chan_out;
195 enum forward_status *status;
196 enum wait_index *listindex;
197 u64 *liststart;
198 u32 *listlimit;
199
200 if (!param(cmd, buffer, params,
201 p_opt_def("status", param_forward_status, &status,
202 FORWARD_ANY),
203 p_opt("in_channel", param_short_channel_id, &chan_in),
204 p_opt("out_channel", param_short_channel_id, &chan_out),
205 p_opt("index", param_index, &listindex),
206 p_opt_def("start", param_u64, &liststart, 0),
207 p_opt("limit", param_u32, &listlimit),
208 NULL))
209 return command_param_failed();
210
211 if (*liststart != 0 && !listindex) {
212 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
213 "Can only specify {start} with {index}");
214 }
215 if (listlimit && !listindex) {
216 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
217 "Can only specify {limit} with {index}");
218 }
219
220 if ((chan_in || chan_out) && *liststart != 0) {
221 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
222 "Cannot use start with in_channel or out_channel");
223 }
224
225 response = json_stream_success(cmd);
226 listforwardings_add_forwardings(response, cmd->ld->wallet, *status, chan_in, chan_out, listindex, *liststart, listlimit);
227
228 return command_success(cmd, response);
229}
230
231static const struct json_command listforwards_command = {
232 "listforwards",

Callers

nothing calls this directly

Calls 6

command_param_failedFunction · 0.70
command_failFunction · 0.70
json_stream_successFunction · 0.70
command_successFunction · 0.70
paramFunction · 0.50

Tested by

no test coverage detected