async def maybe_listen(self):
    listen_addr = self.config.get('lightning_listen')
    if listen_addr:
        self.logger.info(f'lightning_listen enabled. will try to bind: {listen_addr!r}')
        try:
            netaddr = NetAddress.from_string(listen_addr)
        except Exception as e:
            self.logger.error(f"failed to parse config key 'lightning_listen'. got: {e!r}")
            return
        addr = str(netaddr.host)

        async def cb(reader, writer):
            transport = LNResponderTransport(self.node_keypair.privkey, reader, writer)
            try:
                node_id = (await transport.handshake())
            except Exception as e:
                self.logger.info(f'handshake failure from incoming connection: {e!r}')
                return
            (await self._add_peer_from_transport(node_id=node_id, transport=transport))
        try:
            self.listen_server = (await asyncio.start_server(cb, addr, netaddr.port))
        except OSError as e:
            self.logger.error(f'cannot listen for lightning p2p. error: {e!r}')
async def maybe_listen(self):
    listen_addr = self.config.get('lightning_listen')
    if listen_addr:
        self.logger.info(f'lightning_listen enabled. will try to bind: {listen_addr!r}')
        try:
            netaddr = NetAddress.from_string(listen_addr)
        except Exception as e:
            self.logger.error(f"failed to parse config key 'lightning_listen'. got: {e!r}")
            return
        addr = str(netaddr.host)

        async def cb(reader, writer):
            transport = LNResponderTransport(self.node_keypair.privkey, reader, writer)
            try:
                node_id = (await transport.handshake())
            except Exception as e:
                self.logger.info(f'handshake failure from incoming connection: {e!r}')
                return
            (await self._add_peer_from_transport(node_id=node_id, transport=transport))
        try:
            self.listen_server = (await asyncio.start_server(cb, addr, netaddr.port))
        except OSError as e:
            self.logger.error(f'cannot listen for lightning p2p. error: {e!r}')