De/serialize custom TLVs on `{Inbound,Outbound}OnionPayload`
authorAlec Chen <alecchendev@gmail.com>
Fri, 19 May 2023 04:16:29 +0000 (23:16 -0500)
committerAlec Chen <alecchendev@gmail.com>
Tue, 8 Aug 2023 21:13:19 +0000 (16:13 -0500)
commitf560320b5fb257b1863eaf33f50aca373a70c9f9
treea98ce93d691de731c27a388dc4af68b69b98cddf
parentd2e9cb4bcd4234e22f731b6e39f178e10f5eaee7
De/serialize custom TLVs on `{Inbound,Outbound}OnionPayload`

When serialized, the TLVs in `OutboundOnionPayload`, unlike a normal
TLV stream, are prefixed with the length of the stream. To allow a user
to add arbitrary custom TLVs, we aren't able to communicate to our
serialization macros exactly which fields to expect, so this commit
adds new macro variants to allow appending an extra set of bytes (and
modifying the prefixed length accordingly).

Because the keysend preimage TLV has a type number in the custom type
range, and a user's TLVs may have type numbers above and/or below
keysend's type number, and because TLV streams must be serialized in
increasing order by type number, this commit also ensures the keysend
TLV is properly sorted/serialized amongst the custom TLVs.
lightning/src/ln/channelmanager.rs
lightning/src/ln/msgs.rs
lightning/src/ln/onion_utils.rs
lightning/src/util/ser_macros.rs