@@ -1229,7 +1229,11 @@ impl_writeable_tlv_based!(PaymentClaimDetails, {
1229
1229
});
1230
1230
1231
1231
#[derive(Clone)]
1232
+ #[cfg(not(any(test, feature = "_test_utils")))]
1232
1233
pub(crate) struct PendingMPPClaimPointer(Arc<Mutex<PendingMPPClaim>>);
1234
+ #[derive(Clone)]
1235
+ #[cfg(any(test, feature = "_test_utils"))]
1236
+ pub struct PendingMPPClaimPointer(Arc<Mutex<PendingMPPClaim>>);
1233
1237
1234
1238
impl PartialEq for PendingMPPClaimPointer {
1235
1239
fn eq(&self, o: &Self) -> bool { Arc::ptr_eq(&self.0, &o.0) }
@@ -1243,6 +1247,7 @@ impl core::fmt::Debug for PendingMPPClaimPointer {
1243
1247
}
1244
1248
1245
1249
#[derive(Clone, PartialEq, Eq, Debug)]
1250
+ #[cfg(not(any(test, feature = "_test_utils")))]
1246
1251
/// If something is blocked on the completion of an RAA-generated [`ChannelMonitorUpdate`] we track
1247
1252
/// the blocked action here. See enum variants for more info.
1248
1253
pub(crate) enum RAAMonitorUpdateBlockingAction {
@@ -1267,6 +1272,32 @@ pub(crate) enum RAAMonitorUpdateBlockingAction {
1267
1272
}
1268
1273
}
1269
1274
1275
+ #[derive(Clone, PartialEq, Eq, Debug)]
1276
+ #[cfg(any(test, feature = "_test_utils"))]
1277
+ /// If something is blocked on the completion of an RAA-generated [`ChannelMonitorUpdate`] we track
1278
+ /// the blocked action here. See enum variants for more info.
1279
+ pub enum RAAMonitorUpdateBlockingAction {
1280
+ /// A forwarded payment was claimed. We block the downstream channel completing its monitor
1281
+ /// update which removes the HTLC preimage until the upstream channel has gotten the preimage
1282
+ /// durably to disk.
1283
+ ForwardedPaymentInboundClaim {
1284
+ /// The upstream channel ID (i.e. the inbound edge).
1285
+ channel_id: ChannelId,
1286
+ /// The HTLC ID on the inbound edge.
1287
+ htlc_id: u64,
1288
+ },
1289
+ /// We claimed an MPP payment across multiple channels. We have to block removing the payment
1290
+ /// preimage from any monitor until the last monitor is updated to contain the payment
1291
+ /// preimage. Otherwise we may not be able to replay the preimage on the monitor(s) that
1292
+ /// weren't updated on startup.
1293
+ ///
1294
+ /// This variant is *not* written to disk, instead being inferred from [`ChannelMonitor`]
1295
+ /// state.
1296
+ ClaimedMPPPayment {
1297
+ pending_claim: PendingMPPClaimPointer,
1298
+ }
1299
+ }
1300
+
1270
1301
impl RAAMonitorUpdateBlockingAction {
1271
1302
fn from_prev_hop_data(prev_hop: &HTLCPreviousHopData) -> Self {
1272
1303
Self::ForwardedPaymentInboundClaim {
@@ -10600,6 +10631,29 @@ where
10600
10631
self.pending_outbound_payments.clear_pending_payments()
10601
10632
}
10602
10633
10634
+ #[cfg(any(test, feature = "_test_utils"))]
10635
+ pub fn get_and_clear_pending_raa_blockers(
10636
+ &self,
10637
+ ) -> Vec<(ChannelId, Vec<RAAMonitorUpdateBlockingAction>)> {
10638
+ let per_peer_state = self.per_peer_state.read().unwrap();
10639
+ let mut pending_blockers = Vec::new();
10640
+
10641
+ for (_peer_pubkey, peer_state_mutex) in per_peer_state.iter() {
10642
+ let mut peer_state = peer_state_mutex.lock().unwrap();
10643
+
10644
+ for (chan_id, actions) in peer_state.actions_blocking_raa_monitor_updates.iter() {
10645
+ // Only collect the non-empty actions into `pending_blockers`.
10646
+ if !actions.is_empty() {
10647
+ pending_blockers.push((chan_id.clone(), actions.clone()));
10648
+ }
10649
+ }
10650
+
10651
+ peer_state.actions_blocking_raa_monitor_updates.clear();
10652
+ }
10653
+
10654
+ pending_blockers
10655
+ }
10656
+
10603
10657
/// When something which was blocking a channel from updating its [`ChannelMonitor`] (e.g. an
10604
10658
/// [`Event`] being handled) completes, this should be called to restore the channel to normal
10605
10659
/// operation. It will double-check that nothing *else* is also blocking the same channel from
0 commit comments