core-lightning/tests/plugins/htlc_accepted-failmessage.py
Rusty Russell 6a2d949250 lightningd: remove failure_code from invoice hook and htlc_accepted hook.
These were deprecated in v22.08 (invoice hook) and v0.8 (htlc_accepted hook), and
marked EOL in v23.02.

*PLEASE* complain if this breaks things for you: it's kind of a test canary of
the deprecation system!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Removed: Plugins: `invoice_payment` and `htlc_accepted` hook `failure_code` response (derepcated v22.08 and v0.8, EOL v23.02)
2024-03-25 15:02:35 +10:30

33 lines
605 B
Python
Executable file

#!/usr/bin/env python3
"""A simply plugin that fails HTLCs with a configurable failcode.
"""
from pyln.client import Plugin
plugin = Plugin()
@plugin.hook('htlc_accepted')
def on_htlc_accepted(htlc, onion, plugin, **kwargs):
res = {"result": "fail"}
if plugin.failmsg is not None:
res['failure_message'] = plugin.failmsg
return res
@plugin.method('setfailmsg')
def setfailcode(plugin, msg):
"""Sets the failmessage to return when receiving an incoming HTLC.
"""
plugin.failmsg = msg
@plugin.init()
def on_init(**kwargs):
plugin.failmsg = None
plugin.run()