Skip to content

Commit bd11796

Browse files
committed
Simplify Channel deserialization in a few places
e23d32d removed support for reading ancient `Channel`s but left a bit of cleanup for later. Here we clean up deserialization a bit by removing old v1 channel read logic.
1 parent 36ba27a commit bd11796

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

lightning/src/ln/channel.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10305,22 +10305,17 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1030510305
let (entropy_source, signer_provider, serialized_height, our_supported_features) = args;
1030610306
let ver = read_ver_prefix!(reader, SERIALIZATION_VERSION);
1030710307

10308+
if ver <= 2 {
10309+
return Err(DecodeError::InvalidValue);
10310+
}
10311+
1030810312
// `user_id` used to be a single u64 value. In order to remain backwards compatible with
1030910313
// versions prior to 0.0.113, the u128 is serialized as two separate u64 values. We read
1031010314
// the low bytes now and the high bytes later.
1031110315
let user_id_low: u64 = Readable::read(reader)?;
1031210316

10313-
let mut config = Some(LegacyChannelConfig::default());
10314-
if ver == 1 {
10315-
// Read the old serialization of the ChannelConfig from version 0.0.98.
10316-
config.as_mut().unwrap().options.forwarding_fee_proportional_millionths = Readable::read(reader)?;
10317-
config.as_mut().unwrap().options.cltv_expiry_delta = Readable::read(reader)?;
10318-
config.as_mut().unwrap().announce_for_forwarding = Readable::read(reader)?;
10319-
config.as_mut().unwrap().commit_upfront_shutdown_pubkey = Readable::read(reader)?;
10320-
} else {
10321-
// Read the 8 bytes of backwards-compatibility ChannelConfig data.
10322-
let mut _val: u64 = Readable::read(reader)?;
10323-
}
10317+
// Read the 8 bytes of backwards-compatibility ChannelConfig data.
10318+
let mut _val: u64 = Readable::read(reader)?;
1032410319

1032510320
let channel_id: ChannelId = Readable::read(reader)?;
1032610321
let channel_state = ChannelState::from_u32(Readable::read(reader)?).map_err(|_| DecodeError::InvalidValue)?;
@@ -10578,6 +10573,8 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1057810573
let mut next_holder_commitment_point_opt: Option<PublicKey> = None;
1057910574
let mut is_manual_broadcast = None;
1058010575

10576+
let mut config = Some(LegacyChannelConfig::default());
10577+
1058110578
read_tlv_fields!(reader, {
1058210579
(0, announcement_sigs, option),
1058310580
(1, minimum_depth, option),

0 commit comments

Comments
 (0)