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

Function json_check

lightningd/jsonrpc.c:1608–1650  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1606}
1607
1608static struct command_result *json_check(struct command *cmd,
1609 const char *buffer,
1610 const jsmntok_t *obj,
1611 const jsmntok_t *params)
1612{
1613 jsmntok_t *mod_params;
1614 const jsmntok_t *name_tok;
1615 struct command_result *res;
1616 struct lightningd *ld = cmd->ld;
1617
1618 if (cmd->mode == CMD_USAGE) {
1619 mod_params = NULL;
1620 } else {
1621 mod_params = json_tok_copy(cmd, params);
1622 }
1623
1624 /* Replaces cmd->json_cmd: */
1625 if (!param(cmd, buffer, mod_params,
1626 p_req("command_to_check", param_command, &name_tok),
1627 p_opt_any(),
1628 NULL))
1629 return command_param_failed();
1630
1631 cmd->mode = CMD_CHECK;
1632 /* Make *sure* it doesn't try to manip db! */
1633 db_set_readonly(ld->wallet->db, true);
1634
1635 /* Raw check hook is needed for plugins */
1636 if (cmd->json_cmd->check) {
1637 res = cmd->json_cmd->check(cmd, buffer, obj, params);
1638 } else {
1639 /* Point name_tok to the name, not the value */
1640 if (params->type == JSMN_OBJECT)
1641 name_tok--;
1642
1643 json_tok_remove(&mod_params, mod_params, name_tok, 1);
1644
1645 res = cmd->json_cmd->dispatch(cmd, buffer, mod_params, mod_params);
1646 }
1647 db_set_readonly(ld->wallet->db, false);
1648
1649 return res;
1650}
1651
1652static const struct json_command check_command = {
1653 "check",

Callers

nothing calls this directly

Calls 6

json_tok_copyFunction · 0.85
json_tok_removeFunction · 0.85
command_param_failedFunction · 0.70
paramFunction · 0.50
db_set_readonlyFunction · 0.50
checkMethod · 0.45

Tested by

no test coverage detected