electrum

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

commit 6efe5db0d05286b3cd96c62bcb2a8bbf5bb7a628
parent 1763d02b05fca7c27ef7892271110a6853821e5e
Author: ThomasV <thomasv@electrum.org>
Date:   Thu, 11 Oct 2018 18:10:31 +0200

run open_channel in a WaitingDialog

Diffstat:
Melectrum/gui/qt/channels_list.py | 9+--------
Melectrum/gui/qt/main_window.py | 9+++++++++
Melectrum/lnworker.py | 4++--
3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/electrum/gui/qt/channels_list.py b/electrum/gui/qt/channels_list.py @@ -111,11 +111,4 @@ class ChannelsList(MyTreeWidget): local_amt = local_amt_inp.get_amount() push_amt = push_amt_inp.get_amount() connect_contents = str(remote_nodeid.text()).strip() - self.main_window.protect(self.open_channel, (connect_contents, local_amt, push_amt)) - - def open_channel(self, *args, **kwargs): - try: - self.parent.wallet.lnworker.open_channel(*args, **kwargs) - except Exception as e: - # don't use str(e) because str(asyncio.TimeoutError()) (and many others) is '' - self.parent.show_error('Cannot open channel: %s' % repr(e)) + self.parent.open_channel(connect_contents, local_amt, push_amt) diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py @@ -1850,6 +1850,15 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): WaitingDialog(self, _('Broadcasting transaction...'), broadcast_thread, broadcast_done, self.on_error) + @protected + def open_channel(self, *args, **kwargs): + def task(): + return self.wallet.lnworker.open_channel(*args, **kwargs) + def on_success(result): + print(result) + self.show_message(_('Channel open')) + WaitingDialog(self, _('Opening channel...'), task, on_success, self.on_error) + def query_choice(self, msg, choices): # Needed by QtHandler for hardware wallets dialog = WindowModalDialog(self.top_level_window()) diff --git a/electrum/lnworker.py b/electrum/lnworker.py @@ -214,7 +214,7 @@ class LNWorker(PrintError): # TODO maybe filter out onion if not on tor? return random.choice(addr_list) - def open_channel(self, connect_contents, local_amt_sat, push_amt_sat, pw, timeout=5): + def open_channel(self, connect_contents, local_amt_sat, push_amt_sat, password=None, timeout=5): node_id, rest = extract_nodeid(connect_contents) peer = self.peers.get(node_id) if not peer: @@ -231,7 +231,7 @@ class LNWorker(PrintError): except socket.gaierror: raise ConnStringFormatError(_('Hostname does not resolve (getaddrinfo failed)')) peer = self.add_peer(host, port, node_id) - coro = self._open_channel_coroutine(peer, local_amt_sat, push_amt_sat, None if pw == "" else pw) + coro = self._open_channel_coroutine(peer, local_amt_sat, push_amt_sat, password) f = asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop) return f.result(timeout)