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

Function tlv_field_offset

wire/tlvstream.c:95–119  ·  view source on GitHub ↗

Get the offset of this field: returns size of msg if not found (or * tlv malformed) */

Source from the content-addressed store, hash-verified

93/* Get the offset of this field: returns size of msg if not found (or
94 * tlv malformed) */
95size_t tlv_field_offset(const u8 *tlvstream, size_t tlvlen, u64 fieldtype)
96{
97 size_t max = tlvlen;
98 while (max > 0) {
99 u64 type, length;
100 size_t field_off = tlvlen - max;
101
102 type = fromwire_bigsize(&tlvstream, &max);
103 length = fromwire_bigsize(&tlvstream, &max);
104
105 if (!tlvstream)
106 break;
107
108 /* Found it! */
109 if (type == fieldtype)
110 return field_off;
111
112 if (length > max)
113 break;
114
115 max -= length;
116 tlvstream += length;
117 }
118 return tlvlen;
119}
120
121static bool tlv_type_is_allowed(const struct tlv_field *f,
122 const u64 *extra_types)

Callers

nothing calls this directly

Calls 1

fromwire_bigsizeFunction · 0.50

Tested by

no test coverage detected