| 5 | #include <lightningd/lightningd.h> |
| 6 | |
| 7 | static void json_add_datastore(struct json_stream *response, |
| 8 | const char **key, const u8 *data, |
| 9 | u64 generation) |
| 10 | { |
| 11 | json_array_start(response, "key"); |
| 12 | for (size_t i = 0; i < tal_count(key); i++) |
| 13 | json_add_string(response, NULL, key[i]); |
| 14 | json_array_end(response); |
| 15 | |
| 16 | if (data) { |
| 17 | const char *str; |
| 18 | |
| 19 | json_add_u64(response, "generation", generation); |
| 20 | json_add_hex(response, "hex", data, tal_bytelen(data)); |
| 21 | str = utf8_str(NULL, data, tal_bytelen(data)); |
| 22 | if (str) |
| 23 | json_add_string(response, "string", take(str)); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | enum ds_mode { |
| 28 | DS_MUST_EXIST = 1, |
no test coverage detected