Add forward-compat due serialization variants of HTLCFailureMsg
authorMatt Corallo <git@bluematt.me>
Sun, 29 Aug 2021 02:55:39 +0000 (02:55 +0000)
committerMatt Corallo <git@bluematt.me>
Sat, 18 Sep 2021 01:01:41 +0000 (01:01 +0000)
commitf60da31e56cab7713119be1658d4204b054a30d2
tree076ec51ff6173610fdcb0060d5e206bea3018af1
parent7f9eef553c89bef4e5aaf369ad02cfff4e0f9048
Add forward-compat due serialization variants of HTLCFailureMsg

Going forward, all lightning messages have a TLV stream suffix,
allowing new fields to be added as needed. In the P2P protocol,
messages have an explicit length, so there is no implied length in
the TLV stream itself. HTLCFailureMsg enum variants have messages
in them, but without a size prefix or any explicit end. Thus, if a
HTLCFailureMsg is read as a part of a ChannelManager, with a TLV
stream at the end, there is no way to differentiate between the end
of the message and the next field(s) in the ChannelManager.

Here we add two new variant values for HTLCFailureMsg variants in
the read path, allowing us to switch to the new values if/when we
add new TLV fields in UpdateFailHTLC or UpdateFailMalformedHTLC so
that older versions can still read the new TLV fields.
lightning/src/ln/channelmanager.rs