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

Function json_showrunes

lightningd/runes.c:393–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391}
392
393static struct command_result *json_showrunes(struct command *cmd,
394 const char *buffer,
395 const jsmntok_t *obj UNNEEDED,
396 const jsmntok_t *params)
397{
398 struct json_stream *response;
399 struct rune_and_string *ras;
400
401 if (!param(cmd, buffer, params,
402 p_opt("rune", param_rune, &ras), NULL))
403 return command_param_failed();
404
405 response = json_stream_success(cmd);
406 json_array_start(response, "runes");
407 if (ras) {
408 u64 uid = rune_unique_id(ras->rune);
409 struct timeabs last_used;
410 const char *from_db = wallet_get_rune(tmpctx, cmd->ld->wallet, uid, &last_used);
411
412 /* This is how we indicate no timestamp: */
413 if (!from_db)
414 last_used.ts.tv_sec = 0;
415 /* We consider it stored iff this is exactly stored */
416 json_add_rune(cmd->ld, response, NULL, ras->runestr, ras->rune,
417 from_db && streq(from_db, ras->runestr), last_used);
418 } else {
419 struct timeabs *last_used;
420 const char **strs = wallet_get_runes(cmd, cmd->ld->wallet, &last_used);
421 for (size_t i = 0; i < tal_count(strs); i++) {
422 const struct rune *r = rune_from_base64(cmd, strs[i]);
423 json_add_rune(cmd->ld, response, NULL, strs[i], r, true, last_used[i]);
424 }
425 }
426 json_array_end(response);
427 return command_success(cmd, response);
428}
429
430static const struct json_command showrunes_command = {
431 "showrunes",

Callers

nothing calls this directly

Calls 11

json_array_startFunction · 0.85
wallet_get_runeFunction · 0.85
wallet_get_runesFunction · 0.85
rune_from_base64Function · 0.85
json_array_endFunction · 0.85
command_param_failedFunction · 0.70
json_stream_successFunction · 0.70
rune_unique_idFunction · 0.70
json_add_runeFunction · 0.70
command_successFunction · 0.70
paramFunction · 0.50

Tested by

no test coverage detected