From c2456892b43d3552c14ba68bac5e5832a97ed14a Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Tue, 4 Feb 2025 10:55:25 +0100 Subject: [PATCH] qt: show warning on expired invoice on send tab. Also disables Save button when invoice has expired. --- electrum/gui/qt/send_tab.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/electrum/gui/qt/send_tab.py b/electrum/gui/qt/send_tab.py index 402dd729b..a87d9e1b1 100644 --- a/electrum/gui/qt/send_tab.py +++ b/electrum/gui/qt/send_tab.py @@ -25,7 +25,7 @@ from electrum.submarine_swaps import SwapServerError from .amountedit import AmountEdit, BTCAmountEdit, SizedFreezableLineEdit from .paytoedit import InvalidPaymentIdentifier 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 if TYPE_CHECKING: @@ -127,6 +127,11 @@ class SendTab(QWidget, MessageBoxMixin, Logger): self.max_button.setEnabled(False) 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.clicked.connect(self.do_paste) self.paste_button.setIcon(read_QIcon('copy.png')) @@ -367,6 +372,7 @@ class SendTab(QWidget, MessageBoxMixin, Logger): w.setEnabled(False) self.window.update_status() self.paytomany_menu.setChecked(self.payto_e.multiline) + self.invoice_error.setText('') 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()) 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]) + self.invoice_error.setText(_('Expired') if pi.has_expired() else '') + def _handle_payment_identifier(self): self.update_fields()