@@ -17713,16 +17713,16 @@ pub fn provided_init_features(config: &UserConfig) -> InitFeatures {
1771317713const SERIALIZATION_VERSION: u8 = 1;
1771417714const MIN_SERIALIZATION_VERSION: u8 = 1;
1771517715
17716- // We plan to start writing this version in 0.5.
17716+ // We plan to start writing this version a few versions after we start writing inbound committed
17717+ // payment onions in `Channel`, which is already done in tests but not yet switched on in prod.
1771717718//
17718- // LDK 0.5+ will reconstruct the set of pending HTLCs from `Channel{Monitor}` data that started
17719- // being written in 0.3 , ignoring legacy `ChannelManager` HTLC maps on read and not writing them.
17720- // LDK 0.5+ will automatically fail to read if the pending HTLC set cannot be reconstructed, i.e.
17721- // if we were last written with pending HTLCs on 0.2- or if the new 0.3+ fields are missing.
17719+ // If we see this version on read, we will use said onions when reconstructing the set of pending
17720+ // HTLCs , ignoring legacy `ChannelManager` HTLC maps on read and not writing them. We'll also
17721+ // automatically fail to read if the pending HTLC set cannot be reconstructed, i.e. if the new
17722+ // payment onion field is missing.
1772217723//
17723- // If 0.3 or 0.4 reads this manager version, it knows that the legacy maps were not written and
17724- // acts accordingly.
17725- const RECONSTRUCT_HTLCS_FROM_CHANS_VERSION: u8 = 2;
17724+ // Left as `None` for now until we are committed to writing inbound committed onions in `Channel`s.
17725+ const RECONSTRUCT_HTLCS_FROM_CHANS_VERSION: Option<u8> = None;
1772617726
1772717727impl_writeable_tlv_based!(PhantomRouteHints, {
1772817728 (2, channels, required_vec),
@@ -18549,7 +18549,7 @@ impl<'a, ES: EntropySource, SP: SignerProvider, L: Logger>
1854918549 }
1855018550
1855118551 let forward_htlcs_legacy: HashMap<u64, Vec<HTLCForwardInfo>> =
18552- if version < RECONSTRUCT_HTLCS_FROM_CHANS_VERSION {
18552+ if RECONSTRUCT_HTLCS_FROM_CHANS_VERSION.map_or(true, |v| version < v) {
1855318553 let forward_htlcs_count: u64 = Readable::read(reader)?;
1855418554 let mut fwds = hash_map_with_capacity(cmp::min(forward_htlcs_count as usize, 128));
1855518555 for _ in 0..forward_htlcs_count {
@@ -19695,7 +19695,8 @@ impl<
1969519695 // `reconstruct_manager_from_monitors` is set below. Currently we set in tests randomly to
1969619696 // ensure the legacy codepaths also have test coverage.
1969719697 #[cfg(not(test))]
19698- let reconstruct_manager_from_monitors = _version >= RECONSTRUCT_HTLCS_FROM_CHANS_VERSION;
19698+ let reconstruct_manager_from_monitors =
19699+ RECONSTRUCT_HTLCS_FROM_CHANS_VERSION.is_some_and(|v| _version >= v);
1969919700 #[cfg(test)]
1970019701 let reconstruct_manager_from_monitors =
1970119702 args.reconstruct_manager_from_monitors.unwrap_or_else(|| {
@@ -19758,7 +19759,6 @@ impl<
1975819759 if reconstruct_manager_from_monitors {
1975919760 if let Some(chan) = peer_state.channel_by_id.get(channel_id) {
1976019761 if let Some(funded_chan) = chan.as_funded() {
19761- // Legacy HTLCs are from pre-LDK 0.3 and cannot be reconstructed.
1976219762 if funded_chan.has_legacy_inbound_htlcs() {
1976319763 return Err(DecodeError::InvalidValue);
1976419764 }
0 commit comments