2019-06-25 10:48:11 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""This plugin is used to check that sendpay_success and sendpay_failure calls are working correctly.
|
|
|
|
"""
|
2020-02-11 23:04:21 +01:00
|
|
|
from pyln.client import Plugin
|
2019-06-25 10:48:11 +02:00
|
|
|
|
|
|
|
plugin = Plugin()
|
|
|
|
|
|
|
|
|
|
|
|
@plugin.init()
|
|
|
|
def init(configuration, options, plugin):
|
|
|
|
plugin.success_list = []
|
|
|
|
plugin.failure_list = []
|
|
|
|
|
|
|
|
|
|
|
|
@plugin.subscribe("sendpay_success")
|
|
|
|
def notify_sendpay_success(plugin, sendpay_success):
|
2020-01-07 17:15:20 +01:00
|
|
|
plugin.log("Received a sendpay_success: id={}, payment_hash={}".format(sendpay_success['id'], sendpay_success['payment_hash']))
|
2019-06-25 10:48:11 +02:00
|
|
|
plugin.success_list.append(sendpay_success)
|
|
|
|
|
|
|
|
|
|
|
|
@plugin.subscribe("sendpay_failure")
|
|
|
|
def notify_sendpay_failure(plugin, sendpay_failure):
|
2020-01-07 17:15:20 +01:00
|
|
|
plugin.log("Received a sendpay_failure: id={}, payment_hash={}".format(sendpay_failure['data']['id'],
|
2019-06-25 10:48:11 +02:00
|
|
|
sendpay_failure['data']['payment_hash']))
|
|
|
|
plugin.failure_list.append(sendpay_failure)
|
|
|
|
|
|
|
|
|
|
|
|
@plugin.method('listsendpays_plugin')
|
|
|
|
def record_lookup(plugin):
|
|
|
|
return {'sendpay_success': plugin.success_list,
|
|
|
|
'sendpay_failure': plugin.failure_list}
|
|
|
|
|
|
|
|
|
|
|
|
plugin.run()
|