mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
run open_channel in a WaitingDialog
This commit is contained in:
parent
12bc0a75f8
commit
591e85c087
3 changed files with 12 additions and 10 deletions
|
@ -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))
|
|
||||||
|
|
|
@ -1747,6 +1747,15 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
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())
|
||||||
|
|
|
@ -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…
Add table
Reference in a new issue