From: Matt Corallo <649246+TheBlueMatt@users.noreply.github.com> Date: Thu, 5 Aug 2021 21:05:43 +0000 (+0000) Subject: Merge pull request #1029 from TheBlueMatt/2021-07-log-channel-close X-Git-Tag: v0.0.100~9 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=853007800ebb433f53b5b10e1a941cc65c04e829;hp=69ee4860848d5992b238eca3343141004d9d1572;p=rust-lightning Merge pull request #1029 from TheBlueMatt/2021-07-log-channel-close Log when a channel is closed on startup due to stale ChannelManager --- diff --git a/lightning-background-processor/src/lib.rs b/lightning-background-processor/src/lib.rs index 55ac14c0..afa3633b 100644 --- a/lightning-background-processor/src/lib.rs +++ b/lightning-background-processor/src/lib.rs @@ -39,6 +39,7 @@ use std::ops::Deref; /// then there is a risk of channels force-closing on startup when the manager realizes it's /// outdated. However, as long as `ChannelMonitor` backups are sound, no funds besides those used /// for unilateral chain closure fees are at risk. +#[must_use = "BackgroundProcessor will immediately stop on drop. It should be stored until shutdown."] pub struct BackgroundProcessor { stop_thread: Arc, thread_handle: Option>>, diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index afbfd0ee..24c0c688 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -5000,6 +5000,10 @@ impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> channel.get_cur_counterparty_commitment_transaction_number() > monitor.get_cur_counterparty_commitment_number() || channel.get_latest_monitor_update_id() < monitor.get_latest_update_id() { // But if the channel is behind of the monitor, close the channel: + log_error!(args.logger, "A ChannelManager is stale compared to the current ChannelMonitor!"); + log_error!(args.logger, " The channel will be force-closed and the latest commitment transaction from the ChannelMonitor broadcast."); + log_error!(args.logger, " The ChannelMonitor for channel {} is at update_id {} but the ChannelManager is at update_id {}.", + log_bytes!(channel.channel_id()), monitor.get_latest_update_id(), channel.get_latest_monitor_update_id()); let (_, mut new_failed_htlcs) = channel.force_shutdown(true); failed_htlcs.append(&mut new_failed_htlcs); monitor.broadcast_latest_holder_commitment_txn(&args.tx_broadcaster, &args.logger);