-
-impl<T: sealed::Context> Readable for Features<T> {
- fn read<R: ::std::io::Read>(r: &mut R) -> Result<Self, DecodeError> {
- let mut flags: Vec<u8> = Readable::read(r)?;
- flags.reverse(); // Swap to little-endian
- Ok(Self {
- flags,
- mark: PhantomData,
- })
+impl_feature_len_prefixed_write!(InitFeatures);
+impl_feature_len_prefixed_write!(ChannelFeatures);
+impl_feature_len_prefixed_write!(NodeFeatures);
+impl_feature_len_prefixed_write!(InvoiceFeatures);
+
+// Because ChannelTypeFeatures only appears inside of TLVs, it doesn't have a length prefix when
+// serialized. Thus, we can't use `impl_feature_len_prefixed_write`, above, and have to write our
+// own serialization.
+impl Writeable for ChannelTypeFeatures {
+ fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
+ self.write_be(w)
+ }
+}
+impl Readable for ChannelTypeFeatures {
+ fn read<R: io::Read>(r: &mut R) -> Result<Self, DecodeError> {
+ let v = io_extras::read_to_end(r)?;
+ Ok(Self::from_be_bytes(v))