electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 4ccfa39fddb5c67a8c8104b3db8607c0071d5a0a
parent 9045d7b293eb4737dff9e032d14bd7fea61b887d
Author: SomberNight <somber.night@protonmail.com>
Date:   Tue, 23 Jul 2019 20:14:59 +0200

cli: fix add_peer cmd

Diffstat:
Melectrum/commands.py | 4+++-
Melectrum/lnworker.py | 2+-
Melectrum/network.py | 4++--
3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/electrum/commands.py b/electrum/commands.py @@ -776,7 +776,9 @@ class Commands: # lightning network commands @command('wn') def add_peer(self, connection_string, timeout=20): - return self.lnworker.add_peer(connection_string) + coro = self.lnworker.add_peer(connection_string) + self.network.run_from_another_thread(coro, timeout=timeout) + return True @command('wpn') def open_channel(self, connection_string, amount, channel_push=0, password=None): diff --git a/electrum/lnworker.py b/electrum/lnworker.py @@ -643,7 +643,7 @@ class LNWallet(LNWorker): def on_channels_updated(self): self.network.trigger_callback('channels') - async def add_peer(self, connect_str, timeout=20): + async def add_peer(self, connect_str: str) -> Peer: node_id, rest = extract_nodeid(connect_str) peer = self.peers.get(node_id) if not peer: diff --git a/electrum/network.py b/electrum/network.py @@ -311,10 +311,10 @@ class Network(Logger): self.lnwatcher = None self.lngossip = None - def run_from_another_thread(self, coro): + def run_from_another_thread(self, coro, *, timeout=None): assert self._loop_thread != threading.current_thread(), 'must not be called from network thread' fut = asyncio.run_coroutine_threadsafe(coro, self.asyncio_loop) - return fut.result() + return fut.result(timeout) @staticmethod def get_instance() -> Optional["Network"]: