@@ -10631,19 +10631,19 @@ where
10631
10631
let mut pending_background_events = Vec::new();
10632
10632
macro_rules! handle_in_flight_updates {
10633
10633
($counterparty_node_id: expr, $chan_in_flight_upds: expr, $funding_txo: expr,
10634
- $channel_id: expr, $ monitor: expr, $peer_state: expr, $logger: expr, $channel_info_log: expr
10634
+ $monitor: expr, $peer_state: expr, $logger: expr, $channel_info_log: expr
10635
10635
) => { {
10636
10636
let mut max_in_flight_update_id = 0;
10637
10637
$chan_in_flight_upds.retain(|upd| upd.update_id > $monitor.get_latest_update_id());
10638
10638
for update in $chan_in_flight_upds.iter() {
10639
10639
log_trace!($logger, "Replaying ChannelMonitorUpdate {} for {}channel {}",
10640
- update.update_id, $channel_info_log, &$channel_id);
10640
+ update.update_id, $channel_info_log, &$monitor. channel_id() );
10641
10641
max_in_flight_update_id = cmp::max(max_in_flight_update_id, update.update_id);
10642
10642
pending_background_events.push(
10643
10643
BackgroundEvent::MonitorUpdateRegeneratedOnStartup {
10644
10644
counterparty_node_id: $counterparty_node_id,
10645
10645
funding_txo: $funding_txo,
10646
- channel_id: $channel_id,
10646
+ channel_id: $monitor. channel_id() ,
10647
10647
update: update.clone(),
10648
10648
});
10649
10649
}
@@ -10654,7 +10654,7 @@ where
10654
10654
pending_background_events.push(
10655
10655
BackgroundEvent::MonitorUpdatesComplete {
10656
10656
counterparty_node_id: $counterparty_node_id,
10657
- channel_id: $channel_id,
10657
+ channel_id: $monitor. channel_id() ,
10658
10658
});
10659
10659
}
10660
10660
if $peer_state.in_flight_monitor_updates.insert($funding_txo, $chan_in_flight_upds).is_some() {
@@ -10675,15 +10675,14 @@ where
10675
10675
// Channels that were persisted have to be funded, otherwise they should have been
10676
10676
// discarded.
10677
10677
let funding_txo = chan.context.get_funding_txo().ok_or(DecodeError::InvalidValue)?;
10678
- let channel_id = chan.context.channel_id();
10679
10678
let monitor = args.channel_monitors.get(&funding_txo)
10680
10679
.expect("We already checked for monitor presence when loading channels");
10681
10680
let mut max_in_flight_update_id = monitor.get_latest_update_id();
10682
10681
if let Some(in_flight_upds) = &mut in_flight_monitor_updates {
10683
10682
if let Some(mut chan_in_flight_upds) = in_flight_upds.remove(&(*counterparty_id, funding_txo)) {
10684
10683
max_in_flight_update_id = cmp::max(max_in_flight_update_id,
10685
10684
handle_in_flight_updates!(*counterparty_id, chan_in_flight_upds,
10686
- funding_txo, channel_id, monitor, peer_state, logger, ""));
10685
+ funding_txo, monitor, peer_state, logger, ""));
10687
10686
}
10688
10687
}
10689
10688
if chan.get_latest_unblocked_monitor_update_id() > max_in_flight_update_id {
@@ -10709,8 +10708,8 @@ where
10709
10708
10710
10709
if let Some(in_flight_upds) = in_flight_monitor_updates {
10711
10710
for ((counterparty_id, funding_txo), mut chan_in_flight_updates) in in_flight_upds {
10712
- let channel_id = funding_txo_to_channel_id.get(&funding_txo).copied().unwrap_or(ChannelId::v1_from_funding_outpoint(funding_txo)) ;
10713
- let logger = WithContext::from(&args.logger, Some(counterparty_id), Some( channel_id) );
10711
+ let channel_id = funding_txo_to_channel_id.get(&funding_txo).copied();
10712
+ let logger = WithContext::from(&args.logger, Some(counterparty_id), channel_id);
10714
10713
if let Some(monitor) = args.channel_monitors.get(&funding_txo) {
10715
10714
// Now that we've removed all the in-flight monitor updates for channels that are
10716
10715
// still open, we need to replay any monitor updates that are for closed channels,
@@ -10720,10 +10719,11 @@ where
10720
10719
});
10721
10720
let mut peer_state = peer_state_mutex.lock().unwrap();
10722
10721
handle_in_flight_updates!(counterparty_id, chan_in_flight_updates,
10723
- funding_txo, channel_id, monitor, peer_state, logger, "closed ");
10722
+ funding_txo, monitor, peer_state, logger, "closed ");
10724
10723
} else {
10725
10724
log_error!(logger, "A ChannelMonitor is missing even though we have in-flight updates for it! This indicates a potentially-critical violation of the chain::Watch API!");
10726
- log_error!(logger, " The ChannelMonitor for channel {} is missing.", &channel_id);
10725
+ log_error!(logger, " The ChannelMonitor for channel {} is missing.", if let Some(channel_id) =
10726
+ channel_id { channel_id.to_string() } else { format!("with outpoint {}", funding_txo) } );
10727
10727
log_error!(logger, " The chain::Watch API *requires* that monitors are persisted durably before returning,");
10728
10728
log_error!(logger, " client applications must ensure that ChannelMonitor data is always available and the latest to avoid funds loss!");
10729
10729
log_error!(logger, " Without the latest ChannelMonitor we cannot continue without risking funds.");
0 commit comments