+/// Legacy version of [`ChannelConfig`] that stored the static
+/// [`ChannelHandshakeConfig::announced_channel`] and
+/// [`ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`] fields.
+#[derive(Copy, Clone, Debug)]
+pub(crate) struct LegacyChannelConfig {
+ pub(crate) options: ChannelConfig,
+ /// Deprecated but may still be read from. See [`ChannelHandshakeConfig::announced_channel`] to
+ /// set this when opening/accepting a channel.
+ pub(crate) announced_channel: bool,
+ /// Deprecated but may still be read from. See
+ /// [`ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`] to set this when
+ /// opening/accepting a channel.
+ pub(crate) commit_upfront_shutdown_pubkey: bool,
+}
+
+impl Default for LegacyChannelConfig {
+ fn default() -> Self {
+ Self {
+ options: ChannelConfig::default(),
+ announced_channel: false,
+ commit_upfront_shutdown_pubkey: true,
+ }
+ }
+}
+
+impl crate::util::ser::Writeable for LegacyChannelConfig {
+ fn write<W: crate::util::ser::Writer>(&self, writer: &mut W) -> Result<(), crate::io::Error> {
+ write_tlv_fields!(writer, {
+ (0, self.options.forwarding_fee_proportional_millionths, required),
+ (1, self.options.max_dust_htlc_exposure_msat, (default_value, 5_000_000)),
+ (2, self.options.cltv_expiry_delta, required),
+ (3, self.options.force_close_avoidance_max_fee_satoshis, (default_value, 1000)),
+ (4, self.announced_channel, required),
+ (6, self.commit_upfront_shutdown_pubkey, required),
+ (8, self.options.forwarding_fee_base_msat, required),
+ });
+ Ok(())
+ }
+}
+
+impl crate::util::ser::Readable for LegacyChannelConfig {
+ fn read<R: crate::io::Read>(reader: &mut R) -> Result<Self, crate::ln::msgs::DecodeError> {
+ let mut forwarding_fee_proportional_millionths = 0;
+ let mut max_dust_htlc_exposure_msat = 5_000_000;
+ let mut cltv_expiry_delta = 0;
+ let mut force_close_avoidance_max_fee_satoshis = 1000;
+ let mut announced_channel = false;
+ let mut commit_upfront_shutdown_pubkey = false;
+ let mut forwarding_fee_base_msat = 0;
+ read_tlv_fields!(reader, {
+ (0, forwarding_fee_proportional_millionths, required),
+ (1, max_dust_htlc_exposure_msat, (default_value, 5_000_000u64)),
+ (2, cltv_expiry_delta, required),
+ (3, force_close_avoidance_max_fee_satoshis, (default_value, 1000u64)),
+ (4, announced_channel, required),
+ (6, commit_upfront_shutdown_pubkey, required),
+ (8, forwarding_fee_base_msat, required),
+ });
+ Ok(Self {
+ options: ChannelConfig {
+ forwarding_fee_proportional_millionths,
+ max_dust_htlc_exposure_msat,
+ cltv_expiry_delta,
+ force_close_avoidance_max_fee_satoshis,
+ forwarding_fee_base_msat,
+ },
+ announced_channel,
+ commit_upfront_shutdown_pubkey,
+ })
+ }
+}
+