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

Function read_sync_rpc_reply

plugins/libplugin.c:735–770  ·  view source on GitHub ↗

Reads rpc reply and returns result tokens */

Source from the content-addressed store, hash-verified

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