Enable wumbo channels to be created
[rust-lightning] / lightning / src / util / ser_macros.rs
index b80ca537bbf03bd86d07912687d32ce81cd11f81..165d1f1edbacea61438ef3426828a1195336a39e 100644 (file)
@@ -310,7 +310,7 @@ macro_rules! write_ver_prefix {
 /// correctly.
 macro_rules! write_tlv_fields {
        ($stream: expr, {$(($type: expr, $field: expr, $fieldty: tt)),* $(,)*}) => {
-               encode_varint_length_prefixed_tlv!($stream, {$(($type, $field, $fieldty)),*});
+               encode_varint_length_prefixed_tlv!($stream, {$(($type, $field, $fieldty)),*})
        }
 }
 
@@ -455,9 +455,12 @@ macro_rules! _impl_writeable_tlv_based_enum_common {
 macro_rules! impl_writeable_tlv_based_enum_upgradable {
        ($st: ident, $(($variant_id: expr, $variant_name: ident) =>
                {$(($type: expr, $field: ident, $fieldty: tt)),* $(,)*}
-       ),* $(,)*) => {
+       ),* $(,)*
+       $(;
+       $(($tuple_variant_id: expr, $tuple_variant_name: ident)),*  $(,)*)*) => {
                _impl_writeable_tlv_based_enum_common!($st,
-                       $(($variant_id, $variant_name) => {$(($type, $field, $fieldty)),*}),*; );
+                       $(($variant_id, $variant_name) => {$(($type, $field, $fieldty)),*}),*;
+                       $($(($tuple_variant_id, $tuple_variant_name)),*)*);
 
                impl ::util::ser::MaybeReadable for $st {
                        fn read<R: $crate::io::Read>(reader: &mut R) -> Result<Option<Self>, ::ln::msgs::DecodeError> {
@@ -481,6 +484,9 @@ macro_rules! impl_writeable_tlv_based_enum_upgradable {
                                                };
                                                f()
                                        }),*
+                                       $($($tuple_variant_id => {
+                                               Ok(Some($st::$tuple_variant_name(Readable::read(reader)?)))
+                                       }),*)*
                                        _ if id % 2 == 1 => Ok(None),
                                        _ => Err(DecodeError::UnknownRequiredFeature),
                                }