@@ -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;
@@ -8379,12 +8380,15 @@ where
83798380 failure_code: failure_code.clone(),
83808381 });
83818382 },
8382- &InboundHTLCRemovalReason::Fulfill(ref payment_preimage) => {
8383+ &InboundHTLCRemovalReason::Fulfill(
8384+ ref payment_preimage,
8385+ ref attribution_data,
8386+ ) => {
83838387 update_fulfill_htlcs.push(msgs::UpdateFulfillHTLC {
83848388 channel_id: self.context.channel_id(),
83858389 htlc_id: htlc.htlc_id,
83868390 payment_preimage: payment_preimage.clone(),
8387- attribution_data: None ,
8391+ attribution_data: attribution_data.clone() ,
83888392 });
83898393 },
83908394 }
@@ -12456,7 +12460,7 @@ where
1245612460 dropped_inbound_htlcs += 1;
1245712461 }
1245812462 }
12459- let mut removed_htlc_failure_attribution_data : Vec<&Option<AttributionData>> = Vec::new();
12463+ let mut removed_htlc_attribution_data : Vec<&Option<AttributionData>> = Vec::new();
1246012464 (self.context.pending_inbound_htlcs.len() as u64 - dropped_inbound_htlcs).write(writer)?;
1246112465 for htlc in self.context.pending_inbound_htlcs.iter() {
1246212466 if let &InboundHTLCState::RemoteAnnounced(_) = &htlc.state {
@@ -12488,15 +12492,16 @@ where
1248812492 }) => {
1248912493 0u8.write(writer)?;
1249012494 data.write(writer)?;
12491- removed_htlc_failure_attribution_data .push(&attribution_data);
12495+ removed_htlc_attribution_data .push(&attribution_data);
1249212496 },
1249312497 InboundHTLCRemovalReason::FailMalformed((hash, code)) => {
1249412498 1u8.write(writer)?;
1249512499 (hash, code).write(writer)?;
1249612500 },
12497- InboundHTLCRemovalReason::Fulfill(preimage) => {
12501+ InboundHTLCRemovalReason::Fulfill(preimage, attribution_data ) => {
1249812502 2u8.write(writer)?;
1249912503 preimage.write(writer)?;
12504+ removed_htlc_attribution_data.push(&attribution_data);
1250012505 },
1250112506 }
1250212507 },
@@ -12813,7 +12818,7 @@ where
1281312818 (51, is_manual_broadcast, option), // Added in 0.0.124
1281412819 (53, funding_tx_broadcast_safe_event_emitted, option), // Added in 0.0.124
1281512820 (54, self.pending_funding, optional_vec), // Added in 0.2
12816- (55, removed_htlc_failure_attribution_data , optional_vec), // Added in 0.2
12821+ (55, removed_htlc_attribution_data , optional_vec), // Added in 0.2
1281712822 (57, holding_cell_failure_attribution_data, optional_vec), // Added in 0.2
1281812823 (58, self.interactive_tx_signing_session, option), // Added in 0.2
1281912824 (59, self.funding.minimum_depth_override, option), // Added in 0.2
@@ -12909,7 +12914,7 @@ where
1290912914 attribution_data: None,
1291012915 }),
1291112916 1 => InboundHTLCRemovalReason::FailMalformed(Readable::read(reader)?),
12912- 2 => InboundHTLCRemovalReason::Fulfill(Readable::read(reader)?),
12917+ 2 => InboundHTLCRemovalReason::Fulfill(Readable::read(reader)?, None ),
1291312918 _ => return Err(DecodeError::InvalidValue),
1291412919 };
1291512920 InboundHTLCState::LocalRemoved(reason)
@@ -13159,7 +13164,7 @@ where
1315913164 let mut pending_outbound_blinding_points_opt: Option<Vec<Option<PublicKey>>> = None;
1316013165 let mut holding_cell_blinding_points_opt: Option<Vec<Option<PublicKey>>> = None;
1316113166
13162- let mut removed_htlc_failure_attribution_data : Option<Vec<Option<AttributionData>>> = None;
13167+ let mut removed_htlc_attribution_data : Option<Vec<Option<AttributionData>>> = None;
1316313168 let mut holding_cell_failure_attribution_data: Option<Vec<Option<AttributionData>>> = None;
1316413169
1316513170 let mut malformed_htlcs: Option<Vec<(u64, u16, [u8; 32])>> = None;
@@ -13212,7 +13217,7 @@ where
1321213217 (51, is_manual_broadcast, option),
1321313218 (53, funding_tx_broadcast_safe_event_emitted, option),
1321413219 (54, pending_funding, optional_vec), // Added in 0.2
13215- (55, removed_htlc_failure_attribution_data , optional_vec),
13220+ (55, removed_htlc_attribution_data , optional_vec),
1321613221 (57, holding_cell_failure_attribution_data, optional_vec),
1321713222 (58, interactive_tx_signing_session, option), // Added in 0.2
1321813223 (59, minimum_depth_override, option), // Added in 0.2
@@ -13318,14 +13323,19 @@ where
1331813323 }
1331913324 }
1332013325
13321- if let Some(attribution_data_list) = removed_htlc_failure_attribution_data {
13326+ if let Some(attribution_data_list) = removed_htlc_attribution_data {
1332213327 let mut removed_htlc_relay_failures =
1332313328 pending_inbound_htlcs.iter_mut().filter_map(|status| {
13324- if let InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailRelay(
13325- ref mut packet,
13326- )) = &mut status.state
13327- {
13328- Some(&mut packet.attribution_data)
13329+ if let InboundHTLCState::LocalRemoved(reason) = &mut status.state {
13330+ match reason {
13331+ InboundHTLCRemovalReason::FailRelay(ref mut packet) => {
13332+ Some(&mut packet.attribution_data)
13333+ },
13334+ InboundHTLCRemovalReason::Fulfill(_, ref mut attribution_data) => {
13335+ Some(attribution_data)
13336+ },
13337+ _ => None,
13338+ }
1332913339 } else {
1333013340 None
1333113341 }
0 commit comments