| 351 | } |
| 352 | |
| 353 | static 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 | |
| 403 | static struct command_result *json_showrunes(struct command *cmd, |
| 404 | const char *buffer, |
no test coverage detected