| 189 | /* FIXME: Move lightningd/jsonrpc to common/ ? */ |
| 190 | |
| 191 | struct out_req * |
| 192 | jsonrpc_request_start_(struct plugin *plugin, struct command *cmd, |
| 193 | const char *method, |
| 194 | struct command_result *(*cb)(struct command *command, |
| 195 | const char *buf, |
| 196 | const jsmntok_t *result, |
| 197 | void *arg), |
| 198 | struct command_result *(*errcb)(struct command *command, |
| 199 | const char *buf, |
| 200 | const jsmntok_t *result, |
| 201 | void *arg), |
| 202 | void *arg) |
| 203 | { |
| 204 | struct out_req *out; |
| 205 | |
| 206 | out = tal(cmd, struct out_req); |
| 207 | out->id = get_json_id(out, plugin, cmd ? cmd->id : NULL, method); |
| 208 | out->cmd = cmd; |
| 209 | out->cb = cb; |
| 210 | out->errcb = errcb; |
| 211 | out->arg = arg; |
| 212 | strmap_add(&plugin->out_reqs, out->id, out); |
| 213 | tal_add_destructor2(out, destroy_out_req, plugin); |
| 214 | |
| 215 | /* If command goes away, don't call callbacks! */ |
| 216 | if (out->cmd) |
| 217 | tal_add_destructor2(out->cmd, disable_request_cb, out); |
| 218 | |
| 219 | out->js = new_json_stream(NULL, cmd, NULL); |
| 220 | json_object_start(out->js, NULL); |
| 221 | json_add_string(out->js, "jsonrpc", "2.0"); |
| 222 | json_add_string(out->js, "id", out->id); |
| 223 | json_add_string(out->js, "method", method); |
| 224 | if (out->errcb) |
| 225 | json_object_start(out->js, "params"); |
| 226 | |
| 227 | return out; |
| 228 | } |
| 229 | |
| 230 | const struct feature_set *plugin_feature_set(const struct plugin *p) |
| 231 | { |
nothing calls this directly
no test coverage detected