| 368 | /* FIXME: Move lightningd/jsonrpc to common/ ? */ |
| 369 | |
| 370 | struct out_req * |
| 371 | jsonrpc_request_start_(struct command *cmd, |
| 372 | const char *method, |
| 373 | const char *id_prefix, |
| 374 | const char *filter, |
| 375 | struct command_result *(*cb)(struct command *command, |
| 376 | const char *methodname, |
| 377 | const char *buf, |
| 378 | const jsmntok_t *result, |
| 379 | void *arg), |
| 380 | struct command_result *(*errcb)(struct command *command, |
| 381 | const char *methodname, |
| 382 | const char *buf, |
| 383 | const jsmntok_t *result, |
| 384 | void *arg), |
| 385 | void *arg) |
| 386 | { |
| 387 | struct out_req *out; |
| 388 | |
| 389 | assert(cmd); |
| 390 | out = tal(cmd, struct out_req); |
| 391 | out->method = tal_strdup(out, method); |
| 392 | out->id = json_id(out, cmd->plugin, method, id_prefix ? id_prefix : cmd->id); |
| 393 | out->cmd = cmd; |
| 394 | out->cb = cb; |
| 395 | out->errcb = errcb; |
| 396 | out->arg = arg; |
| 397 | strmap_add(&cmd->plugin->out_reqs, out->id, out); |
| 398 | tal_add_destructor2(out, destroy_out_req, cmd->plugin); |
| 399 | |
| 400 | out->js = new_json_stream(NULL, cmd, NULL); |
| 401 | json_object_start(out->js, NULL); |
| 402 | json_add_string(out->js, "jsonrpc", "2.0"); |
| 403 | json_add_id(out->js, out->id); |
| 404 | json_add_string(out->js, "method", method); |
| 405 | if (filter) { |
| 406 | /* This is raw JSON, so paste, don't escape! */ |
| 407 | size_t len = strlen(filter); |
| 408 | char *p = json_out_member_direct(out->js->jout, "filter", len); |
| 409 | memcpy(p, filter, len); |
| 410 | } |
| 411 | if (out->errcb) |
| 412 | json_object_start(out->js, "params"); |
| 413 | |
| 414 | return out; |
| 415 | } |
| 416 | |
| 417 | const struct feature_set *plugin_feature_set(const struct plugin *p) |
| 418 | { |
nothing calls this directly
no test coverage detected