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

Function json_check

lightningd/jsonrpc.c:1408–1451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1406}
1407
1408static struct command_result *json_check(struct command *cmd,
1409 const char *buffer,
1410 const jsmntok_t *obj UNNEEDED,
1411 const jsmntok_t *params)
1412{
1413 jsmntok_t *mod_params;
1414 const jsmntok_t *name_tok;
1415 bool failed;
1416 struct json_stream *response;
1417 struct command_result *res;
1418
1419 if (cmd->mode == CMD_USAGE) {
1420 mod_params = NULL;
1421 } else {
1422 mod_params = json_tok_copy(cmd, params);
1423 }
1424
1425 if (!param(cmd, buffer, mod_params,
1426 p_req("command_to_check", param_command, &name_tok),
1427 p_opt_any(),
1428 NULL))
1429 return command_param_failed();
1430
1431 /* Point name_tok to the name, not the value */
1432 if (params->type == JSMN_OBJECT)
1433 name_tok--;
1434
1435 json_tok_remove(&mod_params, mod_params, name_tok, 1);
1436
1437 cmd->mode = CMD_CHECK;
1438 failed = false;
1439 tal_add_destructor2(cmd, destroy_command_canary, &failed);
1440 res = cmd->json_cmd->dispatch(cmd, buffer, mod_params, mod_params);
1441
1442 /* CMD_CHECK always makes it "fail" parameter parsing. */
1443 assert(res == &param_failed);
1444
1445 if (failed)
1446 return res;
1447
1448 response = json_stream_success(cmd);
1449 json_add_string(response, "command_to_check", cmd->json_cmd->name);
1450 return command_success(cmd, response);
1451}
1452
1453static const struct json_command check_command = {
1454 "check",

Callers

nothing calls this directly

Calls 7

json_tok_copyFunction · 0.85
json_tok_removeFunction · 0.85
command_param_failedFunction · 0.70
json_stream_successFunction · 0.70
command_successFunction · 0.70
paramFunction · 0.50
json_add_stringFunction · 0.50

Tested by

no test coverage detected