Fix get_pending_swaps: use both funding and spending tx heights
Also, do not show closing warnings if we are offline.
This commit is contained in:
@@ -2699,7 +2699,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
|
|||||||
warning = ''.join([
|
warning = ''.join([
|
||||||
_("Are you sure you want to close Electrum?"),
|
_("Are you sure you want to close Electrum?"),
|
||||||
'\n\n',
|
'\n\n',
|
||||||
_("An ongoing operation prevents Electrum from closing:"),
|
_("An ongoing operation requires you to stay online."),
|
||||||
'\n',
|
'\n',
|
||||||
warning
|
warning
|
||||||
])
|
])
|
||||||
@@ -2734,6 +2734,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
|
|||||||
"""Callback that will return a warning string if there are unconfirmed swap funding txs."""
|
"""Callback that will return a warning string if there are unconfirmed swap funding txs."""
|
||||||
if not (self.wallet.has_lightning() and self.wallet.lnworker.swap_manager):
|
if not (self.wallet.has_lightning() and self.wallet.lnworker.swap_manager):
|
||||||
return None
|
return None
|
||||||
|
if not self.network:
|
||||||
|
return None
|
||||||
if ongoing_swaps := self.wallet.lnworker.swap_manager.get_pending_swaps():
|
if ongoing_swaps := self.wallet.lnworker.swap_manager.get_pending_swaps():
|
||||||
return "".join((
|
return "".join((
|
||||||
f"{str(len(ongoing_swaps))} ",
|
f"{str(len(ongoing_swaps))} ",
|
||||||
|
|||||||
@@ -1283,11 +1283,11 @@ class SwapManager(Logger):
|
|||||||
"""Returns a list of swaps with unconfirmed funding tx (which require us to stay online)."""
|
"""Returns a list of swaps with unconfirmed funding tx (which require us to stay online)."""
|
||||||
pending_swaps: List[SwapData] = []
|
pending_swaps: List[SwapData] = []
|
||||||
for swap in self.swaps.values():
|
for swap in self.swaps.values():
|
||||||
if swap.funding_txid and not swap.is_redeemed:
|
# note: adb.get_tx_height returns TX_HEIGHT_LOCAL if the txid is unknown
|
||||||
# swap is funded but not marked redeemed by _claim_swap
|
funding_height = self.lnworker.wallet.adb.get_tx_height(swap.funding_txid).height
|
||||||
if self.lnworker.wallet.adb.get_tx_height(swap.funding_txid).height < 1:
|
spending_height = self.lnworker.wallet.adb.get_tx_height(swap.spending_txid).height
|
||||||
# funding TX is not yet confirmed, wallet should not be closed
|
if funding_height > TX_HEIGHT_LOCAL and spending_height <= TX_HEIGHT_LOCAL:
|
||||||
pending_swaps.append(swap)
|
pending_swaps.append(swap)
|
||||||
return pending_swaps
|
return pending_swaps
|
||||||
|
|
||||||
class SwapServerTransport(Logger):
|
class SwapServerTransport(Logger):
|
||||||
|
|||||||
Reference in New Issue
Block a user