@@ -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 }
@@ -4579,10 +4582,10 @@ where
45794582 .pending_outbound_htlcs
45804583 .iter()
45814584 .filter(|OutboundHTLCOutput { state, .. }| match (state, local) {
4582- (OutboundHTLCState::RemoteRemoved(Success(_, _) ), true) => true,
4583- (OutboundHTLCState::RemoteRemoved(Success(_, _) ), false) => false,
4584- (OutboundHTLCState::AwaitingRemoteRevokeToRemove(Success(_, _) ), _) => true,
4585- (OutboundHTLCState::AwaitingRemovedRemoteRevoke(Success(_, _) ), _) => true,
4585+ (OutboundHTLCState::RemoteRemoved(Success { .. } ), true) => true,
4586+ (OutboundHTLCState::RemoteRemoved(Success { .. } ), false) => false,
4587+ (OutboundHTLCState::AwaitingRemoteRevokeToRemove(Success { .. } ), _) => true,
4588+ (OutboundHTLCState::AwaitingRemovedRemoteRevoke(Success { .. } ), _) => true,
45864589 _ => false,
45874590 })
45884591 .map(|OutboundHTLCOutput { amount_msat, .. }| amount_msat)
@@ -7746,8 +7749,8 @@ where
77467749 fn mark_outbound_htlc_removed(&mut self, htlc_id: u64, outcome: OutboundHTLCOutcome) -> Result<&OutboundHTLCOutput, ChannelError> {
77477750 for htlc in self.context.pending_outbound_htlcs.iter_mut() {
77487751 if htlc.htlc_id == htlc_id {
7749- if let OutboundHTLCOutcome::Success( ref payment_preimage , ..) = outcome {
7750- let payment_hash = PaymentHash(Sha256::hash(&payment_preimage .0[..]).to_byte_array());
7752+ if let OutboundHTLCOutcome::Success { ref preimage , .. } = outcome {
7753+ let payment_hash = PaymentHash(Sha256::hash(&preimage .0[..]).to_byte_array());
77517754 if payment_hash != htlc.payment_hash {
77527755 return Err(ChannelError::close(format!("Remote tried to fulfill HTLC ({}) with an incorrect preimage", htlc_id)));
77537756 }
@@ -7788,8 +7791,10 @@ where
77887791 ));
77897792 }
77907793
7791- let outcome =
7792- OutboundHTLCOutcome::Success(msg.payment_preimage, msg.attribution_data.clone());
7794+ let outcome = OutboundHTLCOutcome::Success {
7795+ preimage: msg.payment_preimage,
7796+ attribution_data: msg.attribution_data.clone(),
7797+ };
77937798 self.mark_outbound_htlc_removed(msg.htlc_id, outcome).map(|htlc| {
77947799 (htlc.source.clone(), htlc.amount_msat, htlc.skimmed_fee_msat, htlc.send_timestamp)
77957800 })
@@ -8184,9 +8189,12 @@ where
81848189 log_trace!(logger, "Updating HTLC {} to AwaitingRemoteRevokeToRemove due to commitment_signed in channel {}.",
81858190 &htlc.payment_hash, &self.context.channel_id);
81868191 // Swap against a dummy variant to avoid a potentially expensive clone of `OutboundHTLCOutcome::Failure(HTLCFailReason)`
8187- let mut reason = OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]), None);
8192+ let mut reason = OutboundHTLCOutcome::Success {
8193+ preimage: PaymentPreimage([0u8; 32]),
8194+ attribution_data: None,
8195+ };
81888196 mem::swap(outcome, &mut reason);
8189- if let OutboundHTLCOutcome::Success( preimage, _) = reason {
8197+ if let OutboundHTLCOutcome::Success { preimage, .. } = reason {
81908198 // If a user (a) receives an HTLC claim using LDK 0.0.104 or before, then (b)
81918199 // upgrades to LDK 0.0.114 or later before the HTLC is fully resolved, we could
81928200 // have a `Success(None)` reason. In this case we could forget some HTLC
@@ -8683,7 +8691,7 @@ where
86838691 });
86848692 revoked_htlcs.push((htlc.source.clone(), htlc.payment_hash, reason));
86858693 },
8686- OutboundHTLCOutcome::Success(_, attribution_data) => {
8694+ OutboundHTLCOutcome::Success { attribution_data, .. } => {
86878695 // Even though a fast track was taken for fulfilled HTLCs to the incoming side, we still
86888696 // pass along attribution data here so that we can include hold time information in the
86898697 // final PaymentPathSuccessful events.
@@ -8792,7 +8800,10 @@ where
87928800 {
87938801 log_trace!(logger, " ...promoting outbound AwaitingRemoteRevokeToRemove {} to AwaitingRemovedRemoteRevoke", &htlc.payment_hash);
87948802 // Swap against a dummy variant to avoid a potentially expensive clone of `OutboundHTLCOutcome::Failure(HTLCFailReason)`
8795- let mut reason = OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]), None);
8803+ let mut reason = OutboundHTLCOutcome::Success {
8804+ preimage: PaymentPreimage([0u8; 32]),
8805+ attribution_data: None,
8806+ };
87968807 mem::swap(outcome, &mut reason);
87978808 htlc.state = OutboundHTLCState::AwaitingRemovedRemoteRevoke(reason);
87988809 require_commitment = true;
@@ -12701,7 +12712,7 @@ where
1270112712 if let &mut OutboundHTLCState::AwaitingRemoteRevokeToRemove(ref mut outcome) = &mut htlc.state {
1270212713 log_trace!(logger, " ...promoting outbound AwaitingRemoteRevokeToRemove {} to AwaitingRemovedRemoteRevoke", &htlc.payment_hash);
1270312714 // Swap against a dummy variant to avoid a potentially expensive clone of `OutboundHTLCOutcome::Failure(HTLCFailReason)`
12704- let mut reason = OutboundHTLCOutcome::Success( PaymentPreimage([0u8; 32]), None) ;
12715+ let mut reason = OutboundHTLCOutcome::Success { preimage: PaymentPreimage([0u8; 32]), attribution_data: None } ;
1270512716 mem::swap(outcome, &mut reason);
1270612717 htlc.state = OutboundHTLCState::AwaitingRemovedRemoteRevoke(reason);
1270712718 }
@@ -14534,7 +14545,7 @@ where
1453414545 },
1453514546 &OutboundHTLCState::AwaitingRemoteRevokeToRemove(ref outcome) => {
1453614547 3u8.write(writer)?;
14537- if let OutboundHTLCOutcome::Success( preimage, attribution_data) = outcome {
14548+ if let OutboundHTLCOutcome::Success { preimage, attribution_data } = outcome {
1453814549 preimages.push(Some(preimage));
1453914550 fulfill_attribution_data.push(attribution_data);
1454014551 }
@@ -14543,7 +14554,7 @@ where
1454314554 },
1454414555 &OutboundHTLCState::AwaitingRemovedRemoteRevoke(ref outcome) => {
1454514556 4u8.write(writer)?;
14546- if let OutboundHTLCOutcome::Success( preimage, attribution_data) = outcome {
14557+ if let OutboundHTLCOutcome::Success { preimage, attribution_data } = outcome {
1454714558 preimages.push(Some(preimage));
1454814559 fulfill_attribution_data.push(attribution_data);
1454914560 }
@@ -14971,7 +14982,10 @@ where
1497114982 let outcome = match option {
1497214983 Some(r) => OutboundHTLCOutcome::Failure(r),
1497314984 // Initialize this variant with a dummy preimage, the actual preimage will be filled in further down
14974- None => OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]), None),
14985+ None => OutboundHTLCOutcome::Success {
14986+ preimage: PaymentPreimage([0u8; 32]),
14987+ attribution_data: None,
14988+ },
1497514989 };
1497614990 OutboundHTLCState::RemoteRemoved(outcome)
1497714991 },
@@ -14980,7 +14994,10 @@ where
1498014994 let outcome = match option {
1498114995 Some(r) => OutboundHTLCOutcome::Failure(r),
1498214996 // Initialize this variant with a dummy preimage, the actual preimage will be filled in further down
14983- None => OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]), None),
14997+ None => OutboundHTLCOutcome::Success {
14998+ preimage: PaymentPreimage([0u8; 32]),
14999+ attribution_data: None,
15000+ },
1498415001 };
1498515002 OutboundHTLCState::AwaitingRemoteRevokeToRemove(outcome)
1498615003 },
@@ -14989,7 +15006,10 @@ where
1498915006 let outcome = match option {
1499015007 Some(r) => OutboundHTLCOutcome::Failure(r),
1499115008 // Initialize this variant with a dummy preimage, the actual preimage will be filled in further down
14992- None => OutboundHTLCOutcome::Success(PaymentPreimage([0u8; 32]), None),
15009+ None => OutboundHTLCOutcome::Success {
15010+ preimage: PaymentPreimage([0u8; 32]),
15011+ attribution_data: None,
15012+ },
1499315013 };
1499415014 OutboundHTLCState::AwaitingRemovedRemoteRevoke(outcome)
1499515015 },
@@ -15272,14 +15292,14 @@ where
1527215292 let mut fulfill_attribution_data_iter = fulfill_attribution_data.map(Vec::into_iter);
1527315293 for htlc in pending_outbound_htlcs.iter_mut() {
1527415294 match &mut htlc.state {
15275- OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(
15295+ OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success {
1527615296 ref mut preimage,
1527715297 ref mut attribution_data,
15278- ) )
15279- | OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(
15298+ } )
15299+ | OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success {
1528015300 ref mut preimage,
1528115301 ref mut attribution_data,
15282- ) ) => {
15302+ } ) => {
1528315303 // This variant was initialized like this further above
1528415304 debug_assert_eq!(preimage, &PaymentPreimage([0u8; 32]));
1528515305 // Flatten and unwrap the preimage; they are always set starting in 0.2.
0 commit comments