@@ -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 }
@@ -8731,8 +8721,6 @@ where
87318721 let mut pending_update_adds = Vec::new();
87328722 let mut revoked_htlcs = Vec::new();
87338723 let mut finalized_claimed_htlcs = Vec::new();
8734- let mut update_fail_htlcs = Vec::new();
8735- let mut update_fail_malformed_htlcs = Vec::new();
87368724 let mut static_invoices = Vec::new();
87378725 let mut require_commitment = false;
87388726 let mut value_to_self_msat_diff: i64 = 0;
@@ -8807,43 +8795,6 @@ where
88078795 state
88088796 {
88098797 match resolution {
8810- InboundHTLCResolution::Resolved { pending_htlc_status } => {
8811- match pending_htlc_status {
8812- PendingHTLCStatus::Fail(fail_msg) => {
8813- log_trace!(logger, " ...promoting inbound AwaitingAnnouncedRemoteRevoke {} to LocalRemoved due to PendingHTLCStatus indicating failure", &htlc.payment_hash);
8814- require_commitment = true;
8815- match fail_msg {
8816- HTLCFailureMsg::Relay(msg) => {
8817- htlc.state = InboundHTLCState::LocalRemoved(
8818- InboundHTLCRemovalReason::FailRelay(
8819- msg.clone().into(),
8820- ),
8821- );
8822- update_fail_htlcs.push(msg)
8823- },
8824- HTLCFailureMsg::Malformed(msg) => {
8825- htlc.state = InboundHTLCState::LocalRemoved(
8826- InboundHTLCRemovalReason::FailMalformed {
8827- sha256_of_onion: msg.sha256_of_onion,
8828- failure_code: msg.failure_code,
8829- },
8830- );
8831- update_fail_malformed_htlcs.push(msg)
8832- },
8833- }
8834- },
8835- PendingHTLCStatus::Forward(forward_info) => {
8836- log_trace!(logger, " ...promoting inbound AwaitingAnnouncedRemoteRevoke {} to Committed, attempting to forward", &htlc.payment_hash);
8837- to_forward_infos.push((forward_info, htlc.htlc_id));
8838- htlc.state = InboundHTLCState::Committed {
8839- // HTLCs will only be in state `InboundHTLCResolution::Resolved` if they were
8840- // received on an old pre-0.0.123 version of LDK. In this case, the HTLC is
8841- // required to be resolved prior to upgrading to 0.1+ per CHANGELOG.md.
8842- update_add_htlc_opt: None,
8843- };
8844- },
8845- }
8846- },
88478798 InboundHTLCResolution::Pending { update_add_htlc } => {
88488799 log_trace!(logger, " ...promoting inbound AwaitingAnnouncedRemoteRevoke {} to Committed", &htlc.payment_hash);
88498800 pending_update_adds.push(update_add_htlc.clone());
@@ -8994,9 +8945,11 @@ where
89948945 release_state_str
89958946 );
89968947 if self.context.channel_state.can_generate_new_commitment() {
8997- log_debug!(logger, "Responding with a commitment update with {} HTLCs failed for channel {}",
8998- update_fail_htlcs.len() + update_fail_malformed_htlcs.len(),
8999- &self.context.channel_id);
8948+ log_debug!(
8949+ logger,
8950+ "Responding with a commitment update for channel {}",
8951+ &self.context.channel_id
8952+ );
90008953 } else {
90018954 debug_assert!(htlcs_to_fail.is_empty());
90028955 let reason = if self.context.channel_state.is_local_stfu_sent() {
@@ -15191,8 +15144,9 @@ where
1519115144 let counterparty_next_commitment_transaction_number = Readable::read(reader)?;
1519215145 let value_to_self_msat = Readable::read(reader)?;
1519315146
15194- let pending_inbound_htlc_count: u64 = Readable::read(reader)? ;
15147+ let logger = WithContext::from(logger, None, Some(channel_id), None) ;
1519515148
15149+ let pending_inbound_htlc_count: u64 = Readable::read(reader)?;
1519615150 let mut pending_inbound_htlcs = Vec::with_capacity(cmp::min(
1519715151 pending_inbound_htlc_count as usize,
1519815152 DEFAULT_MAX_HTLCS as usize,
@@ -15205,23 +15159,17 @@ where
1520515159 payment_hash: Readable::read(reader)?,
1520615160 state: match <u8 as Readable>::read(reader)? {
1520715161 1 => {
15208- let resolution = if ver <= 3 {
15209- InboundHTLCResolution::Resolved {
15210- pending_htlc_status: Readable::read(reader)?,
15211- }
15212- } else {
15213- Readable::read(reader)?
15214- };
15162+ let resolution = Readable::read(reader).map_err(|e| {
15163+ 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");
15164+ e
15165+ })?;
1521515166 InboundHTLCState::AwaitingRemoteRevokeToAnnounce(resolution)
1521615167 },
1521715168 2 => {
15218- let resolution = if ver <= 3 {
15219- InboundHTLCResolution::Resolved {
15220- pending_htlc_status: Readable::read(reader)?,
15221- }
15222- } else {
15223- Readable::read(reader)?
15224- };
15169+ let resolution = Readable::read(reader).map_err(|e| {
15170+ 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");
15171+ e
15172+ })?;
1522515173 InboundHTLCState::AwaitingAnnouncedRemoteRevoke(resolution)
1522615174 },
1522715175 3 => InboundHTLCState::Committed { update_add_htlc_opt: None },
0 commit comments