1
0

lnchannel.get_close_opts: allow REQUEST_REMOTE_FCLOSE if WE_ARE_TOXIC

related https://github.com/spesmilo/electrum/issues/8770
This commit is contained in:
SomberNight
2024-01-15 17:52:48 +00:00
parent 140d2d0247
commit df58dd1f25
4 changed files with 19 additions and 16 deletions

View File

@@ -1015,6 +1015,8 @@ class Channel(AbstractChannel):
def should_try_to_reestablish_peer(self) -> bool:
if self.peer_state != PeerState.DISCONNECTED:
return False
if self.should_request_force_close:
return True
return ChannelState.PREOPENING < self._state < ChannelState.CLOSING
def get_funding_address(self):
@@ -1629,6 +1631,8 @@ class Channel(AbstractChannel):
if not self.has_unsettled_htlcs():
ret.append(ChanCloseOption.COOP_CLOSE)
ret.append(ChanCloseOption.REQUEST_REMOTE_FCLOSE)
if self.get_state() == ChannelState.WE_ARE_TOXIC:
ret.append(ChanCloseOption.REQUEST_REMOTE_FCLOSE)
if not self.is_closed() or self.get_state() == ChannelState.REQUESTED_FCLOSE:
ret.append(ChanCloseOption.LOCAL_FCLOSE)
assert not (self.get_state() == ChannelState.WE_ARE_TOXIC and ChanCloseOption.LOCAL_FCLOSE in ret), "local force-close unsafe if we are toxic"