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

Function json_listconfigs

lightningd/options.c:1691–1746  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1689}
1690
1691static struct command_result *json_listconfigs(struct command *cmd,
1692 const char *buffer,
1693 const jsmntok_t *obj UNNEEDED,
1694 const jsmntok_t *params)
1695{
1696 size_t i;
1697 struct json_stream *response = NULL;
1698 const char *configname;
1699
1700 if (!param(cmd, buffer, params,
1701 p_opt("config", param_string, &configname),
1702 NULL))
1703 return command_param_failed();
1704
1705 if (!configname) {
1706 response = json_stream_success(cmd);
1707 json_add_string(response, "# version", version());
1708 }
1709
1710 for (i = 0; i < opt_count; i++) {
1711 unsigned int len;
1712 const char *name;
1713
1714 /* FIXME: Print out comment somehow? */
1715 if (opt_table[i].type == OPT_SUBTABLE)
1716 continue;
1717
1718 for (name = first_name(opt_table[i].names, &len);
1719 name;
1720 name = next_name(name, &len)) {
1721 /* Skips over first -, so just need to look for one */
1722 if (name[0] != '-')
1723 continue;
1724
1725 if (configname
1726 && !memeq(configname, strlen(configname),
1727 name + 1, len - 1))
1728 continue;
1729
1730 if (!response)
1731 response = json_stream_success(cmd);
1732 add_config(cmd->ld, response, &opt_table[i],
1733 name+1, len-1);
1734 /* If we have more than one long name, first
1735 * is preferred */
1736 break;
1737 }
1738 }
1739
1740 if (configname && !response) {
1741 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
1742 "Unknown config option %s",
1743 configname);
1744 }
1745 return command_success(cmd, response);
1746}
1747
1748static const struct json_command listconfigs_command = {

Callers

nothing calls this directly

Calls 11

memeqFunction · 0.85
add_configFunction · 0.85
command_param_failedFunction · 0.70
json_stream_successFunction · 0.70
first_nameFunction · 0.70
next_nameFunction · 0.70
command_failFunction · 0.70
command_successFunction · 0.70
paramFunction · 0.50
json_add_stringFunction · 0.50
versionFunction · 0.50

Tested by

no test coverage detected