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

Function json_id

plugins/libplugin.c:343–371  ·  view source on GitHub ↗

Prefix is usually a cmd->id */

Source from the content-addressed store, hash-verified

341
342/* Prefix is usually a cmd->id */
343static const char *json_id(const tal_t *ctx, struct plugin *plugin,
344 const char *method, const char *prefix)
345{
346 const char *rawid;
347 int rawidlen;
348
349 /* Strip quotes! */
350 if (strstarts(prefix, "\"")) {
351 assert(strlen(prefix) >= 2);
352 assert(strends(prefix, "\""));
353 rawid = prefix + 1;
354 rawidlen = strlen(prefix) - 2;
355 } else {
356 rawid = prefix;
357 rawidlen = strlen(prefix);
358 }
359
360 /* Don't create weird IDs: they get escaped, we won't match the
361 * reply, and the command never finishes. */
362 if (json_escape_needed(method, strlen(method)))
363 method = "!weird!";
364 if (json_escape_needed(rawid, rawidlen)) {
365 rawid = "!weird!";
366 rawidlen = strlen(rawid);
367 }
368
369 return tal_fmt(ctx, "\"%.*s/%s:%s#%"PRIu64"\"",
370 rawidlen, rawid, plugin->id, method, plugin->next_outreq_id++);
371}
372
373static void destroy_out_req(struct out_req *out_req, struct plugin *plugin)
374{

Callers 2

jsonrpc_request_start_Function · 0.85
sync_reqFunction · 0.85

Calls 2

strendsFunction · 0.85
json_escape_neededFunction · 0.85

Tested by

no test coverage detected