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

Function tlv_field_offset

wire/tlvstream.c:92–116  ·  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

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

Callers

nothing calls this directly

Calls 1

fromwire_bigsizeFunction · 0.50

Tested by

no test coverage detected