@@ -50,10 +50,9 @@ use crate::ln::channel_state::{
5050 OutboundHTLCDetails, OutboundHTLCStateDetails,
5151};
5252use crate::ln::channelmanager::{
53- self, ChannelReadyOrder, FundingConfirmedMessage, HTLCFailureMsg, HTLCPreviousHopData,
54- HTLCSource, OpenChannelMessage, PaymentClaimDetails, PendingHTLCInfo, PendingHTLCStatus,
55- RAACommitmentOrder, SentHTLCId, BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT,
56- MIN_CLTV_EXPIRY_DELTA,
53+ self, ChannelReadyOrder, FundingConfirmedMessage, HTLCPreviousHopData, HTLCSource,
54+ OpenChannelMessage, PaymentClaimDetails, PendingHTLCInfo, RAACommitmentOrder, SentHTLCId,
55+ BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA,
5756};
5857use crate::ln::funding::{FundingTxInput, SpliceContribution};
5958use crate::ln::interactivetxs::{
@@ -149,22 +148,14 @@ enum InboundHTLCRemovalReason {
149148#[cfg_attr(test, derive(Debug))]
150149#[derive(Clone)]
151150enum InboundHTLCResolution {
152- /// Resolved implies the action we must take with the inbound HTLC has already been determined,
153- /// i.e., we already know whether it must be failed back or forwarded.
154- //
155- // TODO: Once this variant is removed, we should also clean up
156- // [`MonitorRestoreUpdates::accepted_htlcs`] as the path will be unreachable.
157- Resolved { pending_htlc_status: PendingHTLCStatus },
158151 /// Pending implies we will attempt to resolve the inbound HTLC once it has been fully committed
159152 /// to by both sides of the channel, i.e., once a `revoke_and_ack` has been processed by both
160153 /// nodes for the state update in which it was proposed.
161154 Pending { update_add_htlc: msgs::UpdateAddHTLC },
162155}
163156
164157impl_writeable_tlv_based_enum!(InboundHTLCResolution,
165- (0, Resolved) => {
166- (0, pending_htlc_status, required),
167- },
158+ // 0 used to be used for InboundHTLCResolution::Resolved in 0.2 and below.
168159 (2, Pending) => {
169160 (0, update_add_htlc, required),
170161 },
@@ -301,7 +292,6 @@ impl InboundHTLCState {
301292 InboundHTLCResolution::Pending { update_add_htlc } => {
302293 update_add_htlc.hold_htlc.is_some()
303294 },
304- InboundHTLCResolution::Resolved { .. } => false,
305295 },
306296 InboundHTLCState::Committed { .. } | InboundHTLCState::LocalRemoved(_) => false,
307297 }
@@ -8691,8 +8681,6 @@ where
86918681 let mut pending_update_adds = Vec::new();
86928682 let mut revoked_htlcs = Vec::new();
86938683 let mut finalized_claimed_htlcs = Vec::new();
8694- let mut update_fail_htlcs = Vec::new();
8695- let mut update_fail_malformed_htlcs = Vec::new();
86968684 let mut static_invoices = Vec::new();
86978685 let mut require_commitment = false;
86988686 let mut value_to_self_msat_diff: i64 = 0;
@@ -8767,43 +8755,6 @@ where
87678755 state
87688756 {
87698757 match resolution {
8770- InboundHTLCResolution::Resolved { pending_htlc_status } => {
8771- match pending_htlc_status {
8772- PendingHTLCStatus::Fail(fail_msg) => {
8773- log_trace!(logger, " ...promoting inbound AwaitingAnnouncedRemoteRevoke {} to LocalRemoved due to PendingHTLCStatus indicating failure", &htlc.payment_hash);
8774- require_commitment = true;
8775- match fail_msg {
8776- HTLCFailureMsg::Relay(msg) => {
8777- htlc.state = InboundHTLCState::LocalRemoved(
8778- InboundHTLCRemovalReason::FailRelay(
8779- msg.clone().into(),
8780- ),
8781- );
8782- update_fail_htlcs.push(msg)
8783- },
8784- HTLCFailureMsg::Malformed(msg) => {
8785- htlc.state = InboundHTLCState::LocalRemoved(
8786- InboundHTLCRemovalReason::FailMalformed {
8787- sha256_of_onion: msg.sha256_of_onion,
8788- failure_code: msg.failure_code,
8789- },
8790- );
8791- update_fail_malformed_htlcs.push(msg)
8792- },
8793- }
8794- },
8795- PendingHTLCStatus::Forward(forward_info) => {
8796- log_trace!(logger, " ...promoting inbound AwaitingAnnouncedRemoteRevoke {} to Committed, attempting to forward", &htlc.payment_hash);
8797- to_forward_infos.push((forward_info, htlc.htlc_id));
8798- htlc.state = InboundHTLCState::Committed {
8799- // HTLCs will only be in state `InboundHTLCResolution::Resolved` if they were
8800- // received on an old pre-0.0.123 version of LDK. In this case, the HTLC is
8801- // required to be resolved prior to upgrading to 0.1+ per CHANGELOG.md.
8802- update_add_htlc_opt: None,
8803- };
8804- },
8805- }
8806- },
88078758 InboundHTLCResolution::Pending { update_add_htlc } => {
88088759 log_trace!(logger, " ...promoting inbound AwaitingAnnouncedRemoteRevoke {} to Committed", &htlc.payment_hash);
88098760 pending_update_adds.push(update_add_htlc.clone());
@@ -8953,9 +8904,11 @@ where
89538904 release_state_str
89548905 );
89558906 if self.context.channel_state.can_generate_new_commitment() {
8956- log_debug!(logger, "Responding with a commitment update with {} HTLCs failed for channel {}",
8957- update_fail_htlcs.len() + update_fail_malformed_htlcs.len(),
8958- &self.context.channel_id);
8907+ log_debug!(
8908+ logger,
8909+ "Responding with a commitment update for channel {}",
8910+ &self.context.channel_id
8911+ );
89598912 } else {
89608913 debug_assert!(htlcs_to_fail.is_empty());
89618914 let reason = if self.context.channel_state.is_local_stfu_sent() {
@@ -15042,8 +14995,9 @@ where
1504214995 let counterparty_next_commitment_transaction_number = Readable::read(reader)?;
1504314996 let value_to_self_msat = Readable::read(reader)?;
1504414997
15045- let pending_inbound_htlc_count: u64 = Readable::read(reader)? ;
14998+ let logger = WithContext::from(logger, None, Some(channel_id), None) ;
1504614999
15000+ let pending_inbound_htlc_count: u64 = Readable::read(reader)?;
1504715001 let mut pending_inbound_htlcs = Vec::with_capacity(cmp::min(
1504815002 pending_inbound_htlc_count as usize,
1504915003 DEFAULT_MAX_HTLCS as usize,
@@ -15056,23 +15010,17 @@ where
1505615010 payment_hash: Readable::read(reader)?,
1505715011 state: match <u8 as Readable>::read(reader)? {
1505815012 1 => {
15059- let resolution = if ver <= 3 {
15060- InboundHTLCResolution::Resolved {
15061- pending_htlc_status: Readable::read(reader)?,
15062- }
15063- } else {
15064- Readable::read(reader)?
15065- };
15013+ let resolution = Readable::read(reader).map_err(|e| {
15014+ 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");
15015+ e
15016+ })?;
1506615017 InboundHTLCState::AwaitingRemoteRevokeToAnnounce(resolution)
1506715018 },
1506815019 2 => {
15069- let resolution = if ver <= 3 {
15070- InboundHTLCResolution::Resolved {
15071- pending_htlc_status: Readable::read(reader)?,
15072- }
15073- } else {
15074- Readable::read(reader)?
15075- };
15020+ let resolution = Readable::read(reader).map_err(|e| {
15021+ 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");
15022+ e
15023+ })?;
1507615024 InboundHTLCState::AwaitingAnnouncedRemoteRevoke(resolution)
1507715025 },
1507815026 3 => InboundHTLCState::Committed { update_add_htlc_opt: None },
0 commit comments