MCPcopy Create free account
hub / github.com/ElementsProject/lightning / sync_req

Function sync_req

plugins/libplugin.c:524–551  ·  view source on GitHub ↗

Send request, return response, set resp/len to reponse */

Source from the content-addressed store, hash-verified

522
523/* Send request, return response, set resp/len to reponse */
524static const jsmntok_t *sync_req(const tal_t *ctx,
525 struct plugin *plugin,
526 const char *method,
527 const struct json_out *params TAKES,
528 const char **resp)
529{
530 bool error;
531 const jsmntok_t *contents;
532 int reqlen;
533 struct json_out *jout = json_out_new(tmpctx);
534
535 json_out_start(jout, NULL, '{');
536 json_out_addstr(jout, "jsonrpc", "2.0");
537 json_out_addstr(jout, "id", get_json_id(tmpctx, plugin, "init", method));
538 json_out_addstr(jout, "method", method);
539 json_out_add_splice(jout, "params", params);
540 if (taken(params))
541 tal_free(params);
542 finish_and_send_json(plugin->rpc_conn->fd, jout);
543
544 read_rpc_reply(ctx, plugin, &contents, &error, &reqlen);
545 if (error)
546 plugin_err(plugin, "Got error reply to %s: '%.*s'",
547 method, reqlen, membuf_elems(&plugin->rpc_conn->mb));
548
549 *resp = membuf_consume(&plugin->rpc_conn->mb, reqlen);
550 return contents;
551}
552
553/* Returns contents of scanning guide on 'result' */
554static const char *rpc_scan_core(const tal_t *ctx,

Callers 2

rpc_scan_coreFunction · 0.85
rpc_enable_batchingFunction · 0.85

Calls 10

json_out_newFunction · 0.85
json_out_startFunction · 0.85
json_out_addstrFunction · 0.85
get_json_idFunction · 0.85
json_out_add_spliceFunction · 0.85
takenFunction · 0.85
tal_freeFunction · 0.85
finish_and_send_jsonFunction · 0.85
read_rpc_replyFunction · 0.85
plugin_errFunction · 0.70

Tested by

no test coverage detected