1
0

qt: show warning on expired invoice on send tab.

Also disables Save button when invoice has expired.
This commit is contained in:
Sander van Grieken
2025-02-04 10:55:25 +01:00
parent 1cdb61d966
commit c2456892b4

View File

@@ -25,7 +25,7 @@ from electrum.submarine_swaps import SwapServerError
from .amountedit import AmountEdit, BTCAmountEdit, SizedFreezableLineEdit from .amountedit import AmountEdit, BTCAmountEdit, SizedFreezableLineEdit
from .paytoedit import InvalidPaymentIdentifier from .paytoedit import InvalidPaymentIdentifier
from .util import (WaitingDialog, HelpLabel, MessageBoxMixin, EnterButton, char_width_in_lineedit, from .util import (WaitingDialog, HelpLabel, MessageBoxMixin, EnterButton, char_width_in_lineedit,
get_iconname_camera, read_QIcon, ColorScheme, icon_path) get_iconname_camera, read_QIcon, ColorScheme, icon_path, IconLabel)
from .invoice_list import InvoiceList from .invoice_list import InvoiceList
if TYPE_CHECKING: if TYPE_CHECKING:
@@ -127,6 +127,11 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
self.max_button.setEnabled(False) self.max_button.setEnabled(False)
grid.addWidget(self.max_button, 3, 3) grid.addWidget(self.max_button, 3, 3)
invoice_error_icon = read_QIcon("warning.png")
self.invoice_error = IconLabel(reverse=True, hide_if_empty=True)
self.invoice_error.setIcon(invoice_error_icon)
grid.addWidget(self.invoice_error, 3, 4, Qt.AlignmentFlag.AlignRight)
self.paste_button = QPushButton() self.paste_button = QPushButton()
self.paste_button.clicked.connect(self.do_paste) self.paste_button.clicked.connect(self.do_paste)
self.paste_button.setIcon(read_QIcon('copy.png')) self.paste_button.setIcon(read_QIcon('copy.png'))
@@ -367,6 +372,7 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
w.setEnabled(False) w.setEnabled(False)
self.window.update_status() self.window.update_status()
self.paytomany_menu.setChecked(self.payto_e.multiline) self.paytomany_menu.setChecked(self.payto_e.multiline)
self.invoice_error.setText('')
run_hook('do_clear', self) run_hook('do_clear', self)
@@ -464,9 +470,11 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
amount_valid = is_spk_script or bool(self.amount_e.get_amount()) amount_valid = is_spk_script or bool(self.amount_e.get_amount())
self.send_button.setEnabled(not pi_unusable and amount_valid and not pi.has_expired()) self.send_button.setEnabled(not pi_unusable and amount_valid and not pi.has_expired())
self.save_button.setEnabled(not pi_unusable and not is_spk_script and \ self.save_button.setEnabled(not pi_unusable and not is_spk_script and not pi.has_expired() and \
pi.type not in [PaymentIdentifierType.LNURLP, PaymentIdentifierType.LNADDR]) pi.type not in [PaymentIdentifierType.LNURLP, PaymentIdentifierType.LNADDR])
self.invoice_error.setText(_('Expired') if pi.has_expired() else '')
def _handle_payment_identifier(self): def _handle_payment_identifier(self):
self.update_fields() self.update_fields()