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

Function plugin_add_params

lightningd/plugin.c:1577–1620  ·  view source on GitHub ↗

Start command might have included plugin-specific parameters. * We make sure they *are* parameters for this plugin, then add them * to our configvars. */

Source from the content-addressed store, hash-verified

1575 * We make sure they *are* parameters for this plugin, then add them
1576 * to our configvars. */
1577static const char *plugin_add_params(const struct plugin *plugin)
1578{
1579 size_t i;
1580 const jsmntok_t *t;
1581
1582 if (!plugin->params)
1583 return NULL;
1584
1585 json_for_each_obj(i, t, plugin->params) {
1586 struct opt_table *ot;
1587 const char *name = json_strdup(tmpctx, plugin->parambuf, t);
1588 struct configvar *cv;
1589 const char *err;
1590
1591 /* This serves two purposes; make sure we don't set an option
1592 * for a different pligin on the plugin start cmdline, and
1593 * make sure we clean it up, since we only clean our own
1594 * configvars in destroy_plugin_opt */
1595 if (!plugin_opt_find(plugin, name))
1596 return tal_fmt(plugin, "unknown parameter %s", name);
1597
1598 ot = opt_find_long(name, NULL);
1599 if (ot->type & OPT_HASARG) {
1600 name = tal_fmt(NULL, "%s=%.*s",
1601 name,
1602 t[1].end - t[1].start,
1603 plugin->parambuf + t[1].start);
1604 }
1605 cv = configvar_new(plugin->plugins->ld->configvars,
1606 CONFIGVAR_PLUGIN_START,
1607 NULL, 0, take(name));
1608 tal_arr_expand(&plugin->plugins->ld->configvars, cv);
1609
1610 /* If this fails, we free plugin and unregister the configvar */
1611 err = configvar_parse(cv, false, true,
1612 plugin->plugins->ld->developer);
1613 if (err)
1614 return err;
1615 }
1616
1617 /* We might have overridden previous configvars */
1618 configvar_finalize_overrides(plugin->plugins->ld->configvars);
1619 return NULL;
1620}
1621
1622static void plugin_manifest_timeout(struct plugin *plugin)
1623{

Callers 1

Calls 6

plugin_opt_findFunction · 0.85
opt_find_longFunction · 0.85
configvar_newFunction · 0.85
configvar_parseFunction · 0.85
json_strdupFunction · 0.50

Tested by

no test coverage detected