Correct Channel type serialization logic 2021-11-fix-chan-type-ser
authorMatt Corallo <git@bluematt.me>
Tue, 9 Nov 2021 21:22:47 +0000 (21:22 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 16 Nov 2021 17:12:35 +0000 (17:12 +0000)
commita44587d9aabe45b5ad419996ec7dbe3e5ddd724b
treebf6c6be8aee68917e3a8c78d525be72a50de3114
parent6f053e48b021d516b562a449c91f977397502e73
Correct Channel type serialization logic

Currently, we write out the Channel's `ChannelTypeFeatures` as an
odd type, implying clients which don't understand the
`ChannelTypeFeatures` field can simply ignore it. This is obviously
nonsense if the channel type is some future version - the client
needs to fail to deserialize as it doesn't understand the channel's
type.

We adapt the serialization logic here to only write out the
`ChannelTypeFeatures` field if it is something other than
only-static-remote-key, and simply consider that "default" (as it
is the only supported type today). Then, we write out the channel
type as an even TLV, implying clients which do not understand it
must fail to read the `Channel`.

Note that we do not need to bother reserving the TLV type no longer
written as it never appeared in a release (merged post-0.0.103).
lightning/src/ln/channel.rs