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

Function towire_tlv

wire/tlvstream.c:294–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294void towire_tlv(u8 **pptr,
295 const struct tlv_record_type *types, size_t num_types,
296 const void *record)
297{
298 if (!record)
299 return;
300
301 for (size_t i = 0; i < num_types; i++) {
302 u8 *val;
303 if (i != 0)
304 assert(types[i].type > types[i-1].type);
305 val = types[i].towire(NULL, record);
306 if (!val)
307 continue;
308
309 /* BOLT #1:
310 *
311 * The sending node:
312 ...
313 * - MUST minimally encode `type` and `length`.
314 */
315 towire_bigsize(pptr, types[i].type);
316 towire_bigsize(pptr, tal_bytelen(val));
317 towire(pptr, val, tal_bytelen(val));
318 tal_free(val);
319 }
320}
321
322struct tlv_field *tlv_make_fields_(const struct tlv_record_type *types,
323 size_t num_types,

Callers

nothing calls this directly

Calls 4

tal_bytelenFunction · 0.85
tal_freeFunction · 0.85
towireFunction · 0.70
towire_bigsizeFunction · 0.50

Tested by

no test coverage detected