core-lightning/tests/plugins/rpc_command_1.py
Rusty Russell de81a59b1e lightningd: mark explicitly what commands are dev-only.
And require --developer to use them.

Also refuse redirection to deprecated APIs if deprecated APIs are disabled! 

Changelog-Removed: `dev-sendcustommsg` (use `sendcustommsg`, which was added in v0.10.1)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-21 20:08:24 +09:30

27 lines
774 B
Python
Executable File

#!/usr/bin/env python3
"""
This plugin is used to test the chained `rpc_command` hook.
"""
from pyln.client import Plugin
plugin = Plugin()
@plugin.hook("rpc_command")
def on_rpc_command(plugin, rpc_command, **kwargs):
request = rpc_command
if request["method"] == "invoice":
# Replace part of this command
request["params"]["description"] = "rpc_command_1 modified this description"
return {"replace": request}
elif request["method"] == "listfunds":
# Return a custom result to the command
return {"return": {"result": ["Custom rpc_command_1 result"]}}
elif request["method"] == "help":
request["method"] = "listconfigs"
return {"replace": request}
return {"result": "continue"}
plugin.run()