| 341 | } |
| 342 | |
| 343 | static 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 | |
| 393 | static struct command_result *json_showrunes(struct command *cmd, |
| 394 | const char *buffer, |
no test coverage detected