Browse Source

Fix sending of 'channel_ready':

- send only once
 - in channel_reestablish, do not send it if we are not funded.
 - lnworker: do not send channel_ready before channel_reestablish
master
ThomasV 2 years ago
parent
commit
aad4fd6d48
  1. 12
      electrum/lnpeer.py
  2. 2
      electrum/lnworker.py

12
electrum/lnpeer.py

@ -1273,11 +1273,10 @@ class Peer(Logger):
resend_revoke_and_ack() resend_revoke_and_ack()
chan.peer_state = PeerState.GOOD chan.peer_state = PeerState.GOOD
chan_just_became_ready = False if chan.is_funded():
if chan.is_funded() and their_next_local_ctn == next_local_ctn == 1: chan_just_became_ready = (their_next_local_ctn == next_local_ctn == 1)
chan_just_became_ready = True if chan_just_became_ready or self.features.supports(LnFeatures.OPTION_SCID_ALIAS_OPT):
if chan_just_became_ready or self.features.supports(LnFeatures.OPTION_SCID_ALIAS_OPT): self.send_channel_ready(chan)
self.send_channel_ready(chan)
# checks done # checks done
util.trigger_callback('channel', self.lnworker.wallet, chan) util.trigger_callback('channel', self.lnworker.wallet, chan)
# if we have sent a previous shutdown, it must be retransmitted (Bolt2) # if we have sent a previous shutdown, it must be retransmitted (Bolt2)
@ -1285,6 +1284,9 @@ class Peer(Logger):
await self.send_shutdown(chan) await self.send_shutdown(chan)
def send_channel_ready(self, chan: Channel): def send_channel_ready(self, chan: Channel):
assert chan.is_funded()
if chan.sent_channel_ready:
return
channel_id = chan.channel_id channel_id = chan.channel_id
per_commitment_secret_index = RevocationStore.START_INDEX - 1 per_commitment_secret_index = RevocationStore.START_INDEX - 1
second_per_commitment_point = secret_to_pubkey(int.from_bytes( second_per_commitment_point = secret_to_pubkey(int.from_bytes(

2
electrum/lnworker.py

@ -1199,7 +1199,7 @@ class LNWallet(LNWorker):
elif chan.get_state() == ChannelState.FUNDED: elif chan.get_state() == ChannelState.FUNDED:
peer = self._peers.get(chan.node_id) peer = self._peers.get(chan.node_id)
if peer and peer.is_initialized(): if peer and peer.is_initialized() and chan.peer_state == PeerState.GOOD:
peer.send_channel_ready(chan) peer.send_channel_ready(chan)
elif chan.get_state() == ChannelState.OPEN: elif chan.get_state() == ChannelState.OPEN:

Loading…
Cancel
Save