@@ -353,11 +353,11 @@ impl From<&OutboundHTLCState> for OutboundHTLCStateDetails {
353353 // the state yet.
354354 OutboundHTLCState::RemoteRemoved(_) =>
355355 OutboundHTLCStateDetails::Committed,
356- OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(_, _) ) =>
356+ OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success{..} ) =>
357357 OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess,
358358 OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Failure(_)) =>
359359 OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure,
360- OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(_, _) ) =>
360+ OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success{..} ) =>
361361 OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess,
362362 OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Failure(_)) =>
363363 OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure,
@@ -392,9 +392,9 @@ impl OutboundHTLCState {
392392 #[rustfmt::skip]
393393 fn preimage(&self) -> Option<PaymentPreimage> {
394394 match self {
395- OutboundHTLCState::RemoteRemoved(OutboundHTLCOutcome::Success( preimage, _) )
396- | OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success( preimage, _) )
397- | OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success( preimage, _) ) => {
395+ OutboundHTLCState::RemoteRemoved(OutboundHTLCOutcome::Success{ preimage, ..} )
396+ | OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success{ preimage, ..} )
397+ | OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success{ preimage, ..} ) => {
398398 Some(*preimage)
399399 },
400400 _ => None,
@@ -407,14 +407,17 @@ impl OutboundHTLCState {
407407enum OutboundHTLCOutcome {
408408 /// We started always filling in the preimages here in 0.0.105, and the requirement
409409 /// that the preimages always be filled in was added in 0.2.
410- Success(PaymentPreimage, Option<AttributionData>),
410+ Success {
411+ preimage: PaymentPreimage,
412+ attribution_data: Option<AttributionData>,
413+ },
411414 Failure(HTLCFailReason),
412415}
413416
414417impl<'a> Into<Option<&'a HTLCFailReason>> for &'a OutboundHTLCOutcome {
415418 fn into(self) -> Option<&'a HTLCFailReason> {
416419 match self {
417- OutboundHTLCOutcome::Success(_, _) => None,
420+ OutboundHTLCOutcome::Success { .. } => None,
418421 OutboundHTLCOutcome::Failure(ref r) => Some(r),
419422 }
420423 }
@@ -4604,10 +4607,10 @@ where
46044607 .pending_outbound_htlcs
46054608 .iter()
46064609 .filter(|OutboundHTLCOutput { state, .. }| match (state, local) {
4607- (OutboundHTLCState::RemoteRemoved(Success(_, _) ), true) => true,
4608- (OutboundHTLCState::RemoteRemoved(Success(_, _) ), false) => false,
4609- (OutboundHTLCState::AwaitingRemoteRevokeToRemove(Success(_, _) ), _) => true,
4610- (OutboundHTLCState::AwaitingRemovedRemoteRevoke(Success(_, _) ), _) => true,
4610+ (OutboundHTLCState::RemoteRemoved(Success { .. } ), true) => true,
4611+ (OutboundHTLCState::RemoteRemoved(Success { .. } ), false) => false,
4612+ (OutboundHTLCState::AwaitingRemoteRevokeToRemove(Success { .. } ), _) => true,
4613+ (OutboundHTLCState::AwaitingRemovedRemoteRevoke(Success { .. } ), _) => true,
46114614 _ => false,
46124615 })
46134616 .map(|OutboundHTLCOutput { amount_msat, .. }| amount_msat)
@@ -7766,8 +7769,8 @@ where
77667769 fn mark_outbound_htlc_removed(&mut self, htlc_id: u64, outcome: OutboundHTLCOutcome) -> Result<&OutboundHTLCOutput, ChannelError> {
77677770 for htlc in self.context.pending_outbound_htlcs.iter_mut() {
77687771 if htlc.htlc_id == htlc_id {
7769- if let OutboundHTLCOutcome::Success( ref payment_preimage , ..) = outcome {
7770- let payment_hash = PaymentHash(Sha256::hash(&payment_preimage .0[..]).to_byte_array());
7772+ if let OutboundHTLCOutcome::Success { ref preimage , .. } = outcome {
7773+ let payment_hash = PaymentHash(Sha256::hash(&preimage .0[..]).to_byte_array());
77717774 if payment_hash != htlc.payment_hash {
77727775 return Err(ChannelError::close(format!("Remote tried to fulfill HTLC ({}) with an incorrect preimage", htlc_id)));
77737776 }
@@ -7808,8 +7811,10 @@ where
78087811 ));
78097812 }
78107813
7811- let outcome =
7812- OutboundHTLCOutcome::Success(msg.payment_preimage, msg.attribution_data.clone());
7814+ let outcome = OutboundHTLCOutcome::Success {
7815+ preimage: msg.payment_preimage,
7816+ attribution_data: msg.attribution_data.clone(),
7817+ };
78137818 self.mark_outbound_htlc_removed(msg.htlc_id, outcome).map(|htlc| {
78147819 (htlc.source.clone(), htlc.amount_msat, htlc.skimmed_fee_msat, htlc.send_timestamp)
78157820 })
@@ -8197,9 +8202,12 @@ where
81978202 log_trace!(logger, "Updating HTLC {} to AwaitingRemoteRevokeToRemove due to commitment_signed in channel {}.",
81988203 &htlc.payment_hash, &self.context.channel_id);
81998204 // Swap against a dummy variant to avoid a potentially expensive clone of `OutboundHTLCOutcome::Failure(HTLCFailReason)`
8200- let mut reason = OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]), None);
8205+ let mut reason = OutboundHTLCOutcome::Success {
8206+ preimage: PaymentPreimage([0u8; 32]),
8207+ attribution_data: None,
8208+ };
82018209 mem::swap(outcome, &mut reason);
8202- if let OutboundHTLCOutcome::Success( preimage, _) = reason {
8210+ if let OutboundHTLCOutcome::Success { preimage, .. } = reason {
82038211 // If a user (a) receives an HTLC claim using LDK 0.0.104 or before, then (b)
82048212 // upgrades to LDK 0.0.114 or later before the HTLC is fully resolved, we could
82058213 // have a `Success(None)` reason. In this case we could forget some HTLC
@@ -8672,7 +8680,7 @@ where
86728680 });
86738681 revoked_htlcs.push((htlc.source.clone(), htlc.payment_hash, reason));
86748682 },
8675- OutboundHTLCOutcome::Success(_, attribution_data) => {
8683+ OutboundHTLCOutcome::Success { attribution_data, .. } => {
86768684 // Even though a fast track was taken for fulfilled HTLCs to the incoming side, we still
86778685 // pass along attribution data here so that we can include hold time information in the
86788686 // final PaymentPathSuccessful events.
@@ -8781,7 +8789,10 @@ where
87818789 {
87828790 log_trace!(logger, " ...promoting outbound AwaitingRemoteRevokeToRemove {} to AwaitingRemovedRemoteRevoke", &htlc.payment_hash);
87838791 // Swap against a dummy variant to avoid a potentially expensive clone of `OutboundHTLCOutcome::Failure(HTLCFailReason)`
8784- let mut reason = OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]), None);
8792+ let mut reason = OutboundHTLCOutcome::Success {
8793+ preimage: PaymentPreimage([0u8; 32]),
8794+ attribution_data: None,
8795+ };
87858796 mem::swap(outcome, &mut reason);
87868797 htlc.state = OutboundHTLCState::AwaitingRemovedRemoteRevoke(reason);
87878798 require_commitment = true;
@@ -12720,7 +12731,7 @@ where
1272012731 if let &mut OutboundHTLCState::AwaitingRemoteRevokeToRemove(ref mut outcome) = &mut htlc.state {
1272112732 log_trace!(logger, " ...promoting outbound AwaitingRemoteRevokeToRemove {} to AwaitingRemovedRemoteRevoke", &htlc.payment_hash);
1272212733 // Swap against a dummy variant to avoid a potentially expensive clone of `OutboundHTLCOutcome::Failure(HTLCFailReason)`
12723- let mut reason = OutboundHTLCOutcome::Success( PaymentPreimage([0u8; 32]), None) ;
12734+ let mut reason = OutboundHTLCOutcome::Success { preimage: PaymentPreimage([0u8; 32]), attribution_data: None } ;
1272412735 mem::swap(outcome, &mut reason);
1272512736 htlc.state = OutboundHTLCState::AwaitingRemovedRemoteRevoke(reason);
1272612737 }
@@ -14552,7 +14563,7 @@ where
1455214563 },
1455314564 &OutboundHTLCState::AwaitingRemoteRevokeToRemove(ref outcome) => {
1455414565 3u8.write(writer)?;
14555- if let OutboundHTLCOutcome::Success( preimage, attribution_data) = outcome {
14566+ if let OutboundHTLCOutcome::Success { preimage, attribution_data } = outcome {
1455614567 preimages.push(Some(preimage));
1455714568 fulfill_attribution_data.push(attribution_data);
1455814569 }
@@ -14561,7 +14572,7 @@ where
1456114572 },
1456214573 &OutboundHTLCState::AwaitingRemovedRemoteRevoke(ref outcome) => {
1456314574 4u8.write(writer)?;
14564- if let OutboundHTLCOutcome::Success( preimage, attribution_data) = outcome {
14575+ if let OutboundHTLCOutcome::Success { preimage, attribution_data } = outcome {
1456514576 preimages.push(Some(preimage));
1456614577 fulfill_attribution_data.push(attribution_data);
1456714578 }
@@ -14998,7 +15009,10 @@ where
1499815009 let outcome = match option {
1499915010 Some(r) => OutboundHTLCOutcome::Failure(r),
1500015011 // Initialize this variant with a dummy preimage, the actual preimage will be filled in further down
15001- None => OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]), None),
15012+ None => OutboundHTLCOutcome::Success {
15013+ preimage: PaymentPreimage([0u8; 32]),
15014+ attribution_data: None,
15015+ },
1500215016 };
1500315017 OutboundHTLCState::RemoteRemoved(outcome)
1500415018 },
@@ -15007,7 +15021,10 @@ where
1500715021 let outcome = match option {
1500815022 Some(r) => OutboundHTLCOutcome::Failure(r),
1500915023 // Initialize this variant with a dummy preimage, the actual preimage will be filled in further down
15010- None => OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]), None),
15024+ None => OutboundHTLCOutcome::Success {
15025+ preimage: PaymentPreimage([0u8; 32]),
15026+ attribution_data: None,
15027+ },
1501115028 };
1501215029 OutboundHTLCState::AwaitingRemoteRevokeToRemove(outcome)
1501315030 },
@@ -15016,7 +15033,10 @@ where
1501615033 let outcome = match option {
1501715034 Some(r) => OutboundHTLCOutcome::Failure(r),
1501815035 // Initialize this variant with a dummy preimage, the actual preimage will be filled in further down
15019- None => OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]), None),
15036+ None => OutboundHTLCOutcome::Success {
15037+ preimage: PaymentPreimage([0u8; 32]),
15038+ attribution_data: None,
15039+ },
1502015040 };
1502115041 OutboundHTLCState::AwaitingRemovedRemoteRevoke(outcome)
1502215042 },
@@ -15303,14 +15323,14 @@ where
1530315323 let mut fulfill_attribution_data_iter = fulfill_attribution_data.map(Vec::into_iter);
1530415324 for htlc in pending_outbound_htlcs.iter_mut() {
1530515325 match &mut htlc.state {
15306- OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(
15326+ OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success {
1530715327 ref mut preimage,
1530815328 ref mut attribution_data,
15309- ) )
15310- | OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(
15329+ } )
15330+ | OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success {
1531115331 ref mut preimage,
1531215332 ref mut attribution_data,
15313- ) ) => {
15333+ } ) => {
1531415334 // This variant was initialized like this further above
1531515335 debug_assert_eq!(preimage, &PaymentPreimage([0u8; 32]));
1531615336 // Flatten and unwrap the preimage; they are always set starting in 0.2.
0 commit comments