Skip to content

Commit cc57595

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 37e57dd commit cc57595

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

lightning/src/ln/channel.rs

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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>)>,
@@ -2895,7 +2896,6 @@ where
28952896
// responsible for some of the HTLCs here or not - we don't know whether the update in question
28962897
// completed or not. We currently ignore these fields entirely when force-closing a channel,
28972898
// but need to handle this somehow or we run the risk of losing HTLCs!
2898-
monitor_pending_forwards: Vec<(PendingHTLCInfo, u64)>,
28992899
monitor_pending_failures: Vec<(HTLCSource, PaymentHash, HTLCFailReason)>,
29002900
monitor_pending_finalized_fulfills: Vec<(HTLCSource, Option<AttributionData>)>,
29012901
monitor_pending_update_adds: Vec<msgs::UpdateAddHTLC>,
@@ -3621,7 +3621,6 @@ where
36213621
monitor_pending_channel_ready: false,
36223622
monitor_pending_revoke_and_ack: false,
36233623
monitor_pending_commitment_signed: false,
3624-
monitor_pending_forwards: Vec::new(),
36253624
monitor_pending_failures: Vec::new(),
36263625
monitor_pending_finalized_fulfills: Vec::new(),
36273626
monitor_pending_update_adds: Vec::new(),
@@ -3860,7 +3859,6 @@ where
38603859
monitor_pending_channel_ready: false,
38613860
monitor_pending_revoke_and_ack: false,
38623861
monitor_pending_commitment_signed: false,
3863-
monitor_pending_forwards: Vec::new(),
38643862
monitor_pending_failures: Vec::new(),
38653863
monitor_pending_finalized_fulfills: Vec::new(),
38663864
monitor_pending_update_adds: Vec::new(),
@@ -9407,8 +9405,6 @@ where
94079405

94089406
let announcement_sigs = self.get_announcement_sigs(node_signer, chain_hash, user_config, best_block_height, logger);
94099407

9410-
let mut accepted_htlcs = Vec::new();
9411-
mem::swap(&mut accepted_htlcs, &mut self.context.monitor_pending_forwards);
94129408
let mut failed_htlcs = Vec::new();
94139409
mem::swap(&mut failed_htlcs, &mut self.context.monitor_pending_failures);
94149410
let mut finalized_claimed_htlcs = Vec::new();
@@ -9429,7 +9425,7 @@ where
94299425
self.context.monitor_pending_commitment_signed = false;
94309426
return MonitorRestoreUpdates {
94319427
raa: None, commitment_update: None, commitment_order: RAACommitmentOrder::RevokeAndACKFirst,
9432-
accepted_htlcs, failed_htlcs, finalized_claimed_htlcs, pending_update_adds,
9428+
accepted_htlcs: Vec::new(), failed_htlcs, finalized_claimed_htlcs, pending_update_adds,
94339429
funding_broadcastable, channel_ready, announcement_sigs, tx_signatures: None,
94349430
channel_ready_order, committed_outbound_htlc_sources
94359431
};
@@ -9460,7 +9456,7 @@ where
94609456
if commitment_update.is_some() { "a" } else { "no" }, if raa.is_some() { "an" } else { "no" },
94619457
match commitment_order { RAACommitmentOrder::CommitmentFirst => "commitment", RAACommitmentOrder::RevokeAndACKFirst => "RAA"});
94629458
MonitorRestoreUpdates {
9463-
raa, commitment_update, commitment_order, accepted_htlcs, failed_htlcs, finalized_claimed_htlcs,
9459+
raa, commitment_update, commitment_order, accepted_htlcs: Vec::new(), failed_htlcs, finalized_claimed_htlcs,
94649460
pending_update_adds, funding_broadcastable, channel_ready, announcement_sigs, tx_signatures: None,
94659461
channel_ready_order, committed_outbound_htlc_sources
94669462
}
@@ -14828,11 +14824,8 @@ where
1482814824
self.context.monitor_pending_revoke_and_ack.write(writer)?;
1482914825
self.context.monitor_pending_commitment_signed.write(writer)?;
1483014826

14831-
(self.context.monitor_pending_forwards.len() as u64).write(writer)?;
14832-
for &(ref pending_forward, ref htlc_id) in self.context.monitor_pending_forwards.iter() {
14833-
pending_forward.write(writer)?;
14834-
htlc_id.write(writer)?;
14835-
}
14827+
// Previously used for monitor_pending_forwards prior to LDK 0.3.
14828+
0u64.write(writer)?;
1483614829

1483714830
(self.context.monitor_pending_failures.len() as u64).write(writer)?;
1483814831
for &(ref htlc_source, ref payment_hash, ref fail_reason) in
@@ -15250,13 +15243,10 @@ where
1525015243
let monitor_pending_revoke_and_ack = Readable::read(reader)?;
1525115244
let monitor_pending_commitment_signed = Readable::read(reader)?;
1525215245

15253-
let monitor_pending_forwards_count: u64 = Readable::read(reader)?;
15254-
let mut monitor_pending_forwards = Vec::with_capacity(cmp::min(
15255-
monitor_pending_forwards_count as usize,
15256-
DEFAULT_MAX_HTLCS as usize,
15257-
));
15258-
for _ in 0..monitor_pending_forwards_count {
15259-
monitor_pending_forwards.push((Readable::read(reader)?, Readable::read(reader)?));
15246+
let monitor_pending_forwards_count_legacy: u64 = Readable::read(reader)?;
15247+
if monitor_pending_forwards_count_legacy != 0 {
15248+
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");
15249+
return Err(DecodeError::InvalidValue);
1526015250
}
1526115251

1526215252
let monitor_pending_failures_count: u64 = Readable::read(reader)?;
@@ -15830,7 +15820,6 @@ where
1583015820
monitor_pending_channel_ready,
1583115821
monitor_pending_revoke_and_ack,
1583215822
monitor_pending_commitment_signed,
15833-
monitor_pending_forwards,
1583415823
monitor_pending_failures,
1583515824
monitor_pending_finalized_fulfills: monitor_pending_finalized_fulfills.unwrap(),
1583615825
monitor_pending_update_adds: monitor_pending_update_adds.unwrap_or_default(),

0 commit comments

Comments
 (0)