@@ -6962,7 +6962,16 @@ where
6962
6962
UpdateFulfillCommitFetch::DuplicateClaim {} => {
6963
6963
let (action_opt, raa_blocker_opt) = completion_action(None, true);
6964
6964
if let Some(raa_blocker) = raa_blocker_opt {
6965
- debug_assert!(peer_state.actions_blocking_raa_monitor_updates.get(&chan_id).unwrap().contains(&raa_blocker));
6965
+ // If we're making a claim during startup, its a replay of a
6966
+ // payment claim from a `ChannelMonitor`. In some cases (MPP or
6967
+ // if the HTLC was only recently removed) we make such claims
6968
+ // after an HTLC has been removed from a channel entirely, and
6969
+ // thus the RAA blocker has long since completed.
6970
+ //
6971
+ // In any other case, the RAA blocker must still be present and
6972
+ // blocking RAAs.
6973
+ debug_assert!(during_init ||
6974
+ peer_state.actions_blocking_raa_monitor_updates.get(&chan_id).unwrap().contains(&raa_blocker));
6966
6975
}
6967
6976
let action = if let Some(action) = action_opt {
6968
6977
action
@@ -6974,38 +6983,41 @@ where
6974
6983
6975
6984
log_trace!(logger, "Completing monitor update completion action for channel {} as claim was redundant: {:?}",
6976
6985
chan_id, action);
6977
- let (node_id, _funding_outpoint, channel_id, blocker) =
6978
6986
if let MonitorUpdateCompletionAction::FreeOtherChannelImmediately {
6979
6987
downstream_counterparty_node_id: node_id,
6980
- downstream_funding_outpoint: funding_outpoint ,
6988
+ downstream_funding_outpoint: _ ,
6981
6989
blocking_action: blocker, downstream_channel_id: channel_id,
6982
6990
} = action {
6983
- (node_id, funding_outpoint, channel_id, blocker)
6991
+ if let Some(peer_state_mtx) = per_peer_state.get(&node_id) {
6992
+ let mut peer_state = peer_state_mtx.lock().unwrap();
6993
+ if let Some(blockers) = peer_state
6994
+ .actions_blocking_raa_monitor_updates
6995
+ .get_mut(&channel_id)
6996
+ {
6997
+ let mut found_blocker = false;
6998
+ blockers.retain(|iter| {
6999
+ // Note that we could actually be blocked, in
7000
+ // which case we need to only remove the one
7001
+ // blocker which was added duplicatively.
7002
+ let first_blocker = !found_blocker;
7003
+ if *iter == blocker { found_blocker = true; }
7004
+ *iter != blocker || !first_blocker
7005
+ });
7006
+ debug_assert!(found_blocker);
7007
+ }
7008
+ } else {
7009
+ debug_assert!(false);
7010
+ }
7011
+ } else if matches!(action, MonitorUpdateCompletionAction::PaymentClaimed { .. }) {
7012
+ debug_assert!(during_init,
7013
+ "Duplicate claims should always either be for forwarded payments(freeing another channel immediately) or during init (for claim replay)");
7014
+ mem::drop(per_peer_state);
7015
+ self.handle_monitor_update_completion_actions([action]);
6984
7016
} else {
6985
7017
debug_assert!(false,
6986
- "Duplicate claims should always free another channel immediately");
7018
+ "Duplicate claims should always either be for forwarded payments(freeing another channel immediately) or during init (for claim replay) ");
6987
7019
return;
6988
7020
};
6989
- if let Some(peer_state_mtx) = per_peer_state.get(&node_id) {
6990
- let mut peer_state = peer_state_mtx.lock().unwrap();
6991
- if let Some(blockers) = peer_state
6992
- .actions_blocking_raa_monitor_updates
6993
- .get_mut(&channel_id)
6994
- {
6995
- let mut found_blocker = false;
6996
- blockers.retain(|iter| {
6997
- // Note that we could actually be blocked, in
6998
- // which case we need to only remove the one
6999
- // blocker which was added duplicatively.
7000
- let first_blocker = !found_blocker;
7001
- if *iter == blocker { found_blocker = true; }
7002
- *iter != blocker || !first_blocker
7003
- });
7004
- debug_assert!(found_blocker);
7005
- }
7006
- } else {
7007
- debug_assert!(false);
7008
- }
7009
7021
}
7010
7022
}
7011
7023
}
0 commit comments