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

Function json_add_rune

lightningd/runes.c:343–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341}
342
343static struct command_result *json_add_rune(struct lightningd *ld,
344 struct json_stream *js,
345 const char *fieldname,
346 const char *runestr,
347 const struct rune *rune,
348 bool stored,
349 struct timeabs last_used)
350{
351 char *rune_english;
352 rune_english = "";
353 json_object_start(js, fieldname);
354 json_add_string(js, "rune", runestr);
355 if (!stored) {
356 json_add_bool(js, "stored", false);
357 }
358 if (is_rune_blacklisted(ld->runes, rune)) {
359 json_add_bool(js, "blacklisted", true);
360 }
361 if (rune_is_ours(ld, rune) != NULL) {
362 json_add_bool(js, "our_rune", false);
363 }
364 if (last_used.ts.tv_sec != 0) {
365 json_add_timeabs(js, "last_used", last_used);
366 }
367 json_add_string(js, "unique_id", rune->unique_id);
368 json_array_start(js, "restrictions");
369 for (size_t i = 0; i < tal_count(rune->restrs); i++) {
370 char *restr_english;
371 restr_english = "";
372 /* Already printed out the unique id */
373 if (is_unique_id(rune->restrs, i)) {
374 continue;
375 }
376 json_object_start(js, NULL);
377 json_array_start(js, "alternatives");
378 for (size_t j = 0; j < tal_count(rune->restrs[i]->alterns); j++) {
379 join_strings(&restr_english, "OR",
380 json_add_alternative(tmpctx, js, NULL, rune->restrs[i]->alterns[j]));
381 }
382 json_array_end(js);
383 json_add_string(js, "english", restr_english);
384 json_object_end(js);
385 join_strings(&rune_english, "AND", restr_english);
386 }
387 json_array_end(js);
388 json_add_string(js, "restrictions_as_english", rune_english);
389 json_object_end(js);
390 return NULL;
391}
392
393static struct command_result *json_showrunes(struct command *cmd,
394 const char *buffer,

Callers 1

json_showrunesFunction · 0.70

Calls 12

json_object_startFunction · 0.85
json_add_boolFunction · 0.85
is_rune_blacklistedFunction · 0.85
rune_is_oursFunction · 0.85
json_add_timeabsFunction · 0.85
json_array_startFunction · 0.85
join_stringsFunction · 0.85
json_add_alternativeFunction · 0.85
json_array_endFunction · 0.85
json_object_endFunction · 0.85
is_unique_idFunction · 0.70
json_add_stringFunction · 0.50

Tested by

no test coverage detected