Enable wumbo channels to be created
[rust-lightning] / lightning / src / util / ser_macros.rs
index 1ddb7e017eb900aa80ccd09696d5ad90824284b0..165d1f1edbacea61438ef3426828a1195336a39e 100644 (file)
@@ -154,7 +154,8 @@ macro_rules! decode_tlv {
                $field = ser::Readable::read(&mut $reader)?;
        }};
        ($reader: expr, $field: ident, vec_type) => {{
-               $field = Some(ser::Readable::read(&mut $reader)?);
+               let f: ::util::ser::VecReadWrapper<_> = ser::Readable::read(&mut $reader)?;
+               $field = Some(f.0);
        }};
        ($reader: expr, $field: ident, option) => {{
                $field = Some(ser::Readable::read(&mut $reader)?);
@@ -309,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)),*})
        }
 }
 
@@ -348,7 +349,7 @@ macro_rules! init_tlv_based_struct_field {
                $field.0.unwrap()
        };
        ($field: ident, vec_type) => {
-               $field.unwrap().0
+               $field.unwrap()
        };
 }
 
@@ -360,7 +361,7 @@ macro_rules! init_tlv_field_var {
                let mut $field = ::util::ser::OptionDeserWrapper(None);
        };
        ($field: ident, vec_type) => {
-               let mut $field = Some(::util::ser::VecReadWrapper(Vec::new()));
+               let mut $field = Some(Vec::new());
        };
        ($field: ident, option) => {
                let mut $field = None;
@@ -454,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> {
@@ -480,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),
                                }