-impl_writeable_tlv_based!(CounterpartyOfferedHTLCOutput, {
- (0, per_commitment_point, required),
- (2, counterparty_delayed_payment_base_key, required),
- (4, counterparty_htlc_base_key, required),
- (6, preimage, required),
- (8, htlc, required),
-});
+impl Writeable for CounterpartyOfferedHTLCOutput {
+ 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.per_commitment_point, required),
+ (2, self.counterparty_delayed_payment_base_key, required),
+ (4, self.counterparty_htlc_base_key, required),
+ (6, self.preimage, required),
+ (8, self.htlc, required),
+ (10, legacy_deserialization_prevention_marker, option),
+ (11, self.channel_type_features, required),
+ });
+ Ok(())
+ }
+}
+
+impl Readable for CounterpartyOfferedHTLCOutput {
+ fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
+ let mut per_commitment_point = RequiredWrapper(None);
+ let mut counterparty_delayed_payment_base_key = RequiredWrapper(None);
+ let mut counterparty_htlc_base_key = RequiredWrapper(None);
+ let mut preimage = RequiredWrapper(None);
+ let mut htlc = RequiredWrapper(None);
+ let mut _legacy_deserialization_prevention_marker: Option<()> = None;
+ let mut channel_type_features = None;
+
+ read_tlv_fields!(reader, {
+ (0, per_commitment_point, required),
+ (2, counterparty_delayed_payment_base_key, required),
+ (4, counterparty_htlc_base_key, required),
+ (6, preimage, required),
+ (8, htlc, required),
+ (10, _legacy_deserialization_prevention_marker, option),
+ (11, channel_type_features, option),
+ });
+
+ verify_channel_type_features(&channel_type_features, None)?;
+
+ Ok(Self {
+ per_commitment_point: per_commitment_point.0.unwrap(),
+ counterparty_delayed_payment_base_key: counterparty_delayed_payment_base_key.0.unwrap(),
+ counterparty_htlc_base_key: counterparty_htlc_base_key.0.unwrap(),
+ preimage: preimage.0.unwrap(),
+ htlc: htlc.0.unwrap(),
+ channel_type_features: channel_type_features.unwrap_or(ChannelTypeFeatures::only_static_remote_key())
+ })
+ }
+}