Serialization macro for TLV streams
authorJeffrey Czyz <jkczyz@gmail.com>
Fri, 24 Jun 2022 21:27:42 +0000 (16:27 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Fri, 4 Nov 2022 20:09:19 +0000 (15:09 -0500)
commit904d3229235f3a7bc5b11d95bb0e53fbb51f0da4
tree87abce7175c76b028dd31217cf246bb3e4c81802
parent227fd51cb49adaca903972464166b73468d3a257
Serialization macro for TLV streams

BOLT 12's offer message is encoded as a TLV stream (i.e., a sequence of
TLV records). impl_writeable_tlv_based can't be used because it writes
the overall length of the struct, whereas TLV streams only include the
length of each TLV record. Add a `tlv_stream` macro for defining structs
used in encoding.

TLV records containing a single variable-length type should not encode
the types length in the value since it is redundant. Add a wrapper type
that can be used within a TLV stream to support the correct behavior
during serialization and de-serialization.
lightning/src/util/ser.rs
lightning/src/util/ser_macros.rs