(trivial) use util.get_asyncio_loop() in some places
This commit is contained in:
@@ -10,7 +10,7 @@ from electrum.lnutil import LOCAL, REMOTE, format_short_channel_id
|
|||||||
from electrum.lnchannel import AbstractChannel, Channel, ChannelState, ChanCloseOption
|
from electrum.lnchannel import AbstractChannel, Channel, ChannelState, ChanCloseOption
|
||||||
from electrum.gui.kivy.i18n import _
|
from electrum.gui.kivy.i18n import _
|
||||||
from electrum.transaction import PartialTxOutput, Transaction
|
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.lnutil import ln_dummy_address
|
||||||
from electrum.gui import messages
|
from electrum.gui import messages
|
||||||
|
|
||||||
@@ -434,7 +434,7 @@ class ChannelBackupPopup(Popup, Logger):
|
|||||||
def _request_force_close(self, b):
|
def _request_force_close(self, b):
|
||||||
if not b:
|
if not b:
|
||||||
return
|
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)
|
coro = asyncio.run_coroutine_threadsafe(self.app.wallet.lnworker.request_force_close(self.chan.channel_id), loop)
|
||||||
try:
|
try:
|
||||||
coro.result(5)
|
coro.result(5)
|
||||||
@@ -527,7 +527,7 @@ class ChannelDetailsPopup(Popup, Logger):
|
|||||||
dialog.open()
|
dialog.open()
|
||||||
|
|
||||||
def _close(self, choice):
|
def _close(self, choice):
|
||||||
loop = self.app.wallet.network.asyncio_loop
|
loop = get_asyncio_loop()
|
||||||
if choice == 0:
|
if choice == 0:
|
||||||
coro = self.app.wallet.lnworker.close_channel(self.chan.channel_id)
|
coro = self.app.wallet.lnworker.close_channel(self.chan.channel_id)
|
||||||
msg = _('Channel closed')
|
msg = _('Channel closed')
|
||||||
@@ -600,7 +600,7 @@ class ChannelDetailsPopup(Popup, Logger):
|
|||||||
def _do_force_close(self, b):
|
def _do_force_close(self, b):
|
||||||
if not b:
|
if not b:
|
||||||
return
|
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)
|
coro = asyncio.run_coroutine_threadsafe(self.app.wallet.lnworker.force_close_channel(self.chan.channel_id), loop)
|
||||||
try:
|
try:
|
||||||
coro.result(1)
|
coro.result(1)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ from electrum.lnaddr import LnInvoiceException
|
|||||||
from electrum.logging import get_logger
|
from electrum.logging import get_logger
|
||||||
from electrum.transaction import PartialTxOutput
|
from electrum.transaction import PartialTxOutput
|
||||||
from electrum.util import (parse_URI, InvalidBitcoinURI, InvoiceError,
|
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.lnutil import format_short_channel_id
|
||||||
from electrum.lnurl import decode_lnurl, request_lnurl, callback_lnurl
|
from electrum.lnurl import decode_lnurl, request_lnurl, callback_lnurl
|
||||||
from electrum.bitcoin import COIN
|
from electrum.bitcoin import COIN
|
||||||
@@ -582,7 +582,7 @@ class QEInvoiceParser(QEInvoice):
|
|||||||
def resolve_task():
|
def resolve_task():
|
||||||
try:
|
try:
|
||||||
coro = request_lnurl(url)
|
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())
|
self.on_lnurl(fut.result())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.validationError.emit('lnurl', repr(e))
|
self.validationError.emit('lnurl', repr(e))
|
||||||
@@ -629,7 +629,7 @@ class QEInvoiceParser(QEInvoice):
|
|||||||
if comment:
|
if comment:
|
||||||
params['comment'] = comment
|
params['comment'] = comment
|
||||||
coro = callback_lnurl(self._lnurlData['callback_url'], params)
|
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())
|
self.on_lnurl_invoice(amount, fut.result())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.error(repr(e))
|
self._logger.error(repr(e))
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from electrum.i18n import _
|
|||||||
from electrum.lnutil import ln_dummy_address
|
from electrum.lnutil import ln_dummy_address
|
||||||
from electrum.logging import get_logger
|
from electrum.logging import get_logger
|
||||||
from electrum.transaction import PartialTxOutput
|
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 .auth import AuthMixin, auth_protect
|
||||||
from .qetypes import QEAmount
|
from .qetypes import QEAmount
|
||||||
@@ -346,7 +346,7 @@ class QESwapHelper(AuthMixin, QObject, QtEventListener):
|
|||||||
assert self._tx
|
assert self._tx
|
||||||
if lightning_amount is None or onchain_amount is None:
|
if lightning_amount is None or onchain_amount is None:
|
||||||
return
|
return
|
||||||
loop = self._wallet.wallet.network.asyncio_loop
|
loop = get_asyncio_loop()
|
||||||
coro = self._wallet.wallet.lnworker.swap_manager.normal_swap(
|
coro = self._wallet.wallet.lnworker.swap_manager.normal_swap(
|
||||||
lightning_amount_sat=lightning_amount,
|
lightning_amount_sat=lightning_amount,
|
||||||
expected_onchain_amount_sat=onchain_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:
|
if lightning_amount is None or onchain_amount is None:
|
||||||
return
|
return
|
||||||
swap_manager = self._wallet.wallet.lnworker.swap_manager
|
swap_manager = self._wallet.wallet.lnworker.swap_manager
|
||||||
loop = self._wallet.wallet.network.asyncio_loop
|
loop = get_asyncio_loop()
|
||||||
coro = swap_manager.reverse_swap(
|
coro = swap_manager.reverse_swap(
|
||||||
lightning_amount_sat=lightning_amount,
|
lightning_amount_sat=lightning_amount,
|
||||||
expected_onchain_amount_sat=onchain_amount + swap_manager.get_claim_fee(),
|
expected_onchain_amount_sat=onchain_amount + swap_manager.get_claim_fee(),
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from electrum.invoices import InvoiceError, PR_DEFAULT_EXPIRATION_WHEN_CREATING,
|
|||||||
from electrum.logging import get_logger
|
from electrum.logging import get_logger
|
||||||
from electrum.network import TxBroadcastError, BestEffortRequestFailed
|
from electrum.network import TxBroadcastError, BestEffortRequestFailed
|
||||||
from electrum.transaction import PartialTxOutput, PartialTransaction
|
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.plugin import run_hook
|
||||||
from electrum.wallet import Multisig_Wallet
|
from electrum.wallet import Multisig_Wallet
|
||||||
from electrum.crypto import pw_decode_with_version_and_mac
|
from electrum.crypto import pw_decode_with_version_and_mac
|
||||||
@@ -604,7 +604,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
|||||||
def pay_thread():
|
def pay_thread():
|
||||||
try:
|
try:
|
||||||
coro = self.wallet.lnworker.pay_invoice(invoice.lightning_invoice, amount_msat=amount_msat)
|
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()
|
fut.result()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.paymentFailed.emit(invoice.get_id(), repr(e))
|
self.paymentFailed.emit(invoice.get_id(), repr(e))
|
||||||
|
|||||||
Reference in New Issue
Block a user