1
0

(trivial) use util.get_asyncio_loop() in some places

This commit is contained in:
SomberNight
2023-04-13 23:08:02 +00:00
parent 488dc4871e
commit 2c1abf24fa
4 changed files with 12 additions and 12 deletions

View File

@@ -10,7 +10,7 @@ from electrum.lnutil import LOCAL, REMOTE, format_short_channel_id
from electrum.lnchannel import AbstractChannel, Channel, ChannelState, ChanCloseOption
from electrum.gui.kivy.i18n import _
from electrum.transaction import PartialTxOutput, Transaction
from electrum.util import NotEnoughFunds, NoDynamicFeeEstimates, format_fee_satoshis, quantize_feerate
from electrum.util import NotEnoughFunds, NoDynamicFeeEstimates, format_fee_satoshis, quantize_feerate, get_asyncio_loop
from electrum.lnutil import ln_dummy_address
from electrum.gui import messages
@@ -434,7 +434,7 @@ class ChannelBackupPopup(Popup, Logger):
def _request_force_close(self, b):
if not b:
return
loop = self.app.wallet.network.asyncio_loop
loop = get_asyncio_loop()
coro = asyncio.run_coroutine_threadsafe(self.app.wallet.lnworker.request_force_close(self.chan.channel_id), loop)
try:
coro.result(5)
@@ -527,7 +527,7 @@ class ChannelDetailsPopup(Popup, Logger):
dialog.open()
def _close(self, choice):
loop = self.app.wallet.network.asyncio_loop
loop = get_asyncio_loop()
if choice == 0:
coro = self.app.wallet.lnworker.close_channel(self.chan.channel_id)
msg = _('Channel closed')
@@ -600,7 +600,7 @@ class ChannelDetailsPopup(Popup, Logger):
def _do_force_close(self, b):
if not b:
return
loop = self.app.wallet.network.asyncio_loop
loop = get_asyncio_loop()
coro = asyncio.run_coroutine_threadsafe(self.app.wallet.lnworker.force_close_channel(self.chan.channel_id), loop)
try:
coro.result(1)

View File

@@ -15,7 +15,7 @@ from electrum.lnaddr import LnInvoiceException
from electrum.logging import get_logger
from electrum.transaction import PartialTxOutput
from electrum.util import (parse_URI, InvalidBitcoinURI, InvoiceError,
maybe_extract_lightning_payment_identifier)
maybe_extract_lightning_payment_identifier, get_asyncio_loop)
from electrum.lnutil import format_short_channel_id
from electrum.lnurl import decode_lnurl, request_lnurl, callback_lnurl
from electrum.bitcoin import COIN
@@ -582,7 +582,7 @@ class QEInvoiceParser(QEInvoice):
def resolve_task():
try:
coro = request_lnurl(url)
fut = asyncio.run_coroutine_threadsafe(coro, self._wallet.wallet.network.asyncio_loop)
fut = asyncio.run_coroutine_threadsafe(coro, get_asyncio_loop())
self.on_lnurl(fut.result())
except Exception as e:
self.validationError.emit('lnurl', repr(e))
@@ -629,7 +629,7 @@ class QEInvoiceParser(QEInvoice):
if comment:
params['comment'] = comment
coro = callback_lnurl(self._lnurlData['callback_url'], params)
fut = asyncio.run_coroutine_threadsafe(coro, self._wallet.wallet.network.asyncio_loop)
fut = asyncio.run_coroutine_threadsafe(coro, get_asyncio_loop())
self.on_lnurl_invoice(amount, fut.result())
except Exception as e:
self._logger.error(repr(e))

View File

@@ -9,7 +9,7 @@ from electrum.i18n import _
from electrum.lnutil import ln_dummy_address
from electrum.logging import get_logger
from electrum.transaction import PartialTxOutput
from electrum.util import NotEnoughFunds, NoDynamicFeeEstimates, profiler
from electrum.util import NotEnoughFunds, NoDynamicFeeEstimates, profiler, get_asyncio_loop
from .auth import AuthMixin, auth_protect
from .qetypes import QEAmount
@@ -346,7 +346,7 @@ class QESwapHelper(AuthMixin, QObject, QtEventListener):
assert self._tx
if lightning_amount is None or onchain_amount is None:
return
loop = self._wallet.wallet.network.asyncio_loop
loop = get_asyncio_loop()
coro = self._wallet.wallet.lnworker.swap_manager.normal_swap(
lightning_amount_sat=lightning_amount,
expected_onchain_amount_sat=onchain_amount,
@@ -376,7 +376,7 @@ class QESwapHelper(AuthMixin, QObject, QtEventListener):
if lightning_amount is None or onchain_amount is None:
return
swap_manager = self._wallet.wallet.lnworker.swap_manager
loop = self._wallet.wallet.network.asyncio_loop
loop = get_asyncio_loop()
coro = swap_manager.reverse_swap(
lightning_amount_sat=lightning_amount,
expected_onchain_amount_sat=onchain_amount + swap_manager.get_claim_fee(),

View File

@@ -13,7 +13,7 @@ from electrum.invoices import InvoiceError, PR_DEFAULT_EXPIRATION_WHEN_CREATING,
from electrum.logging import get_logger
from electrum.network import TxBroadcastError, BestEffortRequestFailed
from electrum.transaction import PartialTxOutput, PartialTransaction
from electrum.util import parse_max_spend, InvalidPassword, event_listener, AddTransactionException
from electrum.util import parse_max_spend, InvalidPassword, event_listener, AddTransactionException, get_asyncio_loop
from electrum.plugin import run_hook
from electrum.wallet import Multisig_Wallet
from electrum.crypto import pw_decode_with_version_and_mac
@@ -604,7 +604,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
def pay_thread():
try:
coro = self.wallet.lnworker.pay_invoice(invoice.lightning_invoice, amount_msat=amount_msat)
fut = asyncio.run_coroutine_threadsafe(coro, self.wallet.network.asyncio_loop)
fut = asyncio.run_coroutine_threadsafe(coro, get_asyncio_loop())
fut.result()
except Exception as e:
self.paymentFailed.emit(invoice.get_id(), repr(e))