core-lightning/tests/plugins/custommsg_b.py
Christian Decker ebb1b19c65 plugin: Fix the custommsg hook not to include the internal prefix
We were always prefixing the `message` field with the internal type
prefix 0x0407, followed by the length prefix. Neither is needed since
the type being constant is of no interest to the plugin and the length
being implicit due to the JSON-encoding.

Reported-by: Ilya Evdokimov
Changelog-Fixed: plugin: The `custommsg` hook no longer includes the internal type prefix and length prefix in its `payload`
Changelog-Deprecated: plugin: The `message` field on the `custommsg` hook is deprecated in favor of the `payload` field, which skips the internal prefix.
2021-03-02 14:41:16 +10:30

17 lines
341 B
Python
Executable File

#!/usr/bin/env python3
from pyln.client import Plugin
plugin = Plugin()
@plugin.hook('custommsg')
def on_custommsg(peer_id, payload, plugin, message=None, **kwargs):
plugin.log("Got custommessage_b {msg} from peer {peer_id}".format(
msg=payload,
peer_id=peer_id
))
return {'result': 'continue'}
plugin.run()