Qt: improve closing warnings for submarine swaps
This commit is contained in:
@@ -74,6 +74,16 @@ MSG_REVERSE_SWAP_FUNDING_MEMPOOL = (
|
|||||||
"you will not get back the already pre-paid mining fees.")
|
"you will not get back the already pre-paid mining fees.")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
MSG_FORWARD_SWAP_WARNING = (
|
||||||
|
_('You will need to come back online after the funding transaction is confirmed, in order to settle the swap.') + ' ' +
|
||||||
|
_('If you remain offline for more than {} blocks, your channel will be force closed and you might lose the funds you sent in the swap.')
|
||||||
|
)
|
||||||
|
|
||||||
|
MSG_REVERSE_SWAP_WARNING = (
|
||||||
|
_('You will need to come back online after the funding transaction is confirmed, in order to settle the swap.') + ' ' +
|
||||||
|
_('If you remain offline for more than {} blocks, the swap will be cancelled and you will lose the prepaid mining fees.')
|
||||||
|
)
|
||||||
|
|
||||||
MSG_LN_UTXO_RESERVE = (
|
MSG_LN_UTXO_RESERVE = (
|
||||||
_("You do not have enough on-chain funds to protect your Lightning channels.") + ' ' +
|
_("You do not have enough on-chain funds to protect your Lightning channels.") + ' ' +
|
||||||
_("You should have at least {} on-chain in order to be able to sweep channel outputs.")
|
_("You should have at least {} on-chain in order to be able to sweep channel outputs.")
|
||||||
|
|||||||
@@ -2732,21 +2732,29 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
|
|||||||
|
|
||||||
def _check_ongoing_submarine_swaps_callback(self) -> Optional[str]:
|
def _check_ongoing_submarine_swaps_callback(self) -> Optional[str]:
|
||||||
"""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."""
|
||||||
|
from electrum.submarine_swaps import MIN_FINAL_CLTV_DELTA_FOR_CLIENT, LOCKTIME_DELTA_REFUND
|
||||||
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:
|
if not self.network:
|
||||||
return None
|
return None
|
||||||
if ongoing_swaps := self.wallet.lnworker.swap_manager.get_pending_swaps():
|
ongoing_swaps = self.wallet.lnworker.swap_manager.get_pending_swaps()
|
||||||
return "".join((
|
if not ongoing_swaps:
|
||||||
f"{str(len(ongoing_swaps))} ",
|
return None
|
||||||
_("pending submarine swap") if len(ongoing_swaps) == 1 else _("pending submarine swaps"),
|
is_forward = any(not swap.is_reverse for swap in ongoing_swaps)
|
||||||
":\n",
|
if is_forward:
|
||||||
_("Wait until the funding transaction of your swap confirms, otherwise you risk losing your"),
|
# fixme: this is inaccurate, we need local_height - cltv_of_htlc
|
||||||
" ",
|
delta = MIN_FINAL_CLTV_DELTA_FOR_CLIENT
|
||||||
_("funds") if any(not swap.is_reverse for swap in ongoing_swaps) else _("mining fee prepayment"),
|
warning = messages.MSG_FORWARD_SWAP_WARNING.format(delta)
|
||||||
".",
|
else:
|
||||||
))
|
locktime = min(swap.locktime for swap in ongoing_swaps)
|
||||||
return None
|
delta = locktime - self.wallet.adb.get_local_height()
|
||||||
|
warning = messages.MSG_REVERSE_SWAP_WARNING.format(delta)
|
||||||
|
return "".join((
|
||||||
|
f"{str(len(ongoing_swaps))} ",
|
||||||
|
_("pending submarine swap") if len(ongoing_swaps) == 1 else _("pending submarine swaps"),
|
||||||
|
"\n\n",
|
||||||
|
warning,
|
||||||
|
))
|
||||||
|
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
# note that closeEvent is NOT called if the user quits with Ctrl-C
|
# note that closeEvent is NOT called if the user quits with Ctrl-C
|
||||||
|
|||||||
Reference in New Issue
Block a user