@@ -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
}
@@ -8321,7 +8321,6 @@ where
8321
8321
chan_id, action);
8322
8322
if let MonitorUpdateCompletionAction::FreeOtherChannelImmediately {
8323
8323
downstream_counterparty_node_id: node_id,
8324
- downstream_funding_outpoint: _,
8325
8324
blocking_action: blocker,
8326
8325
downstream_channel_id: channel_id,
8327
8326
} = action
@@ -8494,7 +8493,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8494
8493
"We don't support claim_htlc claims during startup - monitors may not be available yet");
8495
8494
debug_assert_eq!(next_channel_counterparty_node_id, path.hops[0].pubkey);
8496
8495
let ev_completion_action = EventCompletionAction::ReleaseRAAChannelMonitorUpdate {
8497
- channel_funding_outpoint: next_channel_outpoint,
8496
+ channel_funding_outpoint: Some( next_channel_outpoint) ,
8498
8497
channel_id: next_channel_id,
8499
8498
counterparty_node_id: path.hops[0].pubkey,
8500
8499
};
@@ -8598,7 +8597,6 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8598
8597
if let Some(other_chan) = chan_to_release {
8599
8598
(Some(MonitorUpdateCompletionAction::FreeOtherChannelImmediately {
8600
8599
downstream_counterparty_node_id: other_chan.counterparty_node_id,
8601
- downstream_funding_outpoint: other_chan.funding_txo,
8602
8600
downstream_channel_id: other_chan.channel_id,
8603
8601
blocking_action: other_chan.blocking_action,
8604
8602
}), None)
@@ -8672,17 +8670,17 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8672
8670
if *pending_claim == claim_ptr {
8673
8671
let mut pending_claim_state_lock = pending_claim.0.lock().unwrap();
8674
8672
let pending_claim_state = &mut *pending_claim_state_lock;
8675
- pending_claim_state.channels_without_preimage.retain(|(cp, op, cid)| {
8673
+ pending_claim_state.channels_without_preimage.retain(|(cp, cid)| {
8676
8674
let this_claim =
8677
8675
*cp == counterparty_node_id && *cid == chan_id;
8678
8676
if this_claim {
8679
- pending_claim_state.channels_with_preimage.push((*cp, *op, * cid));
8677
+ pending_claim_state.channels_with_preimage.push((*cp, *cid));
8680
8678
false
8681
8679
} else { true }
8682
8680
});
8683
8681
if pending_claim_state.channels_without_preimage.is_empty() {
8684
- for (cp, op, cid) in pending_claim_state.channels_with_preimage.iter() {
8685
- let freed_chan = (*cp, *op, * cid, blocker.clone());
8682
+ for (cp, cid) in pending_claim_state.channels_with_preimage.iter() {
8683
+ let freed_chan = (*cp, *cid, blocker.clone());
8686
8684
freed_channels.push(freed_chan);
8687
8685
}
8688
8686
}
@@ -8734,26 +8732,26 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8734
8732
self.pending_events.lock().unwrap().push_back((event, None));
8735
8733
if let Some(unblocked) = downstream_counterparty_and_funding_outpoint {
8736
8734
self.handle_monitor_update_release(
8737
- unblocked.counterparty_node_id, unblocked.funding_txo,
8738
- unblocked.channel_id, Some(unblocked.blocking_action),
8735
+ unblocked.counterparty_node_id,
8736
+ unblocked.channel_id,
8737
+ Some(unblocked.blocking_action),
8739
8738
);
8740
8739
}
8741
8740
},
8742
8741
MonitorUpdateCompletionAction::FreeOtherChannelImmediately {
8743
- downstream_counterparty_node_id, downstream_funding_outpoint, downstream_channel_id, blocking_action,
8742
+ downstream_counterparty_node_id, downstream_channel_id, blocking_action,
8744
8743
} => {
8745
8744
self.handle_monitor_update_release(
8746
8745
downstream_counterparty_node_id,
8747
- downstream_funding_outpoint,
8748
8746
downstream_channel_id,
8749
8747
Some(blocking_action),
8750
8748
);
8751
8749
},
8752
8750
}
8753
8751
}
8754
8752
8755
- for (node_id, funding_outpoint, channel_id, blocker) in freed_channels {
8756
- self.handle_monitor_update_release(node_id, funding_outpoint, channel_id, Some(blocker));
8753
+ for (node_id, channel_id, blocker) in freed_channels {
8754
+ self.handle_monitor_update_release(node_id, channel_id, Some(blocker));
8757
8755
}
8758
8756
}
8759
8757
@@ -10535,16 +10533,20 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
10535
10533
#[rustfmt::skip]
10536
10534
fn raa_monitor_updates_held(&self,
10537
10535
actions_blocking_raa_monitor_updates: &BTreeMap<ChannelId, Vec<RAAMonitorUpdateBlockingAction>>,
10538
- channel_funding_outpoint: OutPoint, channel_id: ChannelId, counterparty_node_id: PublicKey
10536
+ channel_id: ChannelId, counterparty_node_id: PublicKey,
10539
10537
) -> bool {
10540
10538
actions_blocking_raa_monitor_updates
10541
10539
.get(&channel_id).map(|v| !v.is_empty()).unwrap_or(false)
10542
10540
|| self.pending_events.lock().unwrap().iter().any(|(_, action)| {
10543
- action == &Some(EventCompletionAction::ReleaseRAAChannelMonitorUpdate {
10544
- channel_funding_outpoint,
10545
- channel_id,
10546
- counterparty_node_id,
10547
- })
10541
+ if let Some(EventCompletionAction::ReleaseRAAChannelMonitorUpdate {
10542
+ channel_funding_outpoint: _,
10543
+ channel_id: ev_channel_id,
10544
+ counterparty_node_id: ev_counterparty_node_id
10545
+ }) = action {
10546
+ *ev_channel_id == channel_id && *ev_counterparty_node_id == counterparty_node_id
10547
+ } else {
10548
+ false
10549
+ }
10548
10550
})
10549
10551
}
10550
10552
@@ -10557,14 +10559,12 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
10557
10559
let mut peer_state_lck = peer_state_mtx.lock().unwrap();
10558
10560
let peer_state = &mut *peer_state_lck;
10559
10561
10560
- if let Some(chan) = peer_state.channel_by_id.get(&channel_id) {
10561
- return self.raa_monitor_updates_held(
10562
- &peer_state.actions_blocking_raa_monitor_updates,
10563
- chan.funding().get_funding_txo().unwrap(),
10564
- channel_id,
10565
- counterparty_node_id,
10566
- );
10567
- }
10562
+ assert!(peer_state.channel_by_id.contains_key(&channel_id));
10563
+ return self.raa_monitor_updates_held(
10564
+ &peer_state.actions_blocking_raa_monitor_updates,
10565
+ channel_id,
10566
+ counterparty_node_id,
10567
+ );
10568
10568
}
10569
10569
false
10570
10570
}
@@ -10584,11 +10584,9 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
10584
10584
if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
10585
10585
let logger = WithChannelContext::from(&self.logger, &chan.context, None);
10586
10586
let funding_txo_opt = chan.funding.get_funding_txo();
10587
- let mon_update_blocked = if let Some(funding_txo) = funding_txo_opt {
10588
- self.raa_monitor_updates_held(
10589
- &peer_state.actions_blocking_raa_monitor_updates, funding_txo, msg.channel_id,
10590
- *counterparty_node_id)
10591
- } else { false };
10587
+ let mon_update_blocked = self.raa_monitor_updates_held(
10588
+ &peer_state.actions_blocking_raa_monitor_updates, msg.channel_id,
10589
+ *counterparty_node_id);
10592
10590
let (htlcs_to_fail, monitor_update_opt) = try_channel_entry!(self, peer_state,
10593
10591
chan.revoke_and_ack(&msg, &self.fee_estimator, &&logger, mon_update_blocked), chan_entry);
10594
10592
if let Some(monitor_update) = monitor_update_opt {
@@ -12573,10 +12571,10 @@ where
12573
12571
/// operation. It will double-check that nothing *else* is also blocking the same channel from
12574
12572
/// making progress and then let any blocked [`ChannelMonitorUpdate`]s fly.
12575
12573
#[rustfmt::skip]
12576
- fn handle_monitor_update_release(&self, counterparty_node_id: PublicKey,
12577
- channel_funding_outpoint: OutPoint , channel_id: ChannelId,
12578
- mut completed_blocker: Option<RAAMonitorUpdateBlockingAction>) {
12579
-
12574
+ fn handle_monitor_update_release(
12575
+ &self, counterparty_node_id: PublicKey , channel_id: ChannelId,
12576
+ mut completed_blocker: Option<RAAMonitorUpdateBlockingAction>,
12577
+ ) {
12580
12578
let logger = WithContext::from(
12581
12579
&self.logger, Some(counterparty_node_id), Some(channel_id), None
12582
12580
);
@@ -12595,7 +12593,7 @@ where
12595
12593
}
12596
12594
12597
12595
if self.raa_monitor_updates_held(&peer_state.actions_blocking_raa_monitor_updates,
12598
- channel_funding_outpoint, channel_id, counterparty_node_id) {
12596
+ channel_id, counterparty_node_id) {
12599
12597
// Check that, while holding the peer lock, we don't have anything else
12600
12598
// blocking monitor updates for this channel. If we do, release the monitor
12601
12599
// update(s) when those blockers complete.
@@ -12607,7 +12605,7 @@ where
12607
12605
if let hash_map::Entry::Occupied(mut chan_entry) = peer_state.channel_by_id.entry(
12608
12606
channel_id) {
12609
12607
if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
12610
- debug_assert_eq!( chan.funding.get_funding_txo().unwrap(), channel_funding_outpoint );
12608
+ let channel_funding_outpoint = chan.funding_outpoint( );
12611
12609
if let Some((monitor_update, further_update_exists)) = chan.unblock_next_blocked_monitor_update() {
12612
12610
log_debug!(logger, "Unlocking monitor updating for channel {} and updating monitor",
12613
12611
channel_id);
@@ -12637,16 +12635,11 @@ where
12637
12635
for action in actions {
12638
12636
match action {
12639
12637
EventCompletionAction::ReleaseRAAChannelMonitorUpdate {
12640
- channel_funding_outpoint,
12638
+ channel_funding_outpoint: _ ,
12641
12639
channel_id,
12642
12640
counterparty_node_id,
12643
12641
} => {
12644
- self.handle_monitor_update_release(
12645
- counterparty_node_id,
12646
- channel_funding_outpoint,
12647
- channel_id,
12648
- None,
12649
- );
12642
+ self.handle_monitor_update_release(counterparty_node_id, channel_id, None);
12650
12643
},
12651
12644
}
12652
12645
}
@@ -16420,7 +16413,9 @@ where
16420
16413
// `ChannelMonitor` is removed.
16421
16414
let compl_action =
16422
16415
EventCompletionAction::ReleaseRAAChannelMonitorUpdate {
16423
- channel_funding_outpoint: monitor.get_funding_txo(),
16416
+ channel_funding_outpoint: Some(
16417
+ monitor.get_funding_txo(),
16418
+ ),
16424
16419
channel_id: monitor.channel_id(),
16425
16420
counterparty_node_id: path.hops[0].pubkey,
16426
16421
};
@@ -16923,13 +16918,7 @@ where
16923
16918
let mut channels_without_preimage = payment_claim
16924
16919
.mpp_parts
16925
16920
.iter()
16926
- .map(|htlc_info| {
16927
- (
16928
- htlc_info.counterparty_node_id,
16929
- htlc_info.funding_txo,
16930
- htlc_info.channel_id,
16931
- )
16932
- })
16921
+ .map(|htlc_info| (htlc_info.counterparty_node_id, htlc_info.channel_id))
16933
16922
.collect::<Vec<_>>();
16934
16923
// If we have multiple MPP parts which were received over the same channel,
16935
16924
// we only track it once as once we get a preimage durably in the
0 commit comments