@@ -138,7 +138,7 @@ enum FeeUpdateState {
138138enum InboundHTLCRemovalReason {
139139 FailRelay(msgs::OnionErrorPacket),
140140 FailMalformed(([u8; 32], u16)),
141- Fulfill(PaymentPreimage),
141+ Fulfill(PaymentPreimage, Option<AttributionData> ),
142142}
143143
144144/// Represents the resolution status of an inbound HTLC.
@@ -234,7 +234,7 @@ impl From<&InboundHTLCState> for Option<InboundHTLCStateDetails> {
234234 Some(InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail),
235235 InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailMalformed(_)) =>
236236 Some(InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail),
237- InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill(_)) =>
237+ InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill(_, _ )) =>
238238 Some(InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill),
239239 }
240240 }
@@ -266,7 +266,7 @@ impl InboundHTLCState {
266266
267267 fn preimage(&self) -> Option<PaymentPreimage> {
268268 match self {
269- InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill(preimage)) => {
269+ InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill(preimage, _ )) => {
270270 Some(*preimage)
271271 },
272272 _ => None,
@@ -6258,7 +6258,7 @@ where
62586258 match htlc.state {
62596259 InboundHTLCState::Committed => {},
62606260 InboundHTLCState::LocalRemoved(ref reason) => {
6261- if let &InboundHTLCRemovalReason::Fulfill(_) = reason {
6261+ if let &InboundHTLCRemovalReason::Fulfill(_, _ ) = reason {
62626262 } else {
62636263 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());
62646264 debug_assert!(
@@ -6369,6 +6369,7 @@ where
63696369 );
63706370 htlc.state = InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill(
63716371 payment_preimage_arg.clone(),
6372+ None,
63726373 ));
63736374 }
63746375
@@ -7507,7 +7508,7 @@ where
75077508 pending_inbound_htlcs.retain(|htlc| {
75087509 if let &InboundHTLCState::LocalRemoved(ref reason) = &htlc.state {
75097510 log_trace!(logger, " ...removing inbound LocalRemoved {}", &htlc.payment_hash);
7510- if let &InboundHTLCRemovalReason::Fulfill(_) = reason {
7511+ if let &InboundHTLCRemovalReason::Fulfill(_, _ ) = reason {
75117512 value_to_self_msat_diff += htlc.amount_msat as i64;
75127513 }
75137514 *expecting_peer_commitment_signed = true;
@@ -8383,12 +8384,15 @@ where
83838384 failure_code: failure_code.clone(),
83848385 });
83858386 },
8386- &InboundHTLCRemovalReason::Fulfill(ref payment_preimage) => {
8387+ &InboundHTLCRemovalReason::Fulfill(
8388+ ref payment_preimage,
8389+ ref attribution_data,
8390+ ) => {
83878391 update_fulfill_htlcs.push(msgs::UpdateFulfillHTLC {
83888392 channel_id: self.context.channel_id(),
83898393 htlc_id: htlc.htlc_id,
83908394 payment_preimage: payment_preimage.clone(),
8391- attribution_data: None ,
8395+ attribution_data: attribution_data.clone() ,
83928396 });
83938397 },
83948398 }
@@ -12460,7 +12464,7 @@ where
1246012464 dropped_inbound_htlcs += 1;
1246112465 }
1246212466 }
12463- let mut removed_htlc_failure_attribution_data : Vec<&Option<AttributionData>> = Vec::new();
12467+ let mut removed_htlc_attribution_data : Vec<&Option<AttributionData>> = Vec::new();
1246412468 (self.context.pending_inbound_htlcs.len() as u64 - dropped_inbound_htlcs).write(writer)?;
1246512469 for htlc in self.context.pending_inbound_htlcs.iter() {
1246612470 if let &InboundHTLCState::RemoteAnnounced(_) = &htlc.state {
@@ -12492,15 +12496,16 @@ where
1249212496 }) => {
1249312497 0u8.write(writer)?;
1249412498 data.write(writer)?;
12495- removed_htlc_failure_attribution_data .push(&attribution_data);
12499+ removed_htlc_attribution_data .push(&attribution_data);
1249612500 },
1249712501 InboundHTLCRemovalReason::FailMalformed((hash, code)) => {
1249812502 1u8.write(writer)?;
1249912503 (hash, code).write(writer)?;
1250012504 },
12501- InboundHTLCRemovalReason::Fulfill(preimage) => {
12505+ InboundHTLCRemovalReason::Fulfill(preimage, attribution_data ) => {
1250212506 2u8.write(writer)?;
1250312507 preimage.write(writer)?;
12508+ removed_htlc_attribution_data.push(&attribution_data);
1250412509 },
1250512510 }
1250612511 },
@@ -12817,7 +12822,7 @@ where
1281712822 (51, is_manual_broadcast, option), // Added in 0.0.124
1281812823 (53, funding_tx_broadcast_safe_event_emitted, option), // Added in 0.0.124
1281912824 (54, self.pending_funding, optional_vec), // Added in 0.2
12820- (55, removed_htlc_failure_attribution_data , optional_vec), // Added in 0.2
12825+ (55, removed_htlc_attribution_data , optional_vec), // Added in 0.2
1282112826 (57, holding_cell_failure_attribution_data, optional_vec), // Added in 0.2
1282212827 (58, self.interactive_tx_signing_session, option), // Added in 0.2
1282312828 (59, self.funding.minimum_depth_override, option), // Added in 0.2
@@ -12913,7 +12918,7 @@ where
1291312918 attribution_data: None,
1291412919 }),
1291512920 1 => InboundHTLCRemovalReason::FailMalformed(Readable::read(reader)?),
12916- 2 => InboundHTLCRemovalReason::Fulfill(Readable::read(reader)?),
12921+ 2 => InboundHTLCRemovalReason::Fulfill(Readable::read(reader)?, None ),
1291712922 _ => return Err(DecodeError::InvalidValue),
1291812923 };
1291912924 InboundHTLCState::LocalRemoved(reason)
@@ -13163,7 +13168,7 @@ where
1316313168 let mut pending_outbound_blinding_points_opt: Option<Vec<Option<PublicKey>>> = None;
1316413169 let mut holding_cell_blinding_points_opt: Option<Vec<Option<PublicKey>>> = None;
1316513170
13166- let mut removed_htlc_failure_attribution_data : Option<Vec<Option<AttributionData>>> = None;
13171+ let mut removed_htlc_attribution_data : Option<Vec<Option<AttributionData>>> = None;
1316713172 let mut holding_cell_failure_attribution_data: Option<Vec<Option<AttributionData>>> = None;
1316813173
1316913174 let mut malformed_htlcs: Option<Vec<(u64, u16, [u8; 32])>> = None;
@@ -13216,7 +13221,7 @@ where
1321613221 (51, is_manual_broadcast, option),
1321713222 (53, funding_tx_broadcast_safe_event_emitted, option),
1321813223 (54, pending_funding, optional_vec), // Added in 0.2
13219- (55, removed_htlc_failure_attribution_data , optional_vec),
13224+ (55, removed_htlc_attribution_data , optional_vec),
1322013225 (57, holding_cell_failure_attribution_data, optional_vec),
1322113226 (58, interactive_tx_signing_session, option), // Added in 0.2
1322213227 (59, minimum_depth_override, option), // Added in 0.2
@@ -13322,14 +13327,19 @@ where
1332213327 }
1332313328 }
1332413329
13325- if let Some(attribution_data_list) = removed_htlc_failure_attribution_data {
13330+ if let Some(attribution_data_list) = removed_htlc_attribution_data {
1332613331 let mut removed_htlc_relay_failures =
1332713332 pending_inbound_htlcs.iter_mut().filter_map(|status| {
13328- if let InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailRelay(
13329- ref mut packet,
13330- )) = &mut status.state
13331- {
13332- Some(&mut packet.attribution_data)
13333+ if let InboundHTLCState::LocalRemoved(reason) = &mut status.state {
13334+ match reason {
13335+ InboundHTLCRemovalReason::FailRelay(ref mut packet) => {
13336+ Some(&mut packet.attribution_data)
13337+ },
13338+ InboundHTLCRemovalReason::Fulfill(_, ref mut attribution_data) => {
13339+ Some(attribution_data)
13340+ },
13341+ _ => None,
13342+ }
1333313343 } else {
1333413344 None
1333513345 }
0 commit comments