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

Function json_help

lightningd/jsonrpc.c:448–499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446}
447
448static struct command_result *json_help(struct command *cmd,
449 const char *buffer,
450 const jsmntok_t *obj UNNEEDED,
451 const jsmntok_t *params)
452{
453 const char *cmdname;
454 struct cmd_and_usage *one_cmd;
455 struct json_help_info hinfo;
456
457 if (!param_check(cmd, buffer, params,
458 p_opt("command", param_string, &cmdname),
459 NULL))
460 return command_param_failed();
461
462 if (cmdname) {
463 one_cmd = strmap_get(&cmd->ld->jsonrpc->cmdmap, cmdname);
464 if (!one_cmd)
465 return command_fail(cmd, JSONRPC2_METHOD_NOT_FOUND,
466 "Unknown command %s",
467 cmdname);
468 if (!command_deprecated_in_ok(cmd, NULL,
469 one_cmd->command->depr_start,
470 one_cmd->command->depr_end))
471 return command_fail(cmd, JSONRPC2_METHOD_NOT_FOUND,
472 "Deprecated command %s",
473 cmdname);
474 if (!cmd->ld->developer && one_cmd->command->dev_only)
475 return command_fail(cmd, JSONRPC2_METHOD_NOT_FOUND,
476 "Developer-only command %s",
477 cmdname);
478 } else
479 one_cmd = NULL;
480
481 if (command_check_only(cmd))
482 return command_check_done(cmd);
483
484 hinfo.cmd = cmd;
485 hinfo.response = json_stream_success(cmd);
486 json_array_start(hinfo.response, "help");
487 if (one_cmd)
488 json_add_help_command(cmdname, one_cmd, &hinfo);
489 else {
490 strmap_iterate(&cmd->ld->jsonrpc->cmdmap,
491 json_add_help_command, &hinfo);
492 }
493 json_array_end(hinfo.response);
494
495 /* Tell cli this is simple enough to be formatted flat for humans */
496 json_add_string(hinfo.response, "format-hint", "simple");
497
498 return command_success(cmd, hinfo.response);
499}
500
501static const struct json_command *find_cmd(const struct jsonrpc *rpc,
502 const char *buffer,

Callers

nothing calls this directly

Calls 12

param_checkFunction · 0.85
json_array_startFunction · 0.85
json_add_help_commandFunction · 0.85
json_array_endFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
command_deprecated_in_okFunction · 0.70
command_check_onlyFunction · 0.70
command_check_doneFunction · 0.70
json_stream_successFunction · 0.70
command_successFunction · 0.70
json_add_stringFunction · 0.50

Tested by

no test coverage detected