@@ -1202,7 +1202,6 @@ pub(crate) enum MonitorUpdateCompletionAction {
1202
1202
/// stored for later processing.
1203
1203
FreeOtherChannelImmediately {
1204
1204
downstream_counterparty_node_id: PublicKey,
1205
- downstream_funding_outpoint: OutPoint,
1206
1205
blocking_action: RAAMonitorUpdateBlockingAction,
1207
1206
downstream_channel_id: ChannelId,
1208
1207
},
@@ -1217,11 +1216,8 @@ impl_writeable_tlv_based_enum_upgradable!(MonitorUpdateCompletionAction,
1217
1216
// *immediately*. However, for simplicity we implement read/write here.
1218
1217
(1, FreeOtherChannelImmediately) => {
1219
1218
(0, downstream_counterparty_node_id, required),
1220
- (2, downstream_funding_outpoint, required),
1221
1219
(4, blocking_action, upgradable_required),
1222
- // Note that by the time we get past the required read above, downstream_funding_outpoint will be
1223
- // filled in, so we can safely unwrap it here.
1224
- (5, downstream_channel_id, (default_value, ChannelId::v1_from_funding_outpoint(downstream_funding_outpoint.0.unwrap()))),
1220
+ (5, downstream_channel_id, required),
1225
1221
},
1226
1222
(2, EmitEventAndFreeOtherChannel) => {
1227
1223
(0, event, upgradable_required),
@@ -1238,17 +1234,21 @@ impl_writeable_tlv_based_enum_upgradable!(MonitorUpdateCompletionAction,
1238
1234
pub(crate) enum EventCompletionAction {
1239
1235
ReleaseRAAChannelMonitorUpdate {
1240
1236
counterparty_node_id: PublicKey,
1241
- channel_funding_outpoint: OutPoint,
1237
+ // Was required until LDK 0.2. Always filled in as `Some`.
1238
+ channel_funding_outpoint: Option<OutPoint>,
1242
1239
channel_id: ChannelId,
1243
1240
},
1244
1241
}
1245
1242
impl_writeable_tlv_based_enum!(EventCompletionAction,
1246
1243
(0, ReleaseRAAChannelMonitorUpdate) => {
1247
- (0, channel_funding_outpoint, required ),
1244
+ (0, channel_funding_outpoint, option ),
1248
1245
(2, counterparty_node_id, required),
1249
- // Note that by the time we get past the required read above, channel_funding_outpoint will be
1250
- // filled in, so we can safely unwrap it here.
1251
- (3, channel_id, (default_value, ChannelId::v1_from_funding_outpoint(channel_funding_outpoint.0.unwrap()))),
1246
+ (3, channel_id, (default_value, {
1247
+ if channel_funding_outpoint.is_none() {
1248
+ Err(DecodeError::InvalidValue)?
1249
+ }
1250
+ ChannelId::v1_from_funding_outpoint(channel_funding_outpoint.unwrap())
1251
+ })),
1252
1252
}
1253
1253
);
1254
1254
@@ -1278,8 +1278,8 @@ impl From<&MPPClaimHTLCSource> for HTLCClaimSource {
1278
1278
1279
1279
#[derive(Debug)]
1280
1280
pub(crate) struct PendingMPPClaim {
1281
- channels_without_preimage: Vec<(PublicKey, OutPoint, ChannelId)>,
1282
- channels_with_preimage: Vec<(PublicKey, OutPoint, ChannelId)>,
1281
+ channels_without_preimage: Vec<(PublicKey, ChannelId)>,
1282
+ channels_with_preimage: Vec<(PublicKey, ChannelId)>,
1283
1283
}
1284
1284
1285
1285
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
@@ -8066,7 +8066,7 @@ where
8066
8066
let pending_mpp_claim_ptr_opt = if sources.len() > 1 {
8067
8067
let mut channels_without_preimage = Vec::with_capacity(mpp_parts.len());
8068
8068
for part in mpp_parts.iter() {
8069
- let chan = (part.counterparty_node_id, part.funding_txo, part. channel_id);
8069
+ let chan = (part.counterparty_node_id, part.channel_id);
8070
8070
if !channels_without_preimage.contains(&chan) {
8071
8071
channels_without_preimage.push(chan);
8072
8072
}
@@ -8304,7 +8304,6 @@ where
8304
8304
chan_id, action);
8305
8305
if let MonitorUpdateCompletionAction::FreeOtherChannelImmediately {
8306
8306
downstream_counterparty_node_id: node_id,
8307
- downstream_funding_outpoint: _,
8308
8307
blocking_action: blocker,
8309
8308
downstream_channel_id: channel_id,
8310
8309
} = action
@@ -8477,7 +8476,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8477
8476
"We don't support claim_htlc claims during startup - monitors may not be available yet");
8478
8477
debug_assert_eq!(next_channel_counterparty_node_id, path.hops[0].pubkey);
8479
8478
let ev_completion_action = EventCompletionAction::ReleaseRAAChannelMonitorUpdate {
8480
- channel_funding_outpoint: next_channel_outpoint,
8479
+ channel_funding_outpoint: Some( next_channel_outpoint) ,
8481
8480
channel_id: next_channel_id,
8482
8481
counterparty_node_id: path.hops[0].pubkey,
8483
8482
};
@@ -8581,7 +8580,6 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8581
8580
if let Some(other_chan) = chan_to_release {
8582
8581
(Some(MonitorUpdateCompletionAction::FreeOtherChannelImmediately {
8583
8582
downstream_counterparty_node_id: other_chan.counterparty_node_id,
8584
- downstream_funding_outpoint: other_chan.funding_txo,
8585
8583
downstream_channel_id: other_chan.channel_id,
8586
8584
blocking_action: other_chan.blocking_action,
8587
8585
}), None)
@@ -8655,17 +8653,17 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8655
8653
if *pending_claim == claim_ptr {
8656
8654
let mut pending_claim_state_lock = pending_claim.0.lock().unwrap();
8657
8655
let pending_claim_state = &mut *pending_claim_state_lock;
8658
- pending_claim_state.channels_without_preimage.retain(|(cp, op, cid)| {
8656
+ pending_claim_state.channels_without_preimage.retain(|(cp, cid)| {
8659
8657
let this_claim =
8660
8658
*cp == counterparty_node_id && *cid == chan_id;
8661
8659
if this_claim {
8662
- pending_claim_state.channels_with_preimage.push((*cp, *op, * cid));
8660
+ pending_claim_state.channels_with_preimage.push((*cp, *cid));
8663
8661
false
8664
8662
} else { true }
8665
8663
});
8666
8664
if pending_claim_state.channels_without_preimage.is_empty() {
8667
- for (cp, op, cid) in pending_claim_state.channels_with_preimage.iter() {
8668
- let freed_chan = (*cp, *op, * cid, blocker.clone());
8665
+ for (cp, cid) in pending_claim_state.channels_with_preimage.iter() {
8666
+ let freed_chan = (*cp, *cid, blocker.clone());
8669
8667
freed_channels.push(freed_chan);
8670
8668
}
8671
8669
}
@@ -8717,26 +8715,26 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8717
8715
self.pending_events.lock().unwrap().push_back((event, None));
8718
8716
if let Some(unblocked) = downstream_counterparty_and_funding_outpoint {
8719
8717
self.handle_monitor_update_release(
8720
- unblocked.counterparty_node_id, unblocked.funding_txo,
8721
- unblocked.channel_id, Some(unblocked.blocking_action),
8718
+ unblocked.counterparty_node_id,
8719
+ unblocked.channel_id,
8720
+ Some(unblocked.blocking_action),
8722
8721
);
8723
8722
}
8724
8723
},
8725
8724
MonitorUpdateCompletionAction::FreeOtherChannelImmediately {
8726
- downstream_counterparty_node_id, downstream_funding_outpoint, downstream_channel_id, blocking_action,
8725
+ downstream_counterparty_node_id, downstream_channel_id, blocking_action,
8727
8726
} => {
8728
8727
self.handle_monitor_update_release(
8729
8728
downstream_counterparty_node_id,
8730
- downstream_funding_outpoint,
8731
8729
downstream_channel_id,
8732
8730
Some(blocking_action),
8733
8731
);
8734
8732
},
8735
8733
}
8736
8734
}
8737
8735
8738
- for (node_id, funding_outpoint, channel_id, blocker) in freed_channels {
8739
- self.handle_monitor_update_release(node_id, funding_outpoint, channel_id, Some(blocker));
8736
+ for (node_id, channel_id, blocker) in freed_channels {
8737
+ self.handle_monitor_update_release(node_id, channel_id, Some(blocker));
8740
8738
}
8741
8739
}
8742
8740
@@ -10518,16 +10516,20 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
10518
10516
#[rustfmt::skip]
10519
10517
fn raa_monitor_updates_held(&self,
10520
10518
actions_blocking_raa_monitor_updates: &BTreeMap<ChannelId, Vec<RAAMonitorUpdateBlockingAction>>,
10521
- channel_funding_outpoint: OutPoint, channel_id: ChannelId, counterparty_node_id: PublicKey
10519
+ channel_id: ChannelId, counterparty_node_id: PublicKey,
10522
10520
) -> bool {
10523
10521
actions_blocking_raa_monitor_updates
10524
10522
.get(&channel_id).map(|v| !v.is_empty()).unwrap_or(false)
10525
10523
|| self.pending_events.lock().unwrap().iter().any(|(_, action)| {
10526
- action == &Some(EventCompletionAction::ReleaseRAAChannelMonitorUpdate {
10527
- channel_funding_outpoint,
10528
- channel_id,
10529
- counterparty_node_id,
10530
- })
10524
+ if let Some(EventCompletionAction::ReleaseRAAChannelMonitorUpdate {
10525
+ channel_funding_outpoint: _,
10526
+ channel_id: ev_channel_id,
10527
+ counterparty_node_id: ev_counterparty_node_id
10528
+ }) = action {
10529
+ *ev_channel_id == channel_id && *ev_counterparty_node_id == counterparty_node_id
10530
+ } else {
10531
+ false
10532
+ }
10531
10533
})
10532
10534
}
10533
10535
@@ -10540,14 +10542,12 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
10540
10542
let mut peer_state_lck = peer_state_mtx.lock().unwrap();
10541
10543
let peer_state = &mut *peer_state_lck;
10542
10544
10543
- if let Some(chan) = peer_state.channel_by_id.get(&channel_id) {
10544
- return self.raa_monitor_updates_held(
10545
- &peer_state.actions_blocking_raa_monitor_updates,
10546
- chan.funding().get_funding_txo().unwrap(),
10547
- channel_id,
10548
- counterparty_node_id,
10549
- );
10550
- }
10545
+ assert!(peer_state.channel_by_id.contains_key(&channel_id));
10546
+ return self.raa_monitor_updates_held(
10547
+ &peer_state.actions_blocking_raa_monitor_updates,
10548
+ channel_id,
10549
+ counterparty_node_id,
10550
+ );
10551
10551
}
10552
10552
false
10553
10553
}
@@ -10567,11 +10567,9 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
10567
10567
if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
10568
10568
let logger = WithChannelContext::from(&self.logger, &chan.context, None);
10569
10569
let funding_txo_opt = chan.funding.get_funding_txo();
10570
- let mon_update_blocked = if let Some(funding_txo) = funding_txo_opt {
10571
- self.raa_monitor_updates_held(
10572
- &peer_state.actions_blocking_raa_monitor_updates, funding_txo, msg.channel_id,
10573
- *counterparty_node_id)
10574
- } else { false };
10570
+ let mon_update_blocked = self.raa_monitor_updates_held(
10571
+ &peer_state.actions_blocking_raa_monitor_updates, msg.channel_id,
10572
+ *counterparty_node_id);
10575
10573
let (htlcs_to_fail, monitor_update_opt) = try_channel_entry!(self, peer_state,
10576
10574
chan.revoke_and_ack(&msg, &self.fee_estimator, &&logger, mon_update_blocked), chan_entry);
10577
10575
if let Some(monitor_update) = monitor_update_opt {
@@ -12556,10 +12554,10 @@ where
12556
12554
/// operation. It will double-check that nothing *else* is also blocking the same channel from
12557
12555
/// making progress and then let any blocked [`ChannelMonitorUpdate`]s fly.
12558
12556
#[rustfmt::skip]
12559
- fn handle_monitor_update_release(&self, counterparty_node_id: PublicKey,
12560
- channel_funding_outpoint: OutPoint , channel_id: ChannelId,
12561
- mut completed_blocker: Option<RAAMonitorUpdateBlockingAction>) {
12562
-
12557
+ fn handle_monitor_update_release(
12558
+ &self, counterparty_node_id: PublicKey , channel_id: ChannelId,
12559
+ mut completed_blocker: Option<RAAMonitorUpdateBlockingAction>,
12560
+ ) {
12563
12561
let logger = WithContext::from(
12564
12562
&self.logger, Some(counterparty_node_id), Some(channel_id), None
12565
12563
);
@@ -12578,7 +12576,7 @@ where
12578
12576
}
12579
12577
12580
12578
if self.raa_monitor_updates_held(&peer_state.actions_blocking_raa_monitor_updates,
12581
- channel_funding_outpoint, channel_id, counterparty_node_id) {
12579
+ channel_id, counterparty_node_id) {
12582
12580
// Check that, while holding the peer lock, we don't have anything else
12583
12581
// blocking monitor updates for this channel. If we do, release the monitor
12584
12582
// update(s) when those blockers complete.
@@ -12590,7 +12588,7 @@ where
12590
12588
if let hash_map::Entry::Occupied(mut chan_entry) = peer_state.channel_by_id.entry(
12591
12589
channel_id) {
12592
12590
if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
12593
- debug_assert_eq!( chan.funding.get_funding_txo().unwrap(), channel_funding_outpoint );
12591
+ let channel_funding_outpoint = chan.funding.get_funding_txo().unwrap();
12594
12592
if let Some((monitor_update, further_update_exists)) = chan.unblock_next_blocked_monitor_update() {
12595
12593
log_debug!(logger, "Unlocking monitor updating for channel {} and updating monitor",
12596
12594
channel_id);
@@ -12620,16 +12618,11 @@ where
12620
12618
for action in actions {
12621
12619
match action {
12622
12620
EventCompletionAction::ReleaseRAAChannelMonitorUpdate {
12623
- channel_funding_outpoint,
12621
+ channel_funding_outpoint: _ ,
12624
12622
channel_id,
12625
12623
counterparty_node_id,
12626
12624
} => {
12627
- self.handle_monitor_update_release(
12628
- counterparty_node_id,
12629
- channel_funding_outpoint,
12630
- channel_id,
12631
- None,
12632
- );
12625
+ self.handle_monitor_update_release(counterparty_node_id, channel_id, None);
12633
12626
},
12634
12627
}
12635
12628
}
@@ -16403,7 +16396,9 @@ where
16403
16396
// `ChannelMonitor` is removed.
16404
16397
let compl_action =
16405
16398
EventCompletionAction::ReleaseRAAChannelMonitorUpdate {
16406
- channel_funding_outpoint: monitor.get_funding_txo(),
16399
+ channel_funding_outpoint: Some(
16400
+ monitor.get_funding_txo(),
16401
+ ),
16407
16402
channel_id: monitor.channel_id(),
16408
16403
counterparty_node_id: path.hops[0].pubkey,
16409
16404
};
@@ -16906,13 +16901,7 @@ where
16906
16901
let mut channels_without_preimage = payment_claim
16907
16902
.mpp_parts
16908
16903
.iter()
16909
- .map(|htlc_info| {
16910
- (
16911
- htlc_info.counterparty_node_id,
16912
- htlc_info.funding_txo,
16913
- htlc_info.channel_id,
16914
- )
16915
- })
16904
+ .map(|htlc_info| (htlc_info.counterparty_node_id, htlc_info.channel_id))
16916
16905
.collect::<Vec<_>>();
16917
16906
// If we have multiple MPP parts which were received over the same channel,
16918
16907
// we only track it once as once we get a preimage durably in the
0 commit comments