diff --git a/electrum_grs/gui/qml/qetxdetails.py b/electrum_grs/gui/qml/qetxdetails.py index 6df334ecbc68..2e65df6ca916 100644 --- a/electrum_grs/gui/qml/qetxdetails.py +++ b/electrum_grs/gui/qml/qetxdetails.py @@ -260,7 +260,7 @@ def update(self, from_txid: bool = False): if from_txid: self._tx = self._wallet.wallet.db.get_transaction(self._txid) - assert self._tx is not None + assert self._tx is not None, f'unknown txid "{self._txid}"' #self._logger.debug(repr(self._tx.to_json())) diff --git a/electrum_grs/lnworker.py b/electrum_grs/lnworker.py index 3df063964a5b..d64606fe30da 100644 --- a/electrum_grs/lnworker.py +++ b/electrum_grs/lnworker.py @@ -278,7 +278,6 @@ async def cb(reader, writer): except OSError as e: self.logger.error(f"cannot listen for lightning p2p. error: {e!r}") - @ignore_exceptions # don't kill outer taskgroup async def main_loop(self): self.logger.info("starting taskgroup.") try: @@ -937,6 +936,8 @@ async def stop(self): if self.lnwatcher: await self.lnwatcher.stop() self.lnwatcher = None + if self.swap_manager: # may not be present in tests + await self.swap_manager.stop() async def wait_for_received_pending_htlcs_to_get_removed(self): assert self.stopping_soon is True diff --git a/electrum_grs/plugins/swapserver/qt.py b/electrum_grs/plugins/swapserver/qt.py deleted file mode 100644 index 7add7a3861c7..000000000000 --- a/electrum_grs/plugins/swapserver/qt.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python -# -# Electrum - Lightweight Bitcoin Client -# Copyright (C) 2023 The Electrum Developers -# -# Permission is hereby granted, free of charge, to any person -# obtaining a copy of this software and associated documentation files -# (the "Software"), to deal in the Software without restriction, -# including without limitation the rights to use, copy, modify, merge, -# publish, distribute, sublicense, and/or sell copies of the Software, -# and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - - -from .swapserver import SwapServerPlugin - -class Plugin(SwapServerPlugin): - pass - diff --git a/electrum_grs/plugins/trustedcoin/trustedcoin.py b/electrum_grs/plugins/trustedcoin/trustedcoin.py index 03d113695791..7dba0279b611 100644 --- a/electrum_grs/plugins/trustedcoin/trustedcoin.py +++ b/electrum_grs/plugins/trustedcoin/trustedcoin.py @@ -393,8 +393,6 @@ def add_new_billing_address(self, billing_index: int, address: str, addr_type: s self._billing_addresses[addr_type] = billing_addresses_of_this_type self.db.put('trustedcoin_billing_addresses', self._billing_addresses['legacy']) self.db.put('trustedcoin_billing_addresses_segwit', self._billing_addresses['segwit']) - # FIXME this often runs in a daemon thread, where storage.write will fail - self.db.write() def is_billing_address(self, addr: str) -> bool: return addr in self._billing_addresses_set diff --git a/electrum_grs/submarine_swaps.py b/electrum_grs/submarine_swaps.py index 801880933be5..0abca4db3303 100644 --- a/electrum_grs/submarine_swaps.py +++ b/electrum_grs/submarine_swaps.py @@ -207,8 +207,20 @@ def start_network(self, *, network: 'Network', lnwatcher: 'LNWalletWatcher'): self.add_lnwatcher_callback(swap) self.taskgroup = OldTaskGroup() - coro = self.pay_pending_invoices() - asyncio.run_coroutine_threadsafe(self.taskgroup.spawn(coro), self.network.asyncio_loop) + asyncio.run_coroutine_threadsafe(self.main_loop(), self.network.asyncio_loop) + + async def main_loop(self): + self.logger.info("starting taskgroup.") + try: + async with self.taskgroup as group: + await group.spawn(self.pay_pending_invoices()) + except Exception as e: + self.logger.exception("taskgroup died.") + finally: + self.logger.info("taskgroup stopped.") + + async def stop(self): + await self.taskgroup.cancel_remaining() async def pay_invoice(self, key): self.logger.info(f'trying to pay invoice {key}') diff --git a/electrum_grs/tests/test_lnpeer.py b/electrum_grs/tests/test_lnpeer.py index e39ee9af7317..70278dfb39b3 100644 --- a/electrum_grs/tests/test_lnpeer.py +++ b/electrum_grs/tests/test_lnpeer.py @@ -147,6 +147,7 @@ def __init__(self, *, local_keypair: Keypair, chans: Iterable['Channel'], tx_que self.network = MockNetwork(tx_queue, config=self.config) self.taskgroup = OldTaskGroup() self.lnwatcher = None + self.swap_manager = None self.listen_server = None self._channels = {chan.channel_id: chan for chan in chans} self.payment_info = {} diff --git a/electrum_grs/wallet.py b/electrum_grs/wallet.py index 13bbcc57e2d4..e4b9c0c9749a 100644 --- a/electrum_grs/wallet.py +++ b/electrum_grs/wallet.py @@ -452,7 +452,6 @@ def __init__(self, db: WalletDB, *, config: SimpleConfig): def _init_lnworker(self): self.lnworker = None - @ignore_exceptions # don't kill outer taskgroup async def main_loop(self): self.logger.info("starting taskgroup.") try: