@@ -1122,6 +1122,7 @@ pub(super) struct MonitorRestoreUpdates {
11221122 // A `CommitmentUpdate` to be sent to our channel peer.
11231123 pub commitment_update: Option<msgs::CommitmentUpdate>,
11241124 pub commitment_order: RAACommitmentOrder,
1125+ // TODO: get rid of this
11251126 pub accepted_htlcs: Vec<(PendingHTLCInfo, u64)>,
11261127 pub failed_htlcs: Vec<(HTLCSource, PaymentHash, HTLCFailReason)>,
11271128 pub finalized_claimed_htlcs: Vec<(HTLCSource, Option<AttributionData>)>,
@@ -2900,7 +2901,6 @@ where
29002901 // responsible for some of the HTLCs here or not - we don't know whether the update in question
29012902 // completed or not. We currently ignore these fields entirely when force-closing a channel,
29022903 // but need to handle this somehow or we run the risk of losing HTLCs!
2903- monitor_pending_forwards: Vec<(PendingHTLCInfo, u64)>,
29042904 monitor_pending_failures: Vec<(HTLCSource, PaymentHash, HTLCFailReason)>,
29052905 monitor_pending_finalized_fulfills: Vec<(HTLCSource, Option<AttributionData>)>,
29062906 monitor_pending_update_adds: Vec<msgs::UpdateAddHTLC>,
@@ -3626,7 +3626,6 @@ where
36263626 monitor_pending_channel_ready: false,
36273627 monitor_pending_revoke_and_ack: false,
36283628 monitor_pending_commitment_signed: false,
3629- monitor_pending_forwards: Vec::new(),
36303629 monitor_pending_failures: Vec::new(),
36313630 monitor_pending_finalized_fulfills: Vec::new(),
36323631 monitor_pending_update_adds: Vec::new(),
@@ -3865,7 +3864,6 @@ where
38653864 monitor_pending_channel_ready: false,
38663865 monitor_pending_revoke_and_ack: false,
38673866 monitor_pending_commitment_signed: false,
3868- monitor_pending_forwards: Vec::new(),
38693867 monitor_pending_failures: Vec::new(),
38703868 monitor_pending_finalized_fulfills: Vec::new(),
38713869 monitor_pending_update_adds: Vec::new(),
@@ -9374,8 +9372,6 @@ where
93749372
93759373 let announcement_sigs = self.get_announcement_sigs(node_signer, chain_hash, user_config, best_block_height, logger);
93769374
9377- let mut accepted_htlcs = Vec::new();
9378- mem::swap(&mut accepted_htlcs, &mut self.context.monitor_pending_forwards);
93799375 let mut failed_htlcs = Vec::new();
93809376 mem::swap(&mut failed_htlcs, &mut self.context.monitor_pending_failures);
93819377 let mut finalized_claimed_htlcs = Vec::new();
@@ -9396,7 +9392,7 @@ where
93969392 self.context.monitor_pending_commitment_signed = false;
93979393 return MonitorRestoreUpdates {
93989394 raa: None, commitment_update: None, commitment_order: RAACommitmentOrder::RevokeAndACKFirst,
9399- accepted_htlcs, failed_htlcs, finalized_claimed_htlcs, pending_update_adds,
9395+ accepted_htlcs: Vec::new() , failed_htlcs, finalized_claimed_htlcs, pending_update_adds,
94009396 funding_broadcastable, channel_ready, announcement_sigs, tx_signatures: None,
94019397 channel_ready_order, committed_outbound_htlc_sources
94029398 };
@@ -9427,7 +9423,7 @@ where
94279423 if commitment_update.is_some() { "a" } else { "no" }, if raa.is_some() { "an" } else { "no" },
94289424 match commitment_order { RAACommitmentOrder::CommitmentFirst => "commitment", RAACommitmentOrder::RevokeAndACKFirst => "RAA"});
94299425 MonitorRestoreUpdates {
9430- raa, commitment_update, commitment_order, accepted_htlcs, failed_htlcs, finalized_claimed_htlcs,
9426+ raa, commitment_update, commitment_order, accepted_htlcs: Vec::new() , failed_htlcs, finalized_claimed_htlcs,
94319427 pending_update_adds, funding_broadcastable, channel_ready, announcement_sigs, tx_signatures: None,
94329428 channel_ready_order, committed_outbound_htlc_sources
94339429 }
@@ -14725,11 +14721,8 @@ where
1472514721 self.context.monitor_pending_revoke_and_ack.write(writer)?;
1472614722 self.context.monitor_pending_commitment_signed.write(writer)?;
1472714723
14728- (self.context.monitor_pending_forwards.len() as u64).write(writer)?;
14729- for &(ref pending_forward, ref htlc_id) in self.context.monitor_pending_forwards.iter() {
14730- pending_forward.write(writer)?;
14731- htlc_id.write(writer)?;
14732- }
14724+ // Previously used for monitor_pending_forwards prior to LDK 0.3.
14725+ 0u64.write(writer)?;
1473314726
1473414727 (self.context.monitor_pending_failures.len() as u64).write(writer)?;
1473514728 for &(ref htlc_source, ref payment_hash, ref fail_reason) in
@@ -15147,13 +15140,10 @@ where
1514715140 let monitor_pending_revoke_and_ack = Readable::read(reader)?;
1514815141 let monitor_pending_commitment_signed = Readable::read(reader)?;
1514915142
15150- let monitor_pending_forwards_count: u64 = Readable::read(reader)?;
15151- let mut monitor_pending_forwards = Vec::with_capacity(cmp::min(
15152- monitor_pending_forwards_count as usize,
15153- DEFAULT_MAX_HTLCS as usize,
15154- ));
15155- for _ in 0..monitor_pending_forwards_count {
15156- monitor_pending_forwards.push((Readable::read(reader)?, Readable::read(reader)?));
15143+ let monitor_pending_forwards_count_legacy: u64 = Readable::read(reader)?;
15144+ if monitor_pending_forwards_count_legacy != 0 {
15145+ log_error!(logger, "Found deprecated HTLC received on LDK 0.0.123 or earlier. HTLC must be resolved before upgrading to LDK 0.3+, see CHANGELOG.md");
15146+ return Err(DecodeError::InvalidValue);
1515715147 }
1515815148
1515915149 let monitor_pending_failures_count: u64 = Readable::read(reader)?;
@@ -15727,7 +15717,6 @@ where
1572715717 monitor_pending_channel_ready,
1572815718 monitor_pending_revoke_and_ack,
1572915719 monitor_pending_commitment_signed,
15730- monitor_pending_forwards,
1573115720 monitor_pending_failures,
1573215721 monitor_pending_finalized_fulfills: monitor_pending_finalized_fulfills.unwrap(),
1573315722 monitor_pending_update_adds: monitor_pending_update_adds.unwrap_or_default(),
0 commit comments