Browse Source

plugin: Add listconfigs stub for the --plugin option

trytravis
Christian Decker 6 years ago
parent
commit
c71f4f3bd9
  1. 2
      lightningd/options.c
  2. 15
      lightningd/plugin.c
  3. 10
      lightningd/plugin.h

2
lightningd/options.c

@ -971,7 +971,7 @@ static void add_config(struct lightningd *ld,
if (ld->proxyaddr)
answer = fmt_wireaddr(name0, ld->proxyaddr);
} else if (opt->cb_arg == (void *)opt_add_plugin) {
/* FIXME: Actually add the plugin options */
json_add_opt_plugins(response, ld->plugins);
#if DEVELOPER
} else if (strstarts(name, "dev-")) {
/* Ignore dev settings */

15
lightningd/plugin.c

@ -2,6 +2,8 @@
#include <ccan/list/list.h>
#include <ccan/tal/str/str.h>
#include <lightningd/json.h>
#include <unistd.h>
struct plugin {
int stdin, stdout;
@ -33,3 +35,16 @@ void plugin_register(struct plugins *plugins, const char* path TAKES)
void plugins_init(struct plugins *plugins)
{
}
void json_add_opt_plugins(struct json_stream *response,
const struct plugins *plugins)
{
struct plugin *p;
json_object_start(response, "plugin");
for (size_t i=0; i<tal_count(plugins->plugins); i++) {
p = plugins->plugins[i];
json_object_start(response, p->cmd);
json_object_end(response);
}
json_object_end(response);
}

10
lightningd/plugin.h

@ -3,6 +3,7 @@
#include "config.h"
#include <ccan/take/take.h>
#include <ccan/tal/tal.h>
#include <lightningd/jsonrpc.h>
/**
* A collection of plugins, and some associated information.
@ -35,4 +36,13 @@ void plugins_init(struct plugins *plugins);
*/
void plugin_register(struct plugins *plugins, const char* path TAKES);
/**
* Add the plugin option and their respective options to listconfigs.
*
* This adds a dict that maps the plugin name to a dict of configuration options
* for the corresponding plugins.
*/
void json_add_opt_plugins(struct json_stream *response,
const struct plugins *plugins);
#endif /* LIGHTNING_LIGHTNINGD_PLUGIN_H */

Loading…
Cancel
Save