core-lightning/tests/plugins/onionmessage-reply.py
Rusty Russell 37ddf2e829 lightningd: rename sendonionmessage to sendobsonionmessage.
sendonionmessage is going to be the new one, and do much *less*.

As this is an internal experimental-only API, no deprecation cycle
required.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-09-22 06:44:26 +09:30

23 lines
593 B
Python
Executable File

#!/usr/bin/env python3
"""
This plugin is used to test the `onion_message` hook.
"""
from pyln.client import Plugin
plugin = Plugin()
@plugin.hook("onion_message")
def on_onion_message(plugin, onion_message, **kwargs):
if 'reply_path' not in onion_message:
plugin.log("no reply path")
return
plugin.rpc.call('sendobsonionmessage', [onion_message['reply_path']])
plugin.log("Got onion_message invoice '{}'".format(onion_message['invoice']))
plugin.log("Sent reply via {}".format(onion_message['reply_path']))
return {"result": "continue"}
plugin.run()