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

Function check_rune

plugins/commando.c:321–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319}
320
321static const char *check_rune(const tal_t *ctx,
322 struct commando *incoming,
323 const struct node_id *peer,
324 const char *buf,
325 const jsmntok_t *method,
326 const jsmntok_t *params,
327 const jsmntok_t *runetok)
328{
329 struct rune *rune;
330 struct cond_info cinfo;
331 const char *err;
332
333 if (!runetok)
334 return "Missing rune";
335
336 rune = rune_from_base64n(tmpctx, buf + runetok->start,
337 runetok->end - runetok->start);
338 if (!rune)
339 return "Invalid rune";
340
341 cinfo.peer = peer;
342 cinfo.buf = buf;
343 cinfo.method = method;
344 cinfo.params = params;
345 cinfo.usage = NULL;
346 strmap_init(&cinfo.cached_params);
347 err = rune_test(tmpctx, master_rune, rune, check_condition, &cinfo);
348 /* Just in case they manage to make us speak non-JSON, escape! */
349 if (err)
350 err = json_escape(ctx, err)->s;
351
352 strmap_clear(&cinfo.cached_params);
353
354 /* If it succeeded, *now* we increment any associated usage counter. */
355 if (!err && cinfo.usage)
356 cinfo.usage->counter++;
357 return err;
358}
359
360static void try_command(struct node_id *peer,
361 u64 idnum,

Callers 1

try_commandFunction · 0.85

Calls 2

rune_from_base64nFunction · 0.85
json_escapeClass · 0.70

Tested by

no test coverage detected