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

Function read_sync_rpc_reply

plugins/libplugin.c:745–780  ·  view source on GitHub ↗

Reads rpc reply and returns result tokens */

Source from the content-addressed store, hash-verified

743
744/* Reads rpc reply and returns result tokens */
745static const jsmntok_t *read_sync_rpc_reply(const tal_t *ctx,
746 struct plugin *plugin,
747 const char *method,
748 const char **final_buffer)
749{
750 const jsmntok_t *errtok, *resulttok, *toks;
751 const char *buffer;
752
753 for (;;) {
754 buffer = read_one_json_sync(plugin, &toks);
755 /* FIXME: Don't simply ignore notifications here! */
756 if (json_get_member(buffer, toks, "id"))
757 break;
758 jsonrpc_io_parse_done(plugin->sync_io);
759 }
760
761 errtok = json_get_member(buffer, toks, "error");
762 if (errtok) {
763 plugin_err(plugin, "Got error result to %s: '%.*s'",
764 method,
765 json_tok_full_len(toks),
766 json_tok_full(buffer, toks));
767 }
768 resulttok = json_get_member(buffer, toks, "result");
769 if (!resulttok) {
770 plugin_err(plugin, "JSON reply with no 'result' nor 'error'? '%.*s'",
771 json_tok_full_len(toks),
772 json_tok_full(buffer, toks));
773 }
774
775 /* Make the returned pointers valid tal object */
776 json_dup_contents(ctx, buffer, resulttok, final_buffer, &toks);
777 jsonrpc_io_parse_done(plugin->sync_io);
778
779 return toks;
780}
781
782/* Send request, return response, set resp/len to reponse */
783static const jsmntok_t *sync_req(const tal_t *ctx,

Callers 1

sync_reqFunction · 0.85

Calls 7

read_one_json_syncFunction · 0.85
json_get_memberFunction · 0.85
jsonrpc_io_parse_doneFunction · 0.85
json_dup_contentsFunction · 0.85
plugin_errFunction · 0.70
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50

Tested by

no test coverage detected