MCPcopy Create free account
hub / github.com/ElementsProject/lightning / print_valid_offer

Function print_valid_offer

common/test/run-bolt12-encode-test.c:97–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97static 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
133static void print_malformed_tlv(const char *hrp,
134 const char *hex,

Callers 1

mainFunction · 0.85

Calls 7

offer_encodeFunction · 0.85
offer_decodeFunction · 0.85
print_fieldFunction · 0.85
towire_tlv_offerFunction · 0.70
towire_bigsizeFunction · 0.70
towireFunction · 0.70
to_bech32_charsetFunction · 0.70

Tested by

no test coverage detected