-
Notifications
You must be signed in to change notification settings - Fork 1k
RPC plugin management #2771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RPC plugin management #2771
Changes from all commits
4648e22
039dd9c
15fd7bc
84bab9f
4d68a88
fc511a6
ee9457f
6ea0964
96d06c8
3a85aa5
a298c50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |
| - build: now requires `python3-mako` to be installed, i.e. `sudo apt-get install python3-mako` | ||
| - plugins: a new notification type `invoice_payment` (sent when an invoice is paid) has been added | ||
| - plugins: a new 'channel_opened' notification type is added, which is emitted when a peer succesfully funds a channel to us | ||
| - rpc: a new rpc command is added, `plugin`. It allows one to manage plugins without restarting `lightningd`. | ||
| - plugins: a new boolean field is added to the `init`'s `configuration`, `startup`. It allows a plugin to know if it has been started on `lightningd` startup. | ||
| - plugins: a new boolean field can be added to a plugin manifest, `dynamic`. It allows a plugin to tell if it can be started or stopped "on-the-fly". | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll probably collapse these three lines into "plugins: dynamic plugin support", which is the better summary for this level IMHO. (I do a CHANGELOG.md cleanup sweep as part of the release process, so I won't hold up the merge for this!) |
||
|
|
||
| ### Deprecated | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -714,6 +714,51 @@ def ping(self, peer_id, length=128, pongbytes=128): | |
| } | ||
| return self.call("ping", payload) | ||
|
|
||
| def plugin_start(self, plugin): | ||
| """ | ||
| Adds a plugin to lightningd. | ||
| """ | ||
| payload = { | ||
| "subcommand": "start", | ||
| "plugin": plugin | ||
| } | ||
| return self.call("plugin", payload) | ||
|
|
||
| def plugin_startdir(self, directory): | ||
| """ | ||
| Adds all plugins from a directory to lightningd. | ||
| """ | ||
| payload = { | ||
| "subcommand": "startdir", | ||
| "directory": directory | ||
| } | ||
| return self.call("plugin", payload) | ||
|
|
||
| def plugin_stop(self, plugin): | ||
| """ | ||
| Stops a lightningd plugin, will fail if plugin is not dynamic. | ||
| """ | ||
| payload = { | ||
| "subcommand": "stop", | ||
| "plugin": plugin | ||
| } | ||
| return self.call("plugin", payload) | ||
|
|
||
| def plugin_list(self): | ||
| """ | ||
| Lists all plugins lightningd knows about. | ||
| """ | ||
| payload = { | ||
| "subcommand": "list" | ||
| } | ||
| return self.call("plugin", payload) | ||
|
|
||
| def plugin_rescan(self): | ||
| payload = { | ||
| "subcommand": "rescan" | ||
| } | ||
| return self.call("plugin", payload) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, discarding parameters if we don't know the subcommand seems wrong? I think we need to whitelist the known parameters?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand, do you mean whitelist on the C side ? Like accepting parameters for } else if (streq(subcmd, "reload")) {
if (!param(cmd, buffer, params,
p_req("subcommand", param_ignore, cmd),
NULL))
return command_param_failed();
plugins_add_default_dir(cmd->ld->plugins,
path_join(tmpctx, cmd->ld->config_dir, "plugins"));
} else if (streq(subcmd, "list")) {
if (!param(cmd, buffer, params,
p_req("subcommand", param_ignore, cmd),
NULL))
return command_param_failed();
/* Don't do anything as we return the plugin list anyway */
}
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should rewrite this into multiple calls that map to the various
That way we have something to attach the specific help messages to instead of handling opaque sets of parameters? |
||
|
|
||
| def sendpay(self, route, payment_hash, description=None, msatoshi=None): | ||
| """ | ||
| Send along {route} in return for preimage of {payment_hash} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| '\" t | ||
| .\" Title: lightning-plugin | ||
| .\" Author: [see the "AUTHOR" section] | ||
| .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> | ||
| .\" Date: 07/23/2019 | ||
| .\" Manual: \ \& | ||
| .\" Source: \ \& | ||
| .\" Language: English | ||
| .\" | ||
| .TH "LIGHTNING\-PLUGIN" "7" "07/23/2019" "\ \&" "\ \&" | ||
| .\" ----------------------------------------------------------------- | ||
| .\" * Define some portability stuff | ||
| .\" ----------------------------------------------------------------- | ||
| .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| .\" http://bugs.debian.org/507673 | ||
| .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html | ||
| .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| .ie \n(.g .ds Aq \(aq | ||
| .el .ds Aq ' | ||
| .\" ----------------------------------------------------------------- | ||
| .\" * set default formatting | ||
| .\" ----------------------------------------------------------------- | ||
| .\" disable hyphenation | ||
| .nh | ||
| .\" disable justification (adjust text to left margin only) | ||
| .ad l | ||
| .\" ----------------------------------------------------------------- | ||
| .\" * MAIN CONTENT STARTS HERE * | ||
| .\" ----------------------------------------------------------------- | ||
| .SH "NAME" | ||
| lightning-plugin \- Manage plugins with RPC | ||
| .SH "SYNOPSIS" | ||
| .sp | ||
| \fBplugin\fR command [parameter] [second_parameter] | ||
| .SH "DESCRIPTION" | ||
| .sp | ||
| The \fBplugin\fR RPC command allows to manage plugins without having to restart lightningd\&. It takes 1 to 3 parameters: a command (start/stop/startdir/rescan/list) which describes the action to take and optionally one or two parameters which describes the plugin on which the action has to be taken\&. | ||
| .sp | ||
| The \fIstart\fR command takes a path as parameter and will load the plugin available from this path\&. | ||
| .sp | ||
| The \fIstop\fR command takes a plugin name as parameter and will kill and unload the specified plugin\&. | ||
| .sp | ||
| The \fIstartdir\fR command takes a directory path as parameter and will load all plugins this directory contains\&. | ||
| .sp | ||
| The \fIrescan\fR command starts all not\-already\-loaded plugins from the default plugins directory (by default \fI~/\&.lightning/plugins\fR)\&. | ||
| .sp | ||
| The \fIlist\fR command will return all the active plugins\&. | ||
| .SH "RETURN VALUE" | ||
| .sp | ||
| On success, this returns an array \fIplugins\fR of objects, one by plugin\&. Each object contains the name of the plugin (\fIname\fR field) and its status (\fIactive\fR boolean field)\&. Since plugins are configured asynchronously, a freshly started plugin may not appear immediately\&. | ||
| .SH "AUTHOR" | ||
| .sp | ||
| Antoine Poinsot <darosior@protonmail\&.com> is mainly responsible\&. | ||
| .SH "RESOURCES" | ||
| .sp | ||
| Main web site: https://github\&.com/ElementsProject/lightning |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| LIGHTNING-PLUGIN(7) | ||
| =================== | ||
| :doctype: manpage | ||
|
|
||
| NAME | ||
| ---- | ||
| lightning-plugin - Manage plugins with RPC | ||
|
|
||
| SYNOPSIS | ||
| -------- | ||
| *plugin* command [parameter] [second_parameter] | ||
|
|
||
| DESCRIPTION | ||
| ----------- | ||
|
|
||
| The *plugin* RPC command allows to manage plugins without having to restart lightningd. | ||
| It takes 1 to 3 parameters: a command (start/stop/startdir/rescan/list) which describes the | ||
| action to take and optionally one or two parameters which describes the plugin on which | ||
| the action has to be taken. | ||
|
|
||
| The 'start' command takes a path as parameter and will load the plugin available from this | ||
|
darosior marked this conversation as resolved.
|
||
| path. | ||
|
|
||
| The 'stop' command takes a plugin name as parameter and will kill and unload the specified | ||
| plugin. | ||
|
|
||
| The 'startdir' command takes a directory path as parameter and will load all plugins this | ||
| directory contains. | ||
|
|
||
| The 'rescan' command starts all not-already-loaded plugins from the default plugins directory | ||
| (by default '~/.lightning/plugins'). | ||
|
|
||
| The 'list' command will return all the active plugins. | ||
|
|
||
| RETURN VALUE | ||
| ------------ | ||
|
|
||
| On success, this returns an array 'plugins' of objects, one by plugin. Each object contains | ||
| the name of the plugin ('name' field) and its status ('active' boolean field). | ||
| Since plugins are configured asynchronously, a freshly started plugin may not appear immediately. | ||
|
|
||
| AUTHOR | ||
| ------ | ||
| Antoine Poinsot <darosior@protonmail.com> is mainly responsible. | ||
|
|
||
| RESOURCES | ||
| --------- | ||
| Main web site: https://github.com/ElementsProject/lightning | ||
Uh oh!
There was an error while loading. Please reload this page.