@@ -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)
@@ -6809,7 +6809,10 @@ impl FailHTLCContents for ([u8; 32], u16) {
68096809 }
68106810 }
68116811 fn to_inbound_htlc_state(self) -> InboundHTLCState {
6812- InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailMalformed(self))
6812+ InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailMalformed {
6813+ hash: self.0,
6814+ code: self.1,
6815+ })
68136816 }
68146817 fn to_htlc_update_awaiting_ack(self, htlc_id: u64) -> HTLCUpdateAwaitingACK {
68156818 HTLCUpdateAwaitingACK::FailMalformedHTLC {
@@ -7308,7 +7311,7 @@ where
73087311 match htlc.state {
73097312 InboundHTLCState::Committed => {},
73107313 InboundHTLCState::LocalRemoved(ref reason) => {
7311- if let &InboundHTLCRemovalReason::Fulfill(_, _) = reason {
7314+ if let &InboundHTLCRemovalReason::Fulfill { .. } = reason {
73127315 } else {
73137316 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());
73147317 debug_assert!(
@@ -7416,10 +7419,10 @@ where
74167419 "Upgrading HTLC {} to LocalRemoved with a Fulfill!",
74177420 &htlc.payment_hash,
74187421 );
7419- htlc.state = InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill(
7420- payment_preimage_arg.clone(),
7422+ htlc.state = InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill {
7423+ preimage: payment_preimage_arg.clone(),
74217424 attribution_data,
7422- ) );
7425+ } );
74237426 }
74247427
74257428 UpdateFulfillFetch::NewClaim { monitor_update, htlc_value_msat, update_blocked: false }
@@ -8645,7 +8648,7 @@ where
86458648 pending_inbound_htlcs.retain(|htlc| {
86468649 if let &InboundHTLCState::LocalRemoved(ref reason) = &htlc.state {
86478650 log_trace!(logger, " ...removing inbound LocalRemoved {}", &htlc.payment_hash);
8648- if let &InboundHTLCRemovalReason::Fulfill(_, _) = reason {
8651+ if let &InboundHTLCRemovalReason::Fulfill { .. } = reason {
86498652 value_to_self_msat_diff += htlc.amount_msat as i64;
86508653 }
86518654 *expecting_peer_commitment_signed = true;
@@ -8720,10 +8723,10 @@ where
87208723 },
87218724 HTLCFailureMsg::Malformed(msg) => {
87228725 htlc.state = InboundHTLCState::LocalRemoved(
8723- InboundHTLCRemovalReason::FailMalformed((
8724- msg.sha256_of_onion,
8725- msg.failure_code,
8726- )) ,
8726+ InboundHTLCRemovalReason::FailMalformed {
8727+ hash: msg.sha256_of_onion,
8728+ code: msg.failure_code,
8729+ } ,
87278730 );
87288731 update_fail_malformed_htlcs.push(msg)
87298732 },
@@ -9708,25 +9711,19 @@ where
97089711 attribution_data: err_packet.attribution_data.clone(),
97099712 });
97109713 },
9711- &InboundHTLCRemovalReason::FailMalformed((
9712- ref sha256_of_onion,
9713- ref failure_code,
9714- )) => {
9714+ &InboundHTLCRemovalReason::FailMalformed { ref hash, ref code } => {
97159715 update_fail_malformed_htlcs.push(msgs::UpdateFailMalformedHTLC {
97169716 channel_id: self.context.channel_id(),
97179717 htlc_id: htlc.htlc_id,
9718- sha256_of_onion: sha256_of_onion .clone(),
9719- failure_code: failure_code .clone(),
9718+ sha256_of_onion: hash .clone(),
9719+ failure_code: code .clone(),
97209720 });
97219721 },
9722- &InboundHTLCRemovalReason::Fulfill(
9723- ref payment_preimage,
9724- ref attribution_data,
9725- ) => {
9722+ &InboundHTLCRemovalReason::Fulfill { ref preimage, ref attribution_data } => {
97269723 update_fulfill_htlcs.push(msgs::UpdateFulfillHTLC {
97279724 channel_id: self.context.channel_id(),
97289725 htlc_id: htlc.htlc_id,
9729- payment_preimage: payment_preimage .clone(),
9726+ payment_preimage: preimage .clone(),
97309727 attribution_data: attribution_data.clone(),
97319728 });
97329729 },
@@ -14505,11 +14502,11 @@ where
1450514502 data.write(writer)?;
1450614503 removed_htlc_attribution_data.push(&attribution_data);
1450714504 },
14508- InboundHTLCRemovalReason::FailMalformed(( hash, code)) => {
14505+ InboundHTLCRemovalReason::FailMalformed { hash, code } => {
1450914506 1u8.write(writer)?;
1451014507 (hash, code).write(writer)?;
1451114508 },
14512- InboundHTLCRemovalReason::Fulfill( preimage, attribution_data) => {
14509+ InboundHTLCRemovalReason::Fulfill { preimage, attribution_data } => {
1451314510 2u8.write(writer)?;
1451414511 preimage.write(writer)?;
1451514512 removed_htlc_attribution_data.push(&attribution_data);
@@ -14955,8 +14952,14 @@ where
1495514952 data: Readable::read(reader)?,
1495614953 attribution_data: None,
1495714954 }),
14958- 1 => InboundHTLCRemovalReason::FailMalformed(Readable::read(reader)?),
14959- 2 => InboundHTLCRemovalReason::Fulfill(Readable::read(reader)?, None),
14955+ 1 => {
14956+ let (hash, code) = Readable::read(reader)?;
14957+ InboundHTLCRemovalReason::FailMalformed { hash, code }
14958+ },
14959+ 2 => InboundHTLCRemovalReason::Fulfill {
14960+ preimage: Readable::read(reader)?,
14961+ attribution_data: None,
14962+ },
1496014963 _ => return Err(DecodeError::InvalidValue),
1496114964 };
1496214965 InboundHTLCState::LocalRemoved(reason)
@@ -15414,7 +15417,7 @@ where
1541415417 InboundHTLCRemovalReason::FailRelay(ref mut packet) => {
1541515418 Some(&mut packet.attribution_data)
1541615419 },
15417- InboundHTLCRemovalReason::Fulfill(_, ref mut attribution_data) => {
15420+ InboundHTLCRemovalReason::Fulfill { ref mut attribution_data, .. } => {
1541815421 Some(attribution_data)
1541915422 },
1542015423 _ => None,
0 commit comments