@@ -10296,13 +10296,13 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
1029610296 }
1029710297}
1029810298
10299- impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c ChannelTypeFeatures)> for FundedChannel<SP>
10299+ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c ChannelTypeFeatures)> for FundedChannel<SP>
1030010300 where
1030110301 ES::Target: EntropySource,
1030210302 SP::Target: SignerProvider
1030310303{
10304- fn read<R : io::Read>(reader: &mut R, args: (&'a ES, &'b SP, u32, &'c ChannelTypeFeatures)) -> Result<Self, DecodeError> {
10305- let (entropy_source, signer_provider, serialized_height, our_supported_features) = args;
10304+ fn read<R : io::Read>(reader: &mut R, args: (&'a ES, &'b SP, &'c ChannelTypeFeatures)) -> Result<Self, DecodeError> {
10305+ let (entropy_source, signer_provider, our_supported_features) = args;
1030610306 let ver = read_ver_prefix!(reader, SERIALIZATION_VERSION);
1030710307 if ver <= 2 {
1030810308 return Err(DecodeError::UnknownVersion);
@@ -10313,7 +10313,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1031310313 // the low bytes now and the high bytes later.
1031410314 let user_id_low: u64 = Readable::read(reader)?;
1031510315
10316- let mut config = Some( LegacyChannelConfig::default() );
10316+ let mut config = LegacyChannelConfig::default();
1031710317 {
1031810318 // Read the 8 bytes of backwards-compatibility ChannelConfig data.
1031910319 let mut _val: u64 = Readable::read(reader)?;
@@ -10533,20 +10533,20 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1053310533 // Prior to supporting channel type negotiation, all of our channels were static_remotekey
1053410534 // only, so we default to that if none was written.
1053510535 let mut channel_type = Some(ChannelTypeFeatures::only_static_remote_key());
10536- let mut channel_creation_height = Some(serialized_height) ;
10536+ let mut channel_creation_height = 0u32 ;
1053710537 let mut preimages_opt: Option<Vec<Option<PaymentPreimage>>> = None;
1053810538
1053910539 // If we read an old Channel, for simplicity we just treat it as "we never sent an
1054010540 // AnnouncementSignatures" which implies we'll re-send it on reconnect, but that's fine.
10541- let mut announcement_sigs_state = Some( AnnouncementSigsState::NotSent) ;
10541+ let mut announcement_sigs_state = AnnouncementSigsState::NotSent;
1054210542 let mut latest_inbound_scid_alias = None;
10543- let mut outbound_scid_alias = None ;
10543+ let mut outbound_scid_alias = 0u64 ;
1054410544 let mut channel_pending_event_emitted = None;
1054510545 let mut channel_ready_event_emitted = None;
1054610546 let mut funding_tx_broadcast_safe_event_emitted = None;
1054710547
1054810548 let mut user_id_high_opt: Option<u64> = None;
10549- let mut channel_keys_id: Option<[u8 ; 32]> = None ;
10549+ let mut channel_keys_id = [0u8 ; 32];
1055010550 let mut temporary_channel_id: Option<ChannelId> = None;
1055110551 let mut holder_max_accepted_htlcs: Option<u16> = None;
1055210552
@@ -10575,21 +10575,21 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1057510575 (2, channel_type, option),
1057610576 (3, counterparty_selected_channel_reserve_satoshis, option),
1057710577 (4, holder_selected_channel_reserve_satoshis, option),
10578- (5, config, option), // Note that if none is provided we will *not* overwrite the existing one.
10578+ (5, config, required),
1057910579 (6, holder_max_htlc_value_in_flight_msat, option),
1058010580 (7, shutdown_scriptpubkey, option),
1058110581 (8, blocked_monitor_updates, optional_vec),
1058210582 (9, target_closing_feerate_sats_per_kw, option),
1058310583 (10, monitor_pending_update_adds, option), // Added in 0.0.122
1058410584 (11, monitor_pending_finalized_fulfills, optional_vec),
10585- (13, channel_creation_height, option ),
10585+ (13, channel_creation_height, required ),
1058610586 (15, preimages_opt, optional_vec),
10587- (17, announcement_sigs_state, option ),
10587+ (17, announcement_sigs_state, required ),
1058810588 (19, latest_inbound_scid_alias, option),
10589- (21, outbound_scid_alias, option ),
10589+ (21, outbound_scid_alias, required ),
1059010590 (23, channel_ready_event_emitted, option),
1059110591 (25, user_id_high_opt, option),
10592- (27, channel_keys_id, option ),
10592+ (27, channel_keys_id, required ),
1059310593 (28, holder_max_accepted_htlcs, option),
1059410594 (29, temporary_channel_id, option),
1059510595 (31, channel_pending_event_emitted, option),
@@ -10606,12 +10606,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1060610606 (53, funding_tx_broadcast_safe_event_emitted, option),
1060710607 });
1060810608
10609- let (channel_keys_id, holder_signer) = if let Some(channel_keys_id) = channel_keys_id {
10610- let holder_signer = signer_provider.derive_channel_signer(channel_keys_id);
10611- (channel_keys_id, holder_signer)
10612- } else {
10613- return Err(DecodeError::InvalidValue);
10614- };
10609+ let holder_signer = signer_provider.derive_channel_signer(channel_keys_id);
1061510610
1061610611 if let Some(preimages) = preimages_opt {
1061710612 let mut iter = preimages.into_iter();
@@ -10753,7 +10748,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1075310748 context: ChannelContext {
1075410749 user_id,
1075510750
10756- config: config.unwrap() ,
10751+ config,
1075710752
1075810753 prev_config: None,
1075910754
@@ -10764,7 +10759,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1076410759 channel_id,
1076510760 temporary_channel_id,
1076610761 channel_state,
10767- announcement_sigs_state: announcement_sigs_state.unwrap() ,
10762+ announcement_sigs_state,
1076810763 secp_ctx,
1076910764
1077010765 latest_monitor_update_id,
@@ -10814,7 +10809,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1081410809 funding_tx_confirmed_in,
1081510810 funding_tx_confirmation_height,
1081610811 short_channel_id,
10817- channel_creation_height: channel_creation_height.unwrap() ,
10812+ channel_creation_height,
1081810813
1081910814 counterparty_dust_limit_satoshis,
1082010815 holder_dust_limit_satoshis,
@@ -10847,7 +10842,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1084710842
1084810843 latest_inbound_scid_alias,
1084910844 // Later in the ChannelManager deserialization phase we scan for channels and assign scid aliases if its missing
10850- outbound_scid_alias: outbound_scid_alias.unwrap_or(0) ,
10845+ outbound_scid_alias,
1085110846
1085210847 funding_tx_broadcast_safe_event_emitted: funding_tx_broadcast_safe_event_emitted.unwrap_or(false),
1085310848 channel_pending_event_emitted: channel_pending_event_emitted.unwrap_or(true),
@@ -11556,7 +11551,7 @@ mod tests {
1155611551 let mut s = crate::io::Cursor::new(&encoded_chan);
1155711552 let mut reader = crate::util::ser::FixedLengthReader::new(&mut s, encoded_chan.len() as u64);
1155811553 let features = channelmanager::provided_channel_type_features(&config);
11559- let decoded_chan = FundedChannel::read(&mut reader, (&&keys_provider, &&keys_provider, 0, &features)).unwrap();
11554+ let decoded_chan = FundedChannel::read(&mut reader, (&&keys_provider, &&keys_provider, &features)).unwrap();
1156011555 assert_eq!(decoded_chan.context.pending_outbound_htlcs, pending_outbound_htlcs);
1156111556 assert_eq!(decoded_chan.context.holding_cell_htlc_updates, holding_cell_htlc_updates);
1156211557 }
0 commit comments