mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
plugin: Add plugins to lightningd and register arguments
This commit is contained in:
parent
b6a1735929
commit
59e37c12cd
@ -176,6 +176,11 @@ Sets configuration file (default:
|
||||
\fIPATH\fR
|
||||
must exist and be readable (we allow missing files in the default case)\&. Using this inside a configuration file is meaningless\&.
|
||||
.RE
|
||||
.PP
|
||||
\fBplugin\fR=\fIPATH\fR
|
||||
.RS 4
|
||||
Specify a plugin to run as part of c\-lightning\&. This can be specified multiple times and may enable additional configuration options and JSON\-RPC methods, depending on the plugin\&.
|
||||
.RE
|
||||
.sp
|
||||
Lightning node customization options:
|
||||
.PP
|
||||
|
@ -124,6 +124,11 @@ Lightning daemon options:
|
||||
(we allow missing files in the default case).
|
||||
Using this inside a configuration file is meaningless.
|
||||
|
||||
*plugin*='PATH'::
|
||||
Specify a plugin to run as part of c-lightning. This can be specified
|
||||
multiple times and may enable additional configuration options and JSON-RPC
|
||||
methods, depending on the plugin.
|
||||
|
||||
Lightning node customization options:
|
||||
|
||||
*rgb*='RRGGBB'::
|
||||
|
@ -211,6 +211,14 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
||||
ld->tor_service_password = NULL;
|
||||
ld->max_funding_unconfirmed = 2016;
|
||||
|
||||
/*~ We run a number of plugins (subprocesses that we talk JSON-RPC with)
|
||||
*alongside this process. This allows us to have an easy way for users
|
||||
*to add their own tools without having to modify the c-lightning source
|
||||
*code. Here we initialize the context that will keep track and control
|
||||
*the plugins.
|
||||
*/
|
||||
ld->plugins = plugins_new(ld);
|
||||
|
||||
return ld;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <ccan/time/time.h>
|
||||
#include <ccan/timer/timer.h>
|
||||
#include <lightningd/htlc_end.h>
|
||||
#include <lightningd/plugin.h>
|
||||
#include <stdio.h>
|
||||
#include <wallet/txfilter.h>
|
||||
#include <wallet/wallet.h>
|
||||
@ -203,6 +204,8 @@ struct lightningd {
|
||||
bool use_proxy_always;
|
||||
char *tor_service_password;
|
||||
bool pure_tor_setup;
|
||||
|
||||
struct plugins *plugins;
|
||||
};
|
||||
|
||||
const struct chainparams *get_chainparams(const struct lightningd *ld);
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <lightningd/log.h>
|
||||
#include <lightningd/options.h>
|
||||
#include <lightningd/param.h>
|
||||
#include <lightningd/plugin.h>
|
||||
#include <lightningd/subd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -286,11 +287,23 @@ static char *opt_add_proxy_addr(const char *arg, struct lightningd *ld)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *opt_add_plugin(const char *arg, struct lightningd *ld)
|
||||
{
|
||||
plugin_register(ld->plugins, arg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void config_register_opts(struct lightningd *ld)
|
||||
{
|
||||
opt_register_early_arg("--conf=<file>", opt_set_talstr, NULL,
|
||||
&ld->config_filename,
|
||||
"Specify configuration file. Relative paths will be prefixed by lightning-dir location. (default: config)");
|
||||
|
||||
/* Register plugins as an early argc, so we can initialize them and have
|
||||
* them register more command line options */
|
||||
opt_register_early_arg("--plugin", opt_add_plugin, NULL, ld,
|
||||
"Add a plugin to be run.");
|
||||
|
||||
opt_register_noarg("--daemon", opt_set_bool, &ld->daemon,
|
||||
"Run in the background, suppress stdout/stderr");
|
||||
opt_register_arg("--ignore-fee-limits", opt_set_bool_arg, opt_show_bool,
|
||||
@ -957,6 +970,8 @@ static void add_config(struct lightningd *ld,
|
||||
} else if (opt->cb_arg == (void *)opt_add_proxy_addr) {
|
||||
if (ld->proxyaddr)
|
||||
answer = fmt_wireaddr(name0, ld->proxyaddr);
|
||||
} else if (opt->cb_arg == (void *)opt_add_plugin) {
|
||||
/* FIXME: Actually add the plugin options */
|
||||
#if DEVELOPER
|
||||
} else if (strstarts(name, "dev-")) {
|
||||
/* Ignore dev settings */
|
||||
|
@ -119,6 +119,9 @@ struct chain_topology *new_topology(struct lightningd *ld UNNEEDED, struct log *
|
||||
/* Generated stub for onchaind_replay_channels */
|
||||
void onchaind_replay_channels(struct lightningd *ld UNNEEDED)
|
||||
{ fprintf(stderr, "onchaind_replay_channels called!\n"); abort(); }
|
||||
/* Generated stub for plugins_new */
|
||||
struct plugins *plugins_new(const tal_t *ctx UNNEEDED)
|
||||
{ fprintf(stderr, "plugins_new called!\n"); abort(); }
|
||||
/* Generated stub for register_opts */
|
||||
void register_opts(struct lightningd *ld UNNEEDED)
|
||||
{ fprintf(stderr, "register_opts called!\n"); abort(); }
|
||||
|
Loading…
Reference in New Issue
Block a user