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

Function execute_command

plugins/commando.c:274–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272}
273
274static struct command_result *execute_command(struct command *cmd,
275 struct cond_info *cinfo)
276{
277 struct out_req *req;
278
279 /* We handle success and failure the same */
280 req = jsonrpc_request_whole_object_start(cmd,
281 json_strdup(tmpctx, cinfo->buf, cinfo->method),
282 cinfo->cmdid_prefix,
283 cmd_done, cinfo->incoming);
284 if (cinfo->params) {
285 size_t i;
286 const jsmntok_t *t;
287
288 /* FIXME: This is ugly! */
289 if (cinfo->params->type == JSMN_OBJECT) {
290 json_object_start(req->js, "params");
291 json_for_each_obj(i, t, cinfo->params) {
292 json_add_jsonstr(req->js,
293 json_strdup(tmpctx, cinfo->buf, t),
294 json_tok_full(cinfo->buf, t+1),
295 json_tok_full_len(t+1));
296 }
297 json_object_end(req->js);
298 } else {
299 assert(cinfo->params->type == JSMN_ARRAY);
300 json_array_start(req->js, "params");
301 json_for_each_arr(i, t, cinfo->params) {
302 json_add_jsonstr(req->js,
303 NULL,
304 json_tok_full(cinfo->buf, t),
305 json_tok_full_len(t));
306 }
307 json_array_end(req->js);
308 }
309 } else {
310 json_object_start(req->js, "params");
311 json_object_end(req->js);
312 }
313
314 if (cinfo->filter) {
315 json_add_jsonstr(req->js, "filter",
316 json_tok_full(cinfo->buf, cinfo->filter),
317 json_tok_full_len(cinfo->filter));
318 }
319 return send_outreq(req);
320}
321
322static struct command_result *checkrune_done(struct command *cmd,
323 const char *method,

Callers 1

checkrune_doneFunction · 0.85

Calls 9

json_object_startFunction · 0.85
json_add_jsonstrFunction · 0.85
json_object_endFunction · 0.85
json_array_startFunction · 0.85
json_array_endFunction · 0.85
send_outreqFunction · 0.70
json_strdupFunction · 0.50
json_tok_fullFunction · 0.50
json_tok_full_lenFunction · 0.50

Tested by

no test coverage detected