@@ -1062,10 +1062,20 @@ impl_writeable_tlv_based_enum!(EventCompletionAction,
1062
1062
}
1063
1063
);
1064
1064
1065
+ #[derive(Clone, Debug, PartialEq, Eq)]
1066
+ /// The source of an HTLC which is being claimed as a part of an incoming payment. Each part is
1067
+ /// tracked in [`PendingMPPClaim`].
1068
+ struct MPPClaimHTLCSource {
1069
+ counterparty_node_id: PublicKey,
1070
+ funding_txo: OutPoint,
1071
+ channel_id: ChannelId,
1072
+ htlc_id: u64,
1073
+ }
1074
+
1065
1075
#[derive(Debug)]
1066
1076
pub(crate) struct PendingMPPClaim {
1067
- channels_without_preimage: Vec<(PublicKey, OutPoint, ChannelId, u64) >,
1068
- channels_with_preimage: Vec<(PublicKey, OutPoint, ChannelId) >,
1077
+ channels_without_preimage: Vec<MPPClaimHTLCSource >,
1078
+ channels_with_preimage: Vec<MPPClaimHTLCSource >,
1069
1079
}
1070
1080
1071
1081
#[derive(Clone)]
@@ -6765,8 +6775,12 @@ where
6765
6775
let pending_mpp_claim_ptr_opt = if sources.len() > 1 {
6766
6776
let channels_without_preimage = sources.iter().filter_map(|htlc| {
6767
6777
if let Some(cp_id) = htlc.prev_hop.counterparty_node_id {
6768
- let prev_hop = &htlc.prev_hop;
6769
- Some((cp_id, prev_hop.outpoint, prev_hop.channel_id, prev_hop.htlc_id))
6778
+ Some(MPPClaimHTLCSource {
6779
+ counterparty_node_id: cp_id,
6780
+ funding_txo: htlc.prev_hop.outpoint,
6781
+ channel_id: htlc.prev_hop.channel_id,
6782
+ htlc_id: htlc.prev_hop.htlc_id,
6783
+ })
6770
6784
} else {
6771
6785
None
6772
6786
}
@@ -7184,15 +7198,25 @@ where
7184
7198
if *pending_claim == claim_ptr {
7185
7199
let mut pending_claim_state_lock = pending_claim.0.lock().unwrap();
7186
7200
let pending_claim_state = &mut *pending_claim_state_lock;
7187
- pending_claim_state.channels_without_preimage.retain(|(cp, outp, cid, hid)| {
7188
- if *cp == counterparty_node_id && *cid == chan_id && *hid == htlc_id {
7189
- pending_claim_state.channels_with_preimage.push((*cp, *outp, *cid));
7201
+ pending_claim_state.channels_without_preimage.retain(|htlc_info| {
7202
+ let this_claim =
7203
+ htlc_info.counterparty_node_id == counterparty_node_id
7204
+ && htlc_info.channel_id == chan_id
7205
+ && htlc_info.htlc_id == htlc_id;
7206
+ if this_claim {
7207
+ pending_claim_state.channels_with_preimage.push(htlc_info.clone());
7190
7208
false
7191
7209
} else { true }
7192
7210
});
7193
7211
if pending_claim_state.channels_without_preimage.is_empty() {
7194
- for (cp, outp, cid) in pending_claim_state.channels_with_preimage.iter() {
7195
- freed_channels.push((*cp, *outp, *cid, blocker.clone()));
7212
+ for htlc_info in pending_claim_state.channels_with_preimage.iter() {
7213
+ let freed_chan = (
7214
+ htlc_info.counterparty_node_id,
7215
+ htlc_info.funding_txo,
7216
+ htlc_info.channel_id,
7217
+ blocker.clone()
7218
+ );
7219
+ freed_channels.push(freed_chan);
7196
7220
}
7197
7221
}
7198
7222
!pending_claim_state.channels_without_preimage.is_empty()
0 commit comments