Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/plugins/helloworld.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lightningd/lightningd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 10 additions & 1 deletion lightningd/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should remove log_book and rpc here, and replace by ld->log_book and log->rpc in follow.

{
struct plugins *p;
p = tal(ctx, struct plugins);
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
Expand All @@ -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");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"dir", "params", "configuration".... One of these is not like the other :)

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);
Expand Down
2 changes: 1 addition & 1 deletion lightningd/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lightningd/test/run-find_my_abspath.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down