From 9ccfa318f874865bdeefce49a57ca9077a5b0283 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Tue, 11 Feb 2020 20:55:52 +0100 Subject: [PATCH] add new peer_state for the case where we are waiting for the remote party to force close a channel --- electrum/lnchannel.py | 1 + electrum/lnpeer.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/electrum/lnchannel.py b/electrum/lnchannel.py index 9d07b518d..690aa6195 100644 --- a/electrum/lnchannel.py +++ b/electrum/lnchannel.py @@ -72,6 +72,7 @@ class peer_states(IntEnum): DISCONNECTED = 0 REESTABLISHING = 1 GOOD = 2 + BAD = 3 cs = channel_states state_transitions = [ diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py index 961a13d31..68117b97b 100644 --- a/electrum/lnpeer.py +++ b/electrum/lnpeer.py @@ -848,10 +848,12 @@ class Peer(Logger): else: if dlp_enabled and should_close_they_are_ahead: self.logger.warning(f"channel_reestablish: remote is ahead of us! luckily DLP is enabled. remote PCP: {bh2u(their_local_pcp)}") + # data_loss_protect_remote_pcp is used in lnsweep chan.set_data_loss_protect_remote_pcp(their_next_local_ctn - 1, their_local_pcp) self.lnworker.save_channel(chan) if should_close_they_are_ahead: - self.logger.warning(f"channel_reestablish: remote is ahead of us! trying to get them to force-close.") + self.logger.warning(f"channel_reestablish: remote is ahead of us! They should force-close.") + chan.peer_state = peer_states.BAD return elif should_close_we_are_ahead: self.logger.warning(f"channel_reestablish: we are ahead of remote! trying to force-close.")