-
Notifications
You must be signed in to change notification settings - Fork 913
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b13284a
commit 0bcc8ac
Showing
3 changed files
with
52 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/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_2 modified this description" | ||
return {"replace": request} | ||
elif request["method"] == "sendpay": | ||
# Don't allow this command to be executed | ||
return {"return": {"error": {"code": -1, | ||
"message": "rpc_command_2 cannot do this"}}} | ||
return {"result": "continue"} | ||
|
||
|
||
plugin.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters