ThomasV
6 years ago
committed by
SomberNight
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
3 changed files with
12 additions and
10 deletions
-
electrum/gui/qt/channels_list.py
-
electrum/gui/qt/main_window.py
-
electrum/lnworker.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) |
|
|
|
|
|
@ -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()) |
|
|
|
|
|
@ -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) |
|
|
|
|
|
|
|