You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/plugins.md
+99-3Lines changed: 99 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,6 +78,10 @@ this example:
78
78
"description": "Returns the current time in {timezone}",
79
79
"long_description": "Returns the current time in the timezone that is given as the only parameter.\nThis description may be quite long and is allowed to span multiple lines."
80
80
}
81
+
],
82
+
"subscriptions": [
83
+
"connect",
84
+
"disconnect"
81
85
]
82
86
}
83
87
```
@@ -109,8 +113,12 @@ simple JSON object containing the options:
109
113
110
114
```json
111
115
{
112
-
"objects": {
116
+
"options": {
113
117
"greeting": "World"
118
+
},
119
+
"configuration": {
120
+
"lightning-dir": "/home/user/.lightning",
121
+
"rpc-file": "lightning-rpc"
114
122
}
115
123
}
116
124
```
@@ -120,10 +128,98 @@ arbitrary and will currently be discarded by `lightningd`. JSON-RPC
120
128
commands were chosen over notifications in order not to force plugins
121
129
to implement notifications which are not that well supported.
122
130
123
-
## Event stream subscriptions
131
+
## JSON-RPC passthrough
124
132
125
-
*TBD*
133
+
Plugins may register their own JSON-RPC methods that are exposed
134
+
through the JSON-RPC provided by `lightningd`. This provides users
135
+
with a single interface to interact with, while allowing the addition
136
+
of custom methods without having to modify the daemon itself.
137
+
138
+
JSON-RPC methods are registered as part of the `getmanifest`
139
+
result. Each registered method must provide a `name` and a
140
+
`description`. An optional `long_description` may also be
141
+
provided. This information is then added to the internal dispatch
142
+
table, and used to return the help text when using `lightning-cli
143
+
help`, and the methods can be called using the `name`.
144
+
145
+
For example the above `getmanifest` result will register two methods,
146
+
called `hello` and `gettime`:
147
+
148
+
```json
149
+
...
150
+
"rpcmethods": [
151
+
{
152
+
"name": "hello",
153
+
"description": "Returns a personalized greeting for {greeting} (set via options)."
154
+
},
155
+
{
156
+
"name": "gettime",
157
+
"description": "Returns the current time in {timezone}",
158
+
"long_description": "Returns the current time in the timezone that is given as the only parameter.\nThis description may be quite long and is allowed to span multiple lines."
159
+
}
160
+
],
161
+
...
162
+
```
163
+
164
+
The RPC call will be passed through unmodified, with the exception of
165
+
the JSON-RPC call `id`, which is internally remapped to a unique
166
+
integer instead, in order to avoid collisions. When passing the result
167
+
back the `id` field is restored to its original value.
168
+
169
+
## Event notifications
126
170
171
+
Event notifications allow a plugin to subscribe to events in
172
+
`lightningd`. `lightningd` will then send a push notification if an
173
+
event matching the subscription occurred. A notification is defined in
174
+
the JSON-RPC [specification][jsonrpc-spec] as an RPC call that does
175
+
not include an `id` parameter:
176
+
177
+
> A Notification is a Request object without an "id" member. A Request
178
+
> object that is a Notification signifies the Client's lack of
179
+
> interest in the corresponding Response object, and as such no
180
+
> Response object needs to be returned to the client. The Server MUST
181
+
> NOT reply to a Notification, including those that are within a batch
182
+
> request.
183
+
>
184
+
> Notifications are not confirmable by definition, since they do not
185
+
> have a Response object to be returned. As such, the Client would not
186
+
> be aware of any errors (like e.g. "Invalid params","Internal
187
+
> error").
188
+
189
+
Plugins subscribe by returning an array of subscriptions as part of
190
+
the `getmanifest` response. The result for the `getmanifest` call
191
+
above for example subscribes to the two topics `connect` and
192
+
`disconnect`. The topics that are currently defined and the
193
+
corresponding payloads are listed below.
194
+
195
+
### Notification Types
196
+
197
+
#### `connect`
198
+
199
+
A notification for topic `connect` is sent every time a new connection
0 commit comments