forked from ElementsProject/lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendpay_notifications.py
executable file
·34 lines (23 loc) · 1.03 KB
/
sendpay_notifications.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
"""This plugin is used to check that sendpay_success and sendpay_failure calls are working correctly.
"""
from pyln.client import Plugin
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):
plugin.log("Received a sendpay_success: id={}, payment_hash={}".format(sendpay_success['id'], sendpay_success['payment_hash']))
plugin.success_list.append(sendpay_success)
@plugin.subscribe("sendpay_failure")
def notify_sendpay_failure(plugin, sendpay_failure):
plugin.log("Received a sendpay_failure: id={}, payment_hash={}".format(sendpay_failure['data']['id'],
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()