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

Function json_check

lightningd/jsonrpc.c:1611–1653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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