From a3c6f82bb244b9de44cd2aeae3d0178740309179 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Sat, 2 Feb 2019 08:53:06 +0100 Subject: [PATCH] move LNPeer handshake back into initialize --- electrum/lnbase.py | 3 +++ electrum/lntransport.py | 1 + electrum/lnworker.py | 5 ----- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/electrum/lnbase.py b/electrum/lnbase.py index ee4c630b7..cd5247847 100644 --- a/electrum/lnbase.py +++ b/electrum/lnbase.py @@ -232,6 +232,9 @@ class Peer(PrintError): self.transport.send_bytes(gen_msg(message_name, **kwargs)) async def initialize(self): + if isinstance(self.transport, LNTransport): + await self.transport.handshake() + self.channel_db.add_recent_peer(self.transport.peer_addr) self.send_message("init", gflen=0, lflen=1, localfeatures=self.localfeatures) @property diff --git a/electrum/lntransport.py b/electrum/lntransport.py index 671e81564..a80d4c1d6 100644 --- a/electrum/lntransport.py +++ b/electrum/lntransport.py @@ -214,6 +214,7 @@ class LNTransport(LNTransportBase): self.remote_pubkey = peer_addr.pubkey self.host = peer_addr.host self.port = peer_addr.port + self.peer_addr = peer_addr def name(self): return str(self.host) + ':' + str(self.port) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 203583fcc..adf46c3c5 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -249,11 +249,6 @@ class LNWorker(PrintError): port = int(port) peer_addr = LNPeerAddr(host, port, node_id) transport = LNTransport(self.node_keypair.privkey, peer_addr) - try: - await transport.handshake() - except: - return - self.channel_db.add_recent_peer(peer_addr) self._last_tried_peer[peer_addr] = time.time() self.print_error("adding peer", peer_addr) peer = Peer(self, node_id, transport, request_initial_sync=self.config.get("request_initial_sync", True))