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

Function plugin_rpcmethod_dispatch

lightningd/plugin.c:1121–1160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1119}
1120
1121static struct command_result *plugin_rpcmethod_dispatch(struct command *cmd,
1122 const char *buffer,
1123 const jsmntok_t *toks,
1124 const jsmntok_t *params UNNEEDED)
1125{
1126 const jsmntok_t *idtok;
1127 struct plugin *plugin;
1128 struct jsonrpc_request *req;
1129 struct plugin_rpccall *call;
1130
1131 if (cmd->mode == CMD_CHECK)
1132 return command_param_failed();
1133
1134 plugin = find_plugin_for_command(cmd->ld, cmd->json_cmd->name);
1135 if (!plugin)
1136 fatal("No plugin for %s ?", cmd->json_cmd->name);
1137
1138 /* Find ID again (We've parsed them before, this should not fail!) */
1139 idtok = json_get_member(buffer, toks, "id");
1140 assert(idtok != NULL);
1141
1142 call = tal(plugin, struct plugin_rpccall);
1143 call->cmd = cmd;
1144
1145 req = jsonrpc_request_start_raw(plugin, cmd->json_cmd->name, cmd->id,
1146 plugin->log,
1147 plugin_notify_cb,
1148 plugin_rpcmethod_cb, call);
1149 call->request = req;
1150 call->plugin = plugin;
1151 list_add_tail(&plugin->pending_rpccalls, &call->list);
1152
1153 json_stream_forward_change_id(req->stream, buffer, toks, idtok, req->id,
1154 true);
1155 json_stream_double_cr(req->stream);
1156 plugin_request_send(plugin, req);
1157 req->stream = NULL;
1158
1159 return command_still_pending(cmd);
1160}
1161
1162static const char *plugin_rpcmethod_add(struct plugin *plugin,
1163 const char *buffer,

Callers

nothing calls this directly

Calls 8

json_stream_double_crFunction · 0.85
command_param_failedFunction · 0.70
find_plugin_for_commandFunction · 0.70
fatalFunction · 0.70
plugin_request_sendFunction · 0.70
command_still_pendingFunction · 0.70
json_get_memberFunction · 0.50

Tested by

no test coverage detected