+/// Checks if `$val` matches `$type`.
+/// This is exported for use by other exported macros, do not use directly.
+#[doc(hidden)]
+#[macro_export]
+macro_rules! _decode_tlv_stream_match_check {
+ ($val: ident, $type: expr, (static_value, $value: expr)) => { false };
+ ($val: ident, $type: expr, $fieldty: tt) => { $val == $type }
+}
+
+/// Implements the TLVs deserialization part in a [`Readable`] implementation of a struct.
+///
+/// This should be called inside a method which returns `Result<_, `[`DecodeError`]`>`, such as
+/// [`Readable::read`]. It will either return an `Err` or ensure all `required` fields have been
+/// read and optionally read `optional` fields.
+///
+/// `$stream` must be a [`Read`] and will be fully consumed, reading until no more bytes remain
+/// (i.e. it returns [`DecodeError::ShortRead`]).
+///
+/// Fields MUST be sorted in `$type`-order.
+///
+/// Note that the lightning TLV requirements require that a single type not appear more than once,
+/// that TLVs are sorted in type-ascending order, and that any even types be understood by the
+/// decoder.
+///
+/// For example,
+/// ```
+/// # use lightning::decode_tlv_stream;
+/// # fn read<R: lightning::io::Read> (stream: R) -> Result<(), lightning::ln::msgs::DecodeError> {
+/// let mut required_value = 0u64;
+/// let mut optional_value: Option<u64> = None;
+/// decode_tlv_stream!(stream, {
+/// (0, required_value, required),
+/// (2, optional_value, option),
+/// });
+/// // At this point, `required_value` has been overwritten with the TLV with type 0.
+/// // `optional_value` may have been overwritten, setting it to `Some` if a TLV with type 2 was
+/// // present.
+/// # Ok(())
+/// # }
+/// ```
+///
+/// [`Readable`]: crate::util::ser::Readable
+/// [`DecodeError`]: crate::ln::msgs::DecodeError
+/// [`Readable::read`]: crate::util::ser::Readable::read
+/// [`Read`]: crate::io::Read
+/// [`DecodeError::ShortRead`]: crate::ln::msgs::DecodeError::ShortRead
+#[macro_export]