Skip to content

Commit

Permalink
Document the 'rpc_command' hook
Browse files Browse the repository at this point in the history
  • Loading branch information
darosior committed Nov 3, 2019
1 parent fc70b88 commit 2d7c4d6
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

Plugin: A new plugin hook, `rpc_command` allows a plugin to take over `lightningd` for any RPC command.

### Changed

### Deprecated
Expand Down
63 changes: 63 additions & 0 deletions doc/PLUGINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,69 @@ processed before the HTLC was forwarded, failed, or resolved, then the plugin
may see the same HTLC again during startup. It is therefore paramount that the
plugin is idempotent if it talks to an external system.


#### `rpc_command`

The `rpc_command` hook allows a plugin to take over any RPC command. It sends
the received JSON-RPC request to the registered plugin,

```json
{
"rpc_command": {
"method": "method_name",
"params": {
"param_1": [],
"param_2": {},
"param_n": "",
}
}
}
```

which can in turn:

Let `lightningd` execute the command with

```json
{"continue"}
```
Replace the request made to `lightningd`:

```json
{
"replace": {
"method": "method_name",
"params": {
"param_1": [],
"param_2": {},
"param_n": "",
}
}
}
```

Return a custom response to the request sender:

```json
{
"return": {
"result": {
}
}
}
```

Return a custom error to the request sender:

```json
{
"return": {
"error": {
}
}
}
```

[jsonrpc-spec]: https://www.jsonrpc.org/specification
[jsonrpc-notification-spec]: https://www.jsonrpc.org/specification#notification
[bolt4]: https://github.com/lightningnetwork/lightning-rfc/blob/master/04-onion-routing.md
Expand Down

0 comments on commit 2d7c4d6

Please sign in to comment.