Browse Source

run open_channel in a WaitingDialog

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
ThomasV 6 years ago
parent
commit
6efe5db0d0
  1. 9
      electrum/gui/qt/channels_list.py
  2. 9
      electrum/gui/qt/main_window.py
  3. 4
      electrum/lnworker.py

9
electrum/gui/qt/channels_list.py

@ -111,11 +111,4 @@ class ChannelsList(MyTreeWidget):
local_amt = local_amt_inp.get_amount() local_amt = local_amt_inp.get_amount()
push_amt = push_amt_inp.get_amount() push_amt = push_amt_inp.get_amount()
connect_contents = str(remote_nodeid.text()).strip() connect_contents = str(remote_nodeid.text()).strip()
self.main_window.protect(self.open_channel, (connect_contents, local_amt, push_amt)) self.parent.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))

9
electrum/gui/qt/main_window.py

@ -1850,6 +1850,15 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
WaitingDialog(self, _('Broadcasting transaction...'), WaitingDialog(self, _('Broadcasting transaction...'),
broadcast_thread, broadcast_done, self.on_error) 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): def query_choice(self, msg, choices):
# Needed by QtHandler for hardware wallets # Needed by QtHandler for hardware wallets
dialog = WindowModalDialog(self.top_level_window()) dialog = WindowModalDialog(self.top_level_window())

4
electrum/lnworker.py

@ -214,7 +214,7 @@ class LNWorker(PrintError):
# TODO maybe filter out onion if not on tor? # TODO maybe filter out onion if not on tor?
return random.choice(addr_list) 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) node_id, rest = extract_nodeid(connect_contents)
peer = self.peers.get(node_id) peer = self.peers.get(node_id)
if not peer: if not peer:
@ -231,7 +231,7 @@ class LNWorker(PrintError):
except socket.gaierror: except socket.gaierror:
raise ConnStringFormatError(_('Hostname does not resolve (getaddrinfo failed)')) raise ConnStringFormatError(_('Hostname does not resolve (getaddrinfo failed)'))
peer = self.add_peer(host, port, node_id) 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) f = asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop)
return f.result(timeout) return f.result(timeout)

Loading…
Cancel
Save