Skip to content

Commit 22ed16f

Browse files
Log and panic when fallen behind remote commitment number
1 parent 1e25979 commit 22ed16f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lightning/src/ln/channel.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4236,6 +4236,21 @@ impl<SP: Deref> Channel<SP> where
42364236
} else {
42374237
Some(self.get_last_revoke_and_ack())
42384238
}
4239+
} else if msg.next_remote_commitment_number < self.context.cur_holder_commitment_transaction_number {
4240+
macro_rules! log_and_panic {
4241+
($err_msg: expr) => {
4242+
log_error!(logger, $err_msg, &self.context.channel_id, log_pubkey!(self.context.counterparty_node_id));
4243+
panic!($err_msg, &self.context.channel_id, log_pubkey!(self.context.counterparty_node_id));
4244+
}
4245+
}
4246+
log_and_panic!("We have fallen behind - we have received proof that if we broadcast our counterparty is going to claim all our funds.\n\
4247+
This implies you have restarted with lost ChannelMonitor and ChannelManager state, the first of which is a violation of the LDK chain::Watch requirements.\n\
4248+
More specifically, this means you have a bug in your implementation that can cause loss of funds, or you are running with an old backup, which is unsafe.\n\
4249+
If you have restored from an old backup and wish to force-close channels and return to operation, you should start up, call\n\
4250+
ChannelManager::force_close_without_broadcasting_txn on channel {} with counterparty {} or\n\
4251+
ChannelManager::force_close_all_channels_without_broadcasting_txn, then reconnect to peer(s).\n\
4252+
Note that due to a long-standing bug in lnd you may have to reach out to peers running lnd-based nodes to ask them to manually force-close channels\n\
4253+
See https://github.com/lightningdevkit/rust-lightning/issues/1565 for more info.");
42394254
} else {
42404255
return Err(ChannelError::Close("Peer attempted to reestablish channel with a very old local commitment transaction".to_owned()));
42414256
};

0 commit comments

Comments
 (0)