Skip to content

Commit 8530078

Browse files
authored
Merge pull request #1029 from TheBlueMatt/2021-07-log-channel-close
Log when a channel is closed on startup due to stale ChannelManager
2 parents 69ee486 + 5307b5e commit 8530078

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

lightning-background-processor/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ use std::ops::Deref;
3939
/// then there is a risk of channels force-closing on startup when the manager realizes it's
4040
/// outdated. However, as long as `ChannelMonitor` backups are sound, no funds besides those used
4141
/// for unilateral chain closure fees are at risk.
42+
#[must_use = "BackgroundProcessor will immediately stop on drop. It should be stored until shutdown."]
4243
pub struct BackgroundProcessor {
4344
stop_thread: Arc<AtomicBool>,
4445
thread_handle: Option<JoinHandle<Result<(), std::io::Error>>>,

lightning/src/ln/channelmanager.rs

+4
Original file line numberDiff line numberDiff line change
@@ -5000,6 +5000,10 @@ impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
50005000
channel.get_cur_counterparty_commitment_transaction_number() > monitor.get_cur_counterparty_commitment_number() ||
50015001
channel.get_latest_monitor_update_id() < monitor.get_latest_update_id() {
50025002
// But if the channel is behind of the monitor, close the channel:
5003+
log_error!(args.logger, "A ChannelManager is stale compared to the current ChannelMonitor!");
5004+
log_error!(args.logger, " The channel will be force-closed and the latest commitment transaction from the ChannelMonitor broadcast.");
5005+
log_error!(args.logger, " The ChannelMonitor for channel {} is at update_id {} but the ChannelManager is at update_id {}.",
5006+
log_bytes!(channel.channel_id()), monitor.get_latest_update_id(), channel.get_latest_monitor_update_id());
50035007
let (_, mut new_failed_htlcs) = channel.force_shutdown(true);
50045008
failed_htlcs.append(&mut new_failed_htlcs);
50055009
monitor.broadcast_latest_holder_commitment_txn(&args.tx_broadcaster, &args.logger);

0 commit comments

Comments
 (0)