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

Function json_add_rune

lightningd/runes.c:353–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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