core-lightning/contrib/plugins/helloworld.py
Christian Decker 643480cfd8 pylightning: Migrate the test plugin to use the new wrapper
Should be a lot easier to see what happens :-)

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-15 15:04:32 +01:00

28 lines
633 B
Python
Executable file

#!/usr/bin/env python3
from lightning import Plugin
plugin = Plugin(autopatch=True)
@plugin.method("hello")
def hello(name, plugin):
"""This is the documentation string for the hello-function.
It gets reported as the description when registering the function
as a method with `lightningd`.
"""
greeting = plugin.get_option('greeting')
s = '{} {}'.format(greeting, name)
plugin.log(s)
return s
@plugin.method("init")
def init(options, configuration, plugin):
plugin.log("Plugin helloworld.py initialized")
plugin.add_option('greeting', 'Hello', 'The greeting I should use.')
plugin.run()