| 114 | } |
| 115 | |
| 116 | static void print_fields_json(const struct tlv_field *fields, size_t n, |
| 117 | bool (*include_field)(const struct tlv_field *, void *), |
| 118 | void *arg) |
| 119 | { |
| 120 | for (size_t i = 0; i < n; i++) { |
| 121 | const struct tlv_field *f = &fields[i]; |
| 122 | if (include_field != NULL) { |
| 123 | bool included = !is_tlv_signature_field(f) |
| 124 | && include_field(f, arg); |
| 125 | printf("{\"type\":%"PRIu64",\"len\":%zu,\"hex\":\"%s\",\"included\":%s}%s\n", |
| 126 | f->numtype, f->length, |
| 127 | tal_hexstr(tmpctx, f->value, f->length), |
| 128 | included ? "true" : "false", |
| 129 | i + 1 < n ? "," : ""); |
| 130 | } else { |
| 131 | printf("{\"type\":%"PRIu64",\"len\":%zu,\"hex\":\"%s\"}%s\n", |
| 132 | f->numtype, f->length, |
| 133 | tal_hexstr(tmpctx, f->value, f->length), |
| 134 | i + 1 < n ? "," : ""); |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | static void print_hashes_json(const struct sha256 *hashes, size_t n) |
| 140 | { |
no test coverage detected