Skip to content

Commit ffe3f0e

Browse files
Delete now-unused ChannelContext::monitor_pending_forwards
We stopped adding any HTLCs to this vec a few commits ago when we removed support for HTLCs that were originally received on LDK 0.0.123-.
1 parent 622b39d commit ffe3f0e

1 file changed

Lines changed: 9 additions & 20 deletions

File tree

lightning/src/ln/channel.rs

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,7 @@ pub(super) struct MonitorRestoreUpdates {
11241124
// A `CommitmentUpdate` to be sent to our channel peer.
11251125
pub commitment_update: Option<msgs::CommitmentUpdate>,
11261126
pub commitment_order: RAACommitmentOrder,
1127+
// TODO: get rid of this
11271128
pub accepted_htlcs: Vec<(PendingHTLCInfo, u64)>,
11281129
pub failed_htlcs: Vec<(HTLCSource, PaymentHash, HTLCFailReason)>,
11291130
pub finalized_claimed_htlcs: Vec<(HTLCSource, Option<AttributionData>)>,
@@ -2897,7 +2898,6 @@ where
28972898
// responsible for some of the HTLCs here or not - we don't know whether the update in question
28982899
// completed or not. We currently ignore these fields entirely when force-closing a channel,
28992900
// but need to handle this somehow or we run the risk of losing HTLCs!
2900-
monitor_pending_forwards: Vec<(PendingHTLCInfo, u64)>,
29012901
monitor_pending_failures: Vec<(HTLCSource, PaymentHash, HTLCFailReason)>,
29022902
monitor_pending_finalized_fulfills: Vec<(HTLCSource, Option<AttributionData>)>,
29032903
monitor_pending_update_adds: Vec<msgs::UpdateAddHTLC>,
@@ -3623,7 +3623,6 @@ where
36233623
monitor_pending_channel_ready: false,
36243624
monitor_pending_revoke_and_ack: false,
36253625
monitor_pending_commitment_signed: false,
3626-
monitor_pending_forwards: Vec::new(),
36273626
monitor_pending_failures: Vec::new(),
36283627
monitor_pending_finalized_fulfills: Vec::new(),
36293628
monitor_pending_update_adds: Vec::new(),
@@ -3862,7 +3861,6 @@ where
38623861
monitor_pending_channel_ready: false,
38633862
monitor_pending_revoke_and_ack: false,
38643863
monitor_pending_commitment_signed: false,
3865-
monitor_pending_forwards: Vec::new(),
38663864
monitor_pending_failures: Vec::new(),
38673865
monitor_pending_finalized_fulfills: Vec::new(),
38683866
monitor_pending_update_adds: Vec::new(),
@@ -9410,8 +9408,6 @@ where
94109408

94119409
let announcement_sigs = self.get_announcement_sigs(node_signer, chain_hash, user_config, best_block_height, logger);
94129410

9413-
let mut accepted_htlcs = Vec::new();
9414-
mem::swap(&mut accepted_htlcs, &mut self.context.monitor_pending_forwards);
94159411
let mut failed_htlcs = Vec::new();
94169412
mem::swap(&mut failed_htlcs, &mut self.context.monitor_pending_failures);
94179413
let mut finalized_claimed_htlcs = Vec::new();
@@ -9432,7 +9428,7 @@ where
94329428
self.context.monitor_pending_commitment_signed = false;
94339429
return MonitorRestoreUpdates {
94349430
raa: None, commitment_update: None, commitment_order: RAACommitmentOrder::RevokeAndACKFirst,
9435-
accepted_htlcs, failed_htlcs, finalized_claimed_htlcs, pending_update_adds,
9431+
accepted_htlcs: Vec::new(), failed_htlcs, finalized_claimed_htlcs, pending_update_adds,
94369432
funding_broadcastable, channel_ready, announcement_sigs, tx_signatures: None,
94379433
channel_ready_order, committed_outbound_htlc_sources
94389434
};
@@ -9463,7 +9459,7 @@ where
94639459
if commitment_update.is_some() { "a" } else { "no" }, if raa.is_some() { "an" } else { "no" },
94649460
match commitment_order { RAACommitmentOrder::CommitmentFirst => "commitment", RAACommitmentOrder::RevokeAndACKFirst => "RAA"});
94659461
MonitorRestoreUpdates {
9466-
raa, commitment_update, commitment_order, accepted_htlcs, failed_htlcs, finalized_claimed_htlcs,
9462+
raa, commitment_update, commitment_order, accepted_htlcs: Vec::new(), failed_htlcs, finalized_claimed_htlcs,
94679463
pending_update_adds, funding_broadcastable, channel_ready, announcement_sigs, tx_signatures: None,
94689464
channel_ready_order, committed_outbound_htlc_sources
94699465
}
@@ -14844,11 +14840,8 @@ where
1484414840
self.context.monitor_pending_revoke_and_ack.write(writer)?;
1484514841
self.context.monitor_pending_commitment_signed.write(writer)?;
1484614842

14847-
(self.context.monitor_pending_forwards.len() as u64).write(writer)?;
14848-
for &(ref pending_forward, ref htlc_id) in self.context.monitor_pending_forwards.iter() {
14849-
pending_forward.write(writer)?;
14850-
htlc_id.write(writer)?;
14851-
}
14843+
// Previously used for monitor_pending_forwards prior to LDK 0.3.
14844+
0u64.write(writer)?;
1485214845

1485314846
(self.context.monitor_pending_failures.len() as u64).write(writer)?;
1485414847
for &(ref htlc_source, ref payment_hash, ref fail_reason) in
@@ -15270,13 +15263,10 @@ where
1527015263
let monitor_pending_revoke_and_ack = Readable::read(reader)?;
1527115264
let monitor_pending_commitment_signed = Readable::read(reader)?;
1527215265

15273-
let monitor_pending_forwards_count: u64 = Readable::read(reader)?;
15274-
let mut monitor_pending_forwards = Vec::with_capacity(cmp::min(
15275-
monitor_pending_forwards_count as usize,
15276-
DEFAULT_MAX_HTLCS as usize,
15277-
));
15278-
for _ in 0..monitor_pending_forwards_count {
15279-
monitor_pending_forwards.push((Readable::read(reader)?, Readable::read(reader)?));
15266+
let monitor_pending_forwards_count_legacy: u64 = Readable::read(reader)?;
15267+
if monitor_pending_forwards_count_legacy != 0 {
15268+
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");
15269+
return Err(DecodeError::InvalidValue);
1528015270
}
1528115271

1528215272
let monitor_pending_failures_count: u64 = Readable::read(reader)?;
@@ -15876,7 +15866,6 @@ where
1587615866
monitor_pending_channel_ready,
1587715867
monitor_pending_revoke_and_ack,
1587815868
monitor_pending_commitment_signed,
15879-
monitor_pending_forwards,
1588015869
monitor_pending_failures,
1588115870
monitor_pending_finalized_fulfills: monitor_pending_finalized_fulfills.unwrap(),
1588215871
monitor_pending_update_adds: monitor_pending_update_adds.unwrap_or_default(),

0 commit comments

Comments
 (0)