+impl Writeable for HolderHTLCOutput {
+ fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
+ let legacy_deserialization_prevention_marker = chan_utils::legacy_deserialization_prevention_marker_for_channel_type_features(&self.channel_type_features);
+ write_tlv_fields!(writer, {
+ (0, self.amount_msat, required),
+ (2, self.cltv_expiry, required),
+ (4, self.preimage, option),
+ (6, legacy_deserialization_prevention_marker, option),
+ (7, self.channel_type_features, required),
+ });
+ Ok(())
+ }
+}
+
+impl Readable for HolderHTLCOutput {
+ fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
+ let mut amount_msat = RequiredWrapper(None);
+ let mut cltv_expiry = RequiredWrapper(None);
+ let mut preimage = None;
+ let mut _legacy_deserialization_prevention_marker: Option<()> = None;
+ let mut channel_type_features = None;
+
+ read_tlv_fields!(reader, {
+ (0, amount_msat, required),
+ (2, cltv_expiry, required),
+ (4, preimage, option),
+ (6, _legacy_deserialization_prevention_marker, option),
+ (7, channel_type_features, option),
+ });
+
+ verify_channel_type_features(&channel_type_features, None)?;
+
+ Ok(Self {
+ amount_msat: amount_msat.0.unwrap(),
+ cltv_expiry: cltv_expiry.0.unwrap(),
+ preimage,
+ channel_type_features: channel_type_features.unwrap_or(ChannelTypeFeatures::only_static_remote_key())
+ })
+ }
+}