Browse Source

qt main_window: fix threading for run_coroutine_from_thread

bip39-recovery
SomberNight 5 years ago
parent
commit
a74552f3dd
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 5
      electrum/gui/qt/main_window.py
  2. 3
      electrum/submarine_swaps.py

5
electrum/gui/qt/main_window.py

@ -158,6 +158,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
alias_received_signal = pyqtSignal()
computing_privkeys_signal = pyqtSignal()
show_privkeys_signal = pyqtSignal()
show_error_signal = pyqtSignal(str)
def __init__(self, gui_object: 'ElectrumGui', wallet: Abstract_Wallet):
QMainWindow.__init__(self)
@ -250,6 +251,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
self.payment_request_ok_signal.connect(self.payment_request_ok)
self.payment_request_error_signal.connect(self.payment_request_error)
self.show_error_signal.connect(self.show_error)
self.history_list.setFocus(True)
# network callbacks
@ -307,7 +309,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
if on_result:
on_result(r)
except Exception as e:
self.show_error(str(e))
self.logger.exception("exception in coro scheduled via window.wallet")
self.show_error_signal.emit(str(e))
self.wallet.thread.add(task)
def on_fx_history(self):

3
electrum/submarine_swaps.py

@ -183,7 +183,6 @@ class SwapManager(Logger):
callback = lambda: self._claim_swap(swap)
self.lnwatcher.add_callback(swap.lockup_address, callback)
@log_exceptions
async def normal_swap(self, lightning_amount: int, expected_onchain_amount: int,
password, *, tx: PartialTransaction = None) -> str:
"""send on-chain BTC, receive on Lightning"""
@ -264,7 +263,6 @@ class SwapManager(Logger):
await self.network.broadcast_transaction(tx)
return tx.txid()
@log_exceptions
async def reverse_swap(self, amount_sat: int, expected_amount: int) -> bool:
"""send on Lightning, receive on-chain"""
privkey = os.urandom(32)
@ -354,7 +352,6 @@ class SwapManager(Logger):
success, log = await self.lnworker._pay(invoice, attempts=10)
return success
@log_exceptions
async def get_pairs(self) -> None:
response = await self.network._send_http_on_proxy(
'get',

Loading…
Cancel
Save