mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 23:54:22 +01:00
plugin: Added .params.configuration to init call
This tells the plugin both the `lightning-dir` as well as the `rpc-filename` to use to talk to `lightningd`. Prior to this they'd had to guess. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
@@ -45,7 +45,7 @@ def json_getmanifest(request):
|
||||
}
|
||||
|
||||
|
||||
def json_init(request, options):
|
||||
def json_init(request, options, configuration):
|
||||
"""The main daemon is telling us the relevant cli options
|
||||
"""
|
||||
global greeting
|
||||
|
||||
@@ -214,7 +214,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
||||
*code. Here we initialize the context that will keep track and control
|
||||
*the plugins.
|
||||
*/
|
||||
ld->plugins = plugins_new(ld, ld->log_book, ld->jsonrpc);
|
||||
ld->plugins = plugins_new(ld, ld->log_book, ld->jsonrpc, ld);
|
||||
|
||||
return ld;
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ struct plugins {
|
||||
struct jsonrpc *rpc;
|
||||
|
||||
struct timers timers;
|
||||
struct lightningd *ld;
|
||||
};
|
||||
|
||||
/* Represents a pending JSON-RPC request that was forwarded to a
|
||||
@@ -116,7 +117,7 @@ struct plugin_opt {
|
||||
};
|
||||
|
||||
struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book,
|
||||
struct jsonrpc *rpc)
|
||||
struct jsonrpc *rpc, struct lightningd *ld)
|
||||
{
|
||||
struct plugins *p;
|
||||
p = tal(ctx, struct plugins);
|
||||
@@ -125,6 +126,7 @@ struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book,
|
||||
p->log = new_log(p, log_book, "plugin-manager");
|
||||
p->rpc = rpc;
|
||||
timers_init(&p->timers, time_mono());
|
||||
p->ld = ld;
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -825,6 +827,7 @@ static void plugin_config(struct plugin *plugin)
|
||||
struct plugin_opt *opt;
|
||||
const char *name;
|
||||
struct plugin_request *req;
|
||||
struct lightningd *ld = plugin->plugins->ld;
|
||||
|
||||
/* No writer since we don't flush concurrently. */
|
||||
req = plugin_request_new(plugin, "init", plugin_config_cb, plugin);
|
||||
@@ -839,6 +842,12 @@ static void plugin_config(struct plugin *plugin)
|
||||
}
|
||||
json_object_end(req->stream); /* end of .params.options */
|
||||
|
||||
/* Add .params.configuration */
|
||||
json_object_start(req->stream, "configuration");
|
||||
json_add_string(req->stream, "lightning-dir", ld->config_dir);
|
||||
json_add_string(req->stream, "rpc-file", ld->rpc_filename);
|
||||
json_object_end(req->stream);
|
||||
|
||||
json_object_end(req->stream); /* end of .params */
|
||||
|
||||
plugin_request_queue(req);
|
||||
|
||||
@@ -17,7 +17,7 @@ struct plugins;
|
||||
* Create a new plugins context.
|
||||
*/
|
||||
struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book,
|
||||
struct jsonrpc *rpc);
|
||||
struct jsonrpc *rpc, struct lightningd *ld);
|
||||
|
||||
/**
|
||||
* Initialize the registered plugins.
|
||||
|
||||
@@ -140,7 +140,7 @@ void plugins_init(struct plugins *plugins UNNEEDED)
|
||||
{ fprintf(stderr, "plugins_init called!\n"); abort(); }
|
||||
/* Generated stub for plugins_new */
|
||||
struct plugins *plugins_new(const tal_t *ctx UNNEEDED, struct log_book *log_book UNNEEDED,
|
||||
struct jsonrpc *rpc UNNEEDED)
|
||||
struct jsonrpc *rpc UNNEEDED, struct lightningd *ld UNNEEDED)
|
||||
{ fprintf(stderr, "plugins_new called!\n"); abort(); }
|
||||
/* Generated stub for register_opts */
|
||||
void register_opts(struct lightningd *ld UNNEEDED)
|
||||
|
||||
Reference in New Issue
Block a user