Skip to main content

Plugin Options

  • Command line options passthrough allows plugins to register their own command line options that are exposed through lightningd so that only the main process needs to be configured.
  • Options can also be passed from the config file.
  • Option values are not remembered when a plugin is stopped or killed, but can be passed as parameters to plugin start.

Exercise: Add an option to your plugin

Add this code to your helloworld.py file (hint: make sure you insert this before plugin.run()):

plugin.add_option('greeting', 'Hello', 'The greeting I should use.')

Next, edit your hello RPC method from the previous step to use your option in that call:

Change the line that says:

greeting = "Hello"

To use your option:

greeting = plugin.get_option('greeting')

Now let's test! Go to the shell and stop your plugin:

l1-cli plugin stop helloworld.py

Now start your plugin, inserting a value for your new option:

l1-cli -k plugin subcommand=start plugin=$(pwd)/python-plugin/helloworld.py greeting='A crazy'

Now invoke the updated hello RPC method:

l1-cli hello

Try it with various arguments, and see what happens.

  • Add an option
  • Test that it works as expected