Merge pull request #8944 from SomberNight/202403_swap_messages
swaps: homogenise gui messages
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from electrum.i18n import _
|
||||
from electrum.submarine_swaps import MIN_FINAL_CLTV_DELTA_FOR_CLIENT
|
||||
|
||||
|
||||
def to_rtf(msg):
|
||||
@@ -47,3 +48,22 @@ If you want to keep using this channel, you need to disable trampoline routing i
|
||||
|
||||
MSG_FREEZE_ADDRESS = _("When you freeze an address, the funds in that address will not be used for sending bitcoins.")
|
||||
MSG_FREEZE_COIN = _("When you freeze a coin, it will not be used for sending bitcoins.")
|
||||
|
||||
MSG_FORWARD_SWAP_FUNDING_MEMPOOL = (
|
||||
_('Your funding transaction has been broadcast.') + " " +
|
||||
_('The swap will be finalized once your transaction is confirmed.') + " " +
|
||||
_("After the funding transaction is mined, the server will reveal the preimage needed to "
|
||||
"fulfill the pending received lightning HTLCs. The HTLCs expire in {} blocks. "
|
||||
"You will need to be online after the funding transaction is confirmed but before the HTLCs expire, "
|
||||
"to claim your money. If you go offline for several days while the swap is pending, "
|
||||
"you risk losing the swap amount!").format(MIN_FINAL_CLTV_DELTA_FOR_CLIENT) + " " +
|
||||
_("Please remain online until the funding transaction is confirmed.")
|
||||
)
|
||||
|
||||
MSG_REVERSE_SWAP_FUNDING_MEMPOOL = (
|
||||
_('The funding transaction has been detected.') + " " +
|
||||
_('Your claiming transaction will be broadcast when the funding transaction is confirmed.') + " " +
|
||||
_('You may choose to broadcast it earlier, although that would not be trustless.') + " " +
|
||||
_("If you go offline before broadcasting the claiming transaction and let the swap time out, "
|
||||
"you will not get back the already pre-paid mining fees.")
|
||||
)
|
||||
|
||||
@@ -12,6 +12,8 @@ from electrum.logging import get_logger
|
||||
from electrum.transaction import PartialTxOutput, PartialTransaction
|
||||
from electrum.util import NotEnoughFunds, NoDynamicFeeEstimates, profiler, get_asyncio_loop
|
||||
|
||||
from electrum.gui import messages
|
||||
|
||||
from .auth import AuthMixin, auth_protect
|
||||
from .qetypes import QEAmount
|
||||
from .qewallet import QEWallet
|
||||
@@ -386,9 +388,7 @@ class QESwapHelper(AuthMixin, QObject, QtEventListener):
|
||||
try: # swaphelper might be destroyed at this point
|
||||
self.userinfo = ' '.join([
|
||||
_('Success!'),
|
||||
_('Your funding transaction has been broadcast.'),
|
||||
_('The swap will be finalized once your transaction is confirmed.'),
|
||||
_('You will need to be online to finalize the swap, or the transaction will be refunded to you after some delay.'),
|
||||
messages.MSG_FORWARD_SWAP_FUNDING_MEMPOOL,
|
||||
])
|
||||
self.state = QESwapHelper.State.Success
|
||||
except RuntimeError:
|
||||
@@ -459,9 +459,7 @@ class QESwapHelper(AuthMixin, QObject, QtEventListener):
|
||||
if txid:
|
||||
self.userinfo = ' '.join([
|
||||
_('Success!'),
|
||||
_('The funding transaction has been detected.'),
|
||||
_('Your claiming transaction will be broadcast when the funding transaction is confirmed.'),
|
||||
_('You may choose to broadcast it earlier, although that would not be trustless.'),
|
||||
messages.MSG_REVERSE_SWAP_FUNDING_MEMPOOL,
|
||||
])
|
||||
self.state = QESwapHelper.State.Success
|
||||
else:
|
||||
|
||||
@@ -2686,14 +2686,17 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
|
||||
d = RebalanceDialog(self, chan1, chan2, amount_sat)
|
||||
d.run()
|
||||
|
||||
def on_swap_result(self, txid):
|
||||
def on_swap_result(self, txid: Optional[str], *, is_reverse: bool):
|
||||
msg = _("Submarine swap") + ': ' + (_("Success") if txid else _("Expired")) + '\n\n'
|
||||
if txid:
|
||||
msg += _("Funding transaction") + ': ' + txid + '\n'
|
||||
msg += _("Please remain online until the funding transaction is confirmed.")
|
||||
msg += _("Funding transaction") + ': ' + txid + '\n\n'
|
||||
if is_reverse:
|
||||
msg += messages.MSG_REVERSE_SWAP_FUNDING_MEMPOOL
|
||||
else:
|
||||
msg += messages.MSG_FORWARD_SWAP_FUNDING_MEMPOOL
|
||||
self.show_message_signal.emit(msg)
|
||||
else:
|
||||
msg += _("Lightning funds were not received.")
|
||||
msg += _("Lightning funds were not received.") # FIXME should this not depend on is_reverse?
|
||||
self.show_error_signal.emit(msg)
|
||||
|
||||
def set_payment_identifier(self, pi: str):
|
||||
|
||||
@@ -741,7 +741,7 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
|
||||
coro = sm.wait_for_htlcs_and_broadcast(swap=swap, invoice=tx.swap_invoice, tx=tx)
|
||||
self.window.run_coroutine_dialog(
|
||||
coro, _('Awaiting swap payment...'),
|
||||
on_result=self.window.on_swap_result,
|
||||
on_result=lambda funding_txid: self.window.on_swap_result(funding_txid, is_reverse=False),
|
||||
on_cancelled=lambda: sm.cancel_normal_swap(swap))
|
||||
return
|
||||
|
||||
|
||||
@@ -255,7 +255,10 @@ class SwapDialog(WindowModalDialog, QtEventListener):
|
||||
lightning_amount_sat=lightning_amount,
|
||||
expected_onchain_amount_sat=onchain_amount + self.swap_manager.get_claim_fee(),
|
||||
)
|
||||
self.window.run_coroutine_from_thread(coro, _('Swapping funds'), on_result=self.window.on_swap_result)
|
||||
self.window.run_coroutine_from_thread(
|
||||
coro, _('Swapping funds'),
|
||||
on_result=lambda funding_txid: self.window.on_swap_result(funding_txid, is_reverse=True),
|
||||
)
|
||||
return True
|
||||
else:
|
||||
lightning_amount = self.recv_amount_e.get_amount()
|
||||
@@ -334,7 +337,7 @@ class SwapDialog(WindowModalDialog, QtEventListener):
|
||||
coro2 = sm.wait_for_htlcs_and_broadcast(swap=swap, invoice=invoice, tx=tx)
|
||||
self.window.run_coroutine_dialog(
|
||||
coro2, _('Awaiting swap payment...'),
|
||||
on_result=self.window.on_swap_result,
|
||||
on_result=lambda funding_txid: self.window.on_swap_result(funding_txid, is_reverse=False),
|
||||
on_cancelled=lambda: sm.cancel_normal_swap(swap))
|
||||
|
||||
def get_description(self):
|
||||
|
||||
Reference in New Issue
Block a user