Use Infallible for the unconstructable default custom message type
authorMatt Corallo <git@bluematt.me>
Wed, 22 Sep 2021 19:00:30 +0000 (19:00 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 22 Sep 2021 22:01:40 +0000 (22:01 +0000)
commite82318d374fc6dd8e0aec5155bb06bca432ae4b7
treededb403cd2d6f82656406e04887744834af95ffb
parente12d88dfe158b1a7b0e4cedc4af411721be243e6
Use Infallible for the unconstructable default custom message type

When we landed custom messages, we used the empty tuple for the
custom message type for `IgnoringMessageHandler`. This was fine,
except that we also implemented `Writeable` to panic when writing
a `()`. Later, we added support for anchor output construction in
CommitmentTransaction, signified by setting a field to `Some(())`,
which is serialized as-is.

This causes us to panic when writing a `CommitmentTransaction`
with `opt_anchors` set. Note that we never set it inside of LDK,
but downstream users may.

Instead, we implement `Writeable` to write nothing for `()` and use
`core::convert::Infallible` for the default custom message type as
it is, appropriately, unconstructable.

This also makes it easier to implement various things in bindings,
as we can always assume `Infallible`-conversion logic is
unreachable.
lightning/src/ln/peer_handler.rs
lightning/src/ln/wire.rs
lightning/src/util/ser.rs