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

Function json_check

lightningd/jsonrpc.c:1606–1648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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