The example test uses a rpc call `summary` that isn't available (anymore) The assert should be lowercase, otherwise it fails.
Plugins for c-lightning
Community curated plugins for c-lightning.
Available plugins
| Name | Short description |
|---|---|
| autopilot | An autopilot that suggests channels that should be established |
| boltz-channel-creation | A c-lightning plugin for Boltz Channel Creation Swaps |
| csvexportpays | A plugin that exports all payments to a CSV file |
| donations | A simple donations page to accept donations from the web |
| drain | Draining, filling and balancing channels with automatic chunks. |
| event-websocket | Exposes notifications over a Websocket |
| feeadjuster | Dynamic fees to keep your channels more balanced |
| graphql | Exposes the c-lightning API over graphql |
| invoice-queue | Listen to lightning invoices from multiple nodes and send to a redis queue for processing |
| lightning-qt | A bitcoin-qt-like GUI for lightningd |
| monitor | helps you analyze the health of your peers and channels |
| persistent-channels | Maintains a number of channels to peers |
| probe | Regularly probes the network for stability |
| prometheus | Lightning node exporter for the prometheus timeseries server |
| pruning | This plugin manages pruning of bitcoind such that it can always sync |
| rebalance | Keeps your channels balanced |
| reckless | An experimental plugin manager (search/install plugins) |
| sauron | A Bitcoin backend relying on Esplora's API |
| sitzprobe | A Lightning Network payment rehearsal utility |
| sparko | RPC over HTTP with fine-grained permissions, SSE and spark-wallet support |
| summary | Print a nice summary of the node status |
| trustedcoin | Replace your Bitcoin Core with data from public block explorers |
| webhook | Dispatches webhooks based from event notifications |
| zmq | Publishes notifications via ZeroMQ to configured endpoints |
Installation
To install and activate a plugin you need to stop your lightningd and restart it
with the plugin argument like this:
lightningd --plugin=/path/to/plugin/directory/plugin_file_name.py
Notes:
- The
plugin_file_name.pymust have executable permissions:chmod a+x plugin_file_name.py - A plugin can be written in any programming language, as it interacts with
lightningdpurely using stdin/stdout pipes.
Automatic plugin initialization
Alternatively, especially when you use multiple plugins, you can copy or symlink
all plugin directories into your ~/.lightning/plugins directory. The daemon
will load each executeable it finds in sub-directories as a plugin. In this case
you don't need to manage all the --plugin=... parameters.
PYTHONPATH and pyln
To simplify plugin development you can rely on pyln-client for the plugin
implementation, pyln-proto if you need to parse or write lightning protocol
messages, and pyln-testing in order to write tests. These libraries can be
retrieved in a number of different ways:
- Using
piptools:pip3 install pyln-client pyln-testing - Using the
PYTHONPATHenvironment variable to include your clightning's shippedpyln-*libraries:
export PYTHONPATH=/path/to/lightnind/contrib/pyln-client:/path/to/lightnind/contrib/pyln-testing:$PYTHONPATH
Writing tests
The pyln-testing library provides a number of helpers and fixtures to write
tests. While not strictly necessary, writing a test will ensure that your
plugin is working correctly against a number of configurations (both with and
without DEVELOPER, COMPAT and EXPERIMENTAL_FEATURES), and more
importantly that they will continue to work with newly release versions of
c-lightning.
Writing a test is as simple as this:
- The framework will look for unittest filenames starting with
test_. - The test functions should also start with
test_.
from pyln.testing.fixtures import *
pluginopt = {'plugin': os.path.join(os.path.dirname(__file__), "YOUR_PLUGIN.py")}
def test_your_plugin(node_factory, bitcoind):
l1 = node_factory.get_node(options=pluginopt)
s = l1.rpc.getinfo()
assert(s['network'] == 'regtest')
Tests are run against pull requests, all commits on master, as well as once
ever 24 hours to test against the latest master branch of the c-lightning
development tree.
Running tests locally can be done like this:
(make sure the PYTHONPATH env variable is correct)
pytest YOUR_PLUGIN/YOUR_TEST.py
Additional dependencies
Additionally, some Python plugins come with a requirements.txt which can be
used to install the plugin's dependencies using the pip tools:
pip3 install -r requirements.txt
Note: You might need to also specify the --user command line flag depending on
your environment.
More Plugins from the Community
- @conscott's plugins
- @renepickhardt's plugins
- @rsbondi's plugins
- c-lightning plugins emulating commands of LND (lncli)
Plugin Builder Resources
- Description of the plugin API
- C Plugin API by @rustyrussell
- Python Plugin API & RPC Client (PyPI) by @cdecker and a video tutorial by @renepickhardt
- Go Plugin API & RPC Client by @niftynei
- C++ Plugin API & RPC Client by @darosior
- Javascript Plugin API & RPC Client by @darosior