| 95 | } |
| 96 | |
| 97 | static void print_valid_offer(const struct tlv_offer *offer, |
| 98 | const char *testdesc, |
| 99 | const char *extradesc, |
| 100 | const struct tlv_field *extrafield) |
| 101 | { |
| 102 | const char *str = offer_encode(tmpctx, offer), *err; |
| 103 | struct tlv_offer *offer2; |
| 104 | |
| 105 | /* We only use extrafield on the end */ |
| 106 | if (extrafield) { |
| 107 | u8 *wire; |
| 108 | |
| 109 | wire = tal_arr(tmpctx, u8, 0); |
| 110 | towire_tlv_offer(&wire, offer); |
| 111 | towire_bigsize(&wire, extrafield->numtype); |
| 112 | towire_bigsize(&wire, extrafield->length); |
| 113 | towire(&wire, extrafield->value, extrafield->length); |
| 114 | |
| 115 | str = to_bech32_charset(tmpctx, "lno", wire); |
| 116 | } |
| 117 | |
| 118 | printf("%s{ \"description\": \"%s\", \"valid\": true, \"bolt12\": \"%s\",", |
| 119 | extradesc ? "," : "", |
| 120 | testdesc, str); |
| 121 | if (extradesc) |
| 122 | printf("\"field info\": \"%s\", ", extradesc); |
| 123 | |
| 124 | /* Print the fields. */ |
| 125 | printf("\"fields\": ["); |
| 126 | /* Re-marshal to get fields[] arr (and sanity check!) */ |
| 127 | offer2 = offer_decode(tmpctx, str, strlen(str), NULL, NULL, &err); |
| 128 | for (size_t i = 0; i < tal_count(offer2->fields); i++) |
| 129 | print_field(i == 0, &offer2->fields[i]); |
| 130 | printf("]}\n"); |
| 131 | } |
| 132 | |
| 133 | static void print_malformed_tlv(const char *hrp, |
| 134 | const char *hex, |
no test coverage detected