2020-04-01 05:53:22 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""
|
|
|
|
This plugin is used to test the `onion_message` hook.
|
|
|
|
"""
|
2020-06-22 20:29:10 +02:00
|
|
|
from pyln.client import Plugin
|
2020-04-01 05:53:22 +02:00
|
|
|
|
|
|
|
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('sendonionmessage', [onion_message['reply_path']])
|
2021-01-09 05:05:35 +01:00
|
|
|
plugin.log("Got onion_message invoice '{}'".format(onion_message['invoice']))
|
2020-04-01 05:53:22 +02:00
|
|
|
plugin.log("Sent reply via {}".format(onion_message['reply_path']))
|
|
|
|
return {"result": "continue"}
|
|
|
|
|
|
|
|
|
|
|
|
plugin.run()
|