@@ -348,11 +348,11 @@ impl From<&OutboundHTLCState> for OutboundHTLCStateDetails {
348348 // the state yet.
349349 OutboundHTLCState::RemoteRemoved(_) =>
350350 OutboundHTLCStateDetails::Committed,
351- OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(_)) =>
351+ OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(_, _ )) =>
352352 OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess,
353353 OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Failure(_)) =>
354354 OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure,
355- OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(_)) =>
355+ OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(_, _ )) =>
356356 OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess,
357357 OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Failure(_)) =>
358358 OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure,
@@ -387,9 +387,9 @@ impl OutboundHTLCState {
387387 #[rustfmt::skip]
388388 fn preimage(&self) -> Option<PaymentPreimage> {
389389 match self {
390- OutboundHTLCState::RemoteRemoved(OutboundHTLCOutcome::Success(preimage))
391- | OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(preimage))
392- | OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(preimage)) => {
390+ OutboundHTLCState::RemoteRemoved(OutboundHTLCOutcome::Success(preimage, _ ))
391+ | OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(preimage, _ ))
392+ | OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(preimage, _ )) => {
393393 Some(*preimage)
394394 },
395395 _ => None,
@@ -402,14 +402,14 @@ impl OutboundHTLCState {
402402enum OutboundHTLCOutcome {
403403 /// We started always filling in the preimages here in 0.0.105, and the requirement
404404 /// that the preimages always be filled in was added in 0.2.
405- Success(PaymentPreimage),
405+ Success(PaymentPreimage, #[allow(dead_code)] Option<AttributionData> ),
406406 Failure(HTLCFailReason),
407407}
408408
409409impl<'a> Into<Option<&'a HTLCFailReason>> for &'a OutboundHTLCOutcome {
410410 fn into(self) -> Option<&'a HTLCFailReason> {
411411 match self {
412- OutboundHTLCOutcome::Success(_) => None,
412+ OutboundHTLCOutcome::Success(_, _ ) => None,
413413 OutboundHTLCOutcome::Failure(ref r) => Some(r),
414414 }
415415 }
@@ -4159,9 +4159,9 @@ where
41594159 // transaction).
41604160 let mut removed_outbound_total_msat = 0;
41614161 for ref htlc in self.pending_outbound_htlcs.iter() {
4162- if let OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(_)) = htlc.state {
4162+ if let OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(_, _ )) = htlc.state {
41634163 removed_outbound_total_msat += htlc.amount_msat;
4164- } else if let OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(_)) = htlc.state {
4164+ } else if let OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(_, _ )) = htlc.state {
41654165 removed_outbound_total_msat += htlc.amount_msat;
41664166 }
41674167 }
@@ -4424,9 +4424,9 @@ where
44244424
44254425 let mut removed_outbound_total_msat = 0;
44264426 for ref htlc in self.pending_outbound_htlcs.iter() {
4427- if let OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(_)) = htlc.state {
4427+ if let OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(_, _ )) = htlc.state {
44284428 removed_outbound_total_msat += htlc.amount_msat;
4429- } else if let OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(_)) = htlc.state {
4429+ } else if let OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(_, _ )) = htlc.state {
44304430 removed_outbound_total_msat += htlc.amount_msat;
44314431 }
44324432 }
@@ -6694,7 +6694,7 @@ where
66946694 fn mark_outbound_htlc_removed(&mut self, htlc_id: u64, outcome: OutboundHTLCOutcome) -> Result<&OutboundHTLCOutput, ChannelError> {
66956695 for htlc in self.context.pending_outbound_htlcs.iter_mut() {
66966696 if htlc.htlc_id == htlc_id {
6697- if let OutboundHTLCOutcome::Success(ref payment_preimage) = outcome {
6697+ if let OutboundHTLCOutcome::Success(ref payment_preimage, .. ) = outcome {
66986698 let payment_hash = PaymentHash(Sha256::hash(&payment_preimage.0[..]).to_byte_array());
66996699 if payment_hash != htlc.payment_hash {
67006700 return Err(ChannelError::close(format!("Remote tried to fulfill HTLC ({}) with an incorrect preimage", htlc_id)));
@@ -6738,7 +6738,7 @@ where
67386738
67396739 self.mark_outbound_htlc_removed(
67406740 msg.htlc_id,
6741- OutboundHTLCOutcome::Success(msg.payment_preimage),
6741+ OutboundHTLCOutcome::Success(msg.payment_preimage, None ),
67426742 )
67436743 .map(|htlc| (htlc.source.clone(), htlc.amount_msat, htlc.skimmed_fee_msat))
67446744 }
@@ -7078,9 +7078,9 @@ where
70787078 log_trace!(logger, "Updating HTLC {} to AwaitingRemoteRevokeToRemove due to commitment_signed in channel {}.",
70797079 &htlc.payment_hash, &self.context.channel_id);
70807080 // Swap against a dummy variant to avoid a potentially expensive clone of `OutboundHTLCOutcome::Failure(HTLCFailReason)`
7081- let mut reason = OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]));
7081+ let mut reason = OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]), None );
70827082 mem::swap(outcome, &mut reason);
7083- if let OutboundHTLCOutcome::Success(preimage) = reason {
7083+ if let OutboundHTLCOutcome::Success(preimage, _ ) = reason {
70847084 // If a user (a) receives an HTLC claim using LDK 0.0.104 or before, then (b)
70857085 // upgrades to LDK 0.0.114 or later before the HTLC is fully resolved, we could
70867086 // have a `Success(None)` reason. In this case we could forget some HTLC
@@ -7532,7 +7532,7 @@ where
75327532 });
75337533 revoked_htlcs.push((htlc.source.clone(), htlc.payment_hash, reason));
75347534 },
7535- OutboundHTLCOutcome::Success(_ ) => {
7535+ OutboundHTLCOutcome::Success(.. ) => {
75367536 finalized_claimed_htlcs.push(htlc.source.clone());
75377537 // They fulfilled, so we sent them money
75387538 value_to_self_msat_diff -= htlc.amount_msat as i64;
@@ -7620,7 +7620,7 @@ where
76207620 {
76217621 log_trace!(logger, " ...promoting outbound AwaitingRemoteRevokeToRemove {} to AwaitingRemovedRemoteRevoke", &htlc.payment_hash);
76227622 // Swap against a dummy variant to avoid a potentially expensive clone of `OutboundHTLCOutcome::Failure(HTLCFailReason)`
7623- let mut reason = OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]));
7623+ let mut reason = OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]), None );
76247624 mem::swap(outcome, &mut reason);
76257625 htlc.state = OutboundHTLCState::AwaitingRemovedRemoteRevoke(reason);
76267626 require_commitment = true;
@@ -10750,7 +10750,7 @@ where
1075010750 if let &mut OutboundHTLCState::AwaitingRemoteRevokeToRemove(ref mut outcome) = &mut htlc.state {
1075110751 log_trace!(logger, " ...promoting outbound AwaitingRemoteRevokeToRemove {} to AwaitingRemovedRemoteRevoke", &htlc.payment_hash);
1075210752 // Swap against a dummy variant to avoid a potentially expensive clone of `OutboundHTLCOutcome::Failure(HTLCFailReason)`
10753- let mut reason = OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]));
10753+ let mut reason = OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]), None );
1075410754 mem::swap(outcome, &mut reason);
1075510755 htlc.state = OutboundHTLCState::AwaitingRemovedRemoteRevoke(reason);
1075610756 }
@@ -12531,15 +12531,15 @@ where
1253112531 },
1253212532 &OutboundHTLCState::AwaitingRemoteRevokeToRemove(ref outcome) => {
1253312533 3u8.write(writer)?;
12534- if let OutboundHTLCOutcome::Success(preimage) = outcome {
12534+ if let OutboundHTLCOutcome::Success(preimage, _ ) = outcome {
1253512535 preimages.push(Some(preimage));
1253612536 }
1253712537 let reason: Option<&HTLCFailReason> = outcome.into();
1253812538 reason.write(writer)?;
1253912539 },
1254012540 &OutboundHTLCState::AwaitingRemovedRemoteRevoke(ref outcome) => {
1254112541 4u8.write(writer)?;
12542- if let OutboundHTLCOutcome::Success(preimage) = outcome {
12542+ if let OutboundHTLCOutcome::Success(preimage, _ ) = outcome {
1254312543 preimages.push(Some(preimage));
1254412544 }
1254512545 let reason: Option<&HTLCFailReason> = outcome.into();
@@ -12939,7 +12939,7 @@ where
1293912939 let outcome = match option {
1294012940 Some(r) => OutboundHTLCOutcome::Failure(r),
1294112941 // Initialize this variant with a dummy preimage, the actual preimage will be filled in further down
12942- None => OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32])),
12942+ None => OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]), None ),
1294312943 };
1294412944 OutboundHTLCState::RemoteRemoved(outcome)
1294512945 },
@@ -12948,7 +12948,7 @@ where
1294812948 let outcome = match option {
1294912949 Some(r) => OutboundHTLCOutcome::Failure(r),
1295012950 // Initialize this variant with a dummy preimage, the actual preimage will be filled in further down
12951- None => OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32])),
12951+ None => OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]), None ),
1295212952 };
1295312953 OutboundHTLCState::AwaitingRemoteRevokeToRemove(outcome)
1295412954 },
@@ -12957,7 +12957,7 @@ where
1295712957 let outcome = match option {
1295812958 Some(r) => OutboundHTLCOutcome::Failure(r),
1295912959 // Initialize this variant with a dummy preimage, the actual preimage will be filled in further down
12960- None => OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32])),
12960+ None => OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]), None ),
1296112961 };
1296212962 OutboundHTLCState::AwaitingRemovedRemoteRevoke(outcome)
1296312963 },
@@ -13226,6 +13226,7 @@ where
1322613226 match &mut htlc.state {
1322713227 OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(
1322813228 ref mut preimage,
13229+ ..,
1322913230 )) => {
1323013231 // This variant was initialized like this further above
1323113232 debug_assert_eq!(preimage, &PaymentPreimage([0u8; 32]));
@@ -13234,6 +13235,7 @@ where
1323413235 },
1323513236 OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(
1323613237 ref mut preimage,
13238+ ..,
1323713239 )) => {
1323813240 // This variant was initialized like this further above
1323913241 debug_assert_eq!(preimage, &PaymentPreimage([0u8; 32]));
0 commit comments