@@ -141,8 +141,8 @@ enum FeeUpdateState {
141141#[derive(Debug)]
142142enum InboundHTLCRemovalReason {
143143 FailRelay(msgs::OnionErrorPacket),
144- FailMalformed(( [u8; 32], u16)) ,
145- Fulfill( PaymentPreimage, Option<AttributionData>) ,
144+ FailMalformed { hash: [u8; 32], code: u16 } ,
145+ Fulfill { preimage: PaymentPreimage, attribution_data: Option<AttributionData> } ,
146146}
147147
148148/// Represents the resolution status of an inbound HTLC.
@@ -238,9 +238,9 @@ impl From<&InboundHTLCState> for Option<InboundHTLCStateDetails> {
238238 Some(InboundHTLCStateDetails::Committed),
239239 InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailRelay(_)) =>
240240 Some(InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail),
241- InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailMalformed(_) ) =>
241+ InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailMalformed{..} ) =>
242242 Some(InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail),
243- InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill(_, _) ) =>
243+ InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill{..} ) =>
244244 Some(InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill),
245245 }
246246 }
@@ -272,9 +272,9 @@ impl InboundHTLCState {
272272
273273 fn preimage(&self) -> Option<PaymentPreimage> {
274274 match self {
275- InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill(preimage, _)) => {
276- Some(* preimage)
277- },
275+ InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill {
276+ preimage, ..
277+ }) => Some(*preimage) ,
278278 _ => None,
279279 }
280280 }
@@ -4594,8 +4594,8 @@ where
45944594 .pending_inbound_htlcs
45954595 .iter()
45964596 .filter(|InboundHTLCOutput { state, .. }| match (state, local) {
4597- (InboundHTLCState::LocalRemoved(Fulfill(_, _) ), true) => false,
4598- (InboundHTLCState::LocalRemoved(Fulfill(_, _) ), false) => true,
4597+ (InboundHTLCState::LocalRemoved(Fulfill { .. } ), true) => false,
4598+ (InboundHTLCState::LocalRemoved(Fulfill { .. } ), false) => true,
45994599 _ => false,
46004600 })
46014601 .map(|InboundHTLCOutput { amount_msat, .. }| amount_msat)
@@ -6811,7 +6811,10 @@ impl FailHTLCContents for ([u8; 32], u16) {
68116811 }
68126812 }
68136813 fn to_inbound_htlc_state(self) -> InboundHTLCState {
6814- InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailMalformed(self))
6814+ InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailMalformed {
6815+ hash: self.0,
6816+ code: self.1,
6817+ })
68156818 }
68166819 fn to_htlc_update_awaiting_ack(self, htlc_id: u64) -> HTLCUpdateAwaitingACK {
68176820 HTLCUpdateAwaitingACK::FailMalformedHTLC {
@@ -7310,7 +7313,7 @@ where
73107313 match htlc.state {
73117314 InboundHTLCState::Committed => {},
73127315 InboundHTLCState::LocalRemoved(ref reason) => {
7313- if let &InboundHTLCRemovalReason::Fulfill(_, _) = reason {
7316+ if let &InboundHTLCRemovalReason::Fulfill { .. } = reason {
73147317 } else {
73157318 log_warn!(logger, "Have preimage and want to fulfill HTLC with payment hash {} we already failed against channel {}", &htlc.payment_hash, &self.context.channel_id());
73167319 debug_assert!(
@@ -7420,10 +7423,10 @@ where
74207423 "Upgrading HTLC {} to LocalRemoved with a Fulfill!",
74217424 &htlc.payment_hash,
74227425 );
7423- htlc.state = InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill(
7424- payment_preimage_arg.clone(),
7426+ htlc.state = InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill {
7427+ preimage: payment_preimage_arg.clone(),
74257428 attribution_data,
7426- ) );
7429+ } );
74277430 }
74287431
74297432 UpdateFulfillFetch::NewClaim { monitor_update, htlc_value_msat, update_blocked: false }
@@ -8684,7 +8687,7 @@ where
86848687 pending_inbound_htlcs.retain(|htlc| {
86858688 if let &InboundHTLCState::LocalRemoved(ref reason) = &htlc.state {
86868689 log_trace!(logger, " ...removing inbound LocalRemoved {}", &htlc.payment_hash);
8687- if let &InboundHTLCRemovalReason::Fulfill(_, _) = reason {
8690+ if let &InboundHTLCRemovalReason::Fulfill { .. } = reason {
86888691 value_to_self_msat_diff += htlc.amount_msat as i64;
86898692 }
86908693 *expecting_peer_commitment_signed = true;
@@ -8759,10 +8762,10 @@ where
87598762 },
87608763 HTLCFailureMsg::Malformed(msg) => {
87618764 htlc.state = InboundHTLCState::LocalRemoved(
8762- InboundHTLCRemovalReason::FailMalformed((
8763- msg.sha256_of_onion,
8764- msg.failure_code,
8765- )) ,
8765+ InboundHTLCRemovalReason::FailMalformed {
8766+ hash: msg.sha256_of_onion,
8767+ code: msg.failure_code,
8768+ } ,
87668769 );
87678770 update_fail_malformed_htlcs.push(msg)
87688771 },
@@ -9751,25 +9754,19 @@ where
97519754 attribution_data: err_packet.attribution_data.clone(),
97529755 });
97539756 },
9754- &InboundHTLCRemovalReason::FailMalformed((
9755- ref sha256_of_onion,
9756- ref failure_code,
9757- )) => {
9757+ &InboundHTLCRemovalReason::FailMalformed { ref hash, ref code } => {
97589758 update_fail_malformed_htlcs.push(msgs::UpdateFailMalformedHTLC {
97599759 channel_id: self.context.channel_id(),
97609760 htlc_id: htlc.htlc_id,
9761- sha256_of_onion: sha256_of_onion .clone(),
9762- failure_code: failure_code .clone(),
9761+ sha256_of_onion: hash .clone(),
9762+ failure_code: code .clone(),
97639763 });
97649764 },
9765- &InboundHTLCRemovalReason::Fulfill(
9766- ref payment_preimage,
9767- ref attribution_data,
9768- ) => {
9765+ &InboundHTLCRemovalReason::Fulfill { ref preimage, ref attribution_data } => {
97699766 update_fulfill_htlcs.push(msgs::UpdateFulfillHTLC {
97709767 channel_id: self.context.channel_id(),
97719768 htlc_id: htlc.htlc_id,
9772- payment_preimage: payment_preimage .clone(),
9769+ payment_preimage: preimage .clone(),
97739770 attribution_data: attribution_data.clone(),
97749771 });
97759772 },
@@ -14559,11 +14556,11 @@ where
1455914556 data.write(writer)?;
1456014557 removed_htlc_attribution_data.push(&attribution_data);
1456114558 },
14562- InboundHTLCRemovalReason::FailMalformed(( hash, code)) => {
14559+ InboundHTLCRemovalReason::FailMalformed { hash, code } => {
1456314560 1u8.write(writer)?;
1456414561 (hash, code).write(writer)?;
1456514562 },
14566- InboundHTLCRemovalReason::Fulfill( preimage, attribution_data) => {
14563+ InboundHTLCRemovalReason::Fulfill { preimage, attribution_data } => {
1456714564 2u8.write(writer)?;
1456814565 preimage.write(writer)?;
1456914566 removed_htlc_attribution_data.push(&attribution_data);
@@ -15009,8 +15006,14 @@ where
1500915006 data: Readable::read(reader)?,
1501015007 attribution_data: None,
1501115008 }),
15012- 1 => InboundHTLCRemovalReason::FailMalformed(Readable::read(reader)?),
15013- 2 => InboundHTLCRemovalReason::Fulfill(Readable::read(reader)?, None),
15009+ 1 => {
15010+ let (hash, code) = Readable::read(reader)?;
15011+ InboundHTLCRemovalReason::FailMalformed { hash, code }
15012+ },
15013+ 2 => InboundHTLCRemovalReason::Fulfill {
15014+ preimage: Readable::read(reader)?,
15015+ attribution_data: None,
15016+ },
1501415017 _ => return Err(DecodeError::InvalidValue),
1501515018 };
1501615019 InboundHTLCState::LocalRemoved(reason)
@@ -15468,7 +15471,7 @@ where
1546815471 InboundHTLCRemovalReason::FailRelay(ref mut packet) => {
1546915472 Some(&mut packet.attribution_data)
1547015473 },
15471- InboundHTLCRemovalReason::Fulfill(_, ref mut attribution_data) => {
15474+ InboundHTLCRemovalReason::Fulfill { ref mut attribution_data, .. } => {
1547215475 Some(attribution_data)
1547315476 },
1547415477 _ => None,
0 commit comments