Files
lightning/tests/plugins/forward_payment_status.py
Christian Decker 3e3b05e1b2 pyln: Migrate remaining uses of the deprecated pylightning module
`pylightning` is not much more than an alias for `pyln-client`, so this
removes the need to install that as well just to run the tests.
2020-03-24 09:52:33 +10:30

28 lines
799 B
Python
Executable File

#!/usr/bin/env python3
"""This plugin is used to check that forward_event calls are working correctly.
"""
from pyln.client import Plugin
plugin = Plugin()
@plugin.init()
def init(configuration, options, plugin):
plugin.forward_list = []
@plugin.subscribe("forward_event")
def notify_warning(plugin, forward_event):
# One forward payment may have many notification records for different status,
# but one forward payment has only one record in 'listforwards' eventrually.
plugin.log("receive a forward recored, status: {}, payment_hash: {}".format(forward_event['status'], forward_event['payment_hash']))
plugin.forward_list.append(forward_event)
@plugin.method('listforwards_plugin')
def record_lookup(plugin):
return {'forwards': plugin.forward_list}
plugin.run()