2019-04-11 04:15:22 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""Simple plugin to test the invoice_payment_hook.
|
|
|
|
|
|
|
|
We just refuse to let them pay invoices with preimages divisible by 16.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from lightning import Plugin
|
|
|
|
|
|
|
|
plugin = Plugin()
|
|
|
|
|
|
|
|
|
|
|
|
@plugin.hook('invoice_payment')
|
2019-08-05 02:19:48 +02:00
|
|
|
def on_payment(payment, plugin, **kwargs):
|
2019-04-11 04:15:22 +02:00
|
|
|
print("label={}".format(payment['label']))
|
|
|
|
print("msat={}".format(payment['msat']))
|
|
|
|
print("preimage={}".format(payment['preimage']))
|
|
|
|
|
|
|
|
if payment['preimage'].endswith('0'):
|
2020-02-21 06:10:45 +01:00
|
|
|
# WIRE_TEMPORARY_NODE_FAILURE = 0x2002
|
|
|
|
return {'failure_message': "2002"}
|
2019-04-11 04:15:22 +02:00
|
|
|
|
2020-01-31 12:50:37 +01:00
|
|
|
return {'result': 'continue'}
|
2019-04-11 04:15:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
plugin.run()
|