Browse Source

Qt receive widgets: do not show request that have expired

They may still be retrieved from the menu
patch-4
ThomasV 3 years ago
parent
commit
1915330039
  1. 12
      electrum/gui/qt/main_window.py

12
electrum/gui/qt/main_window.py

@ -67,7 +67,7 @@ from electrum.util import (format_time,
AddTransactionException, BITCOIN_BIP21_URI_SCHEME,
InvoiceError, parse_max_spend)
from electrum.invoices import PR_DEFAULT_EXPIRATION_WHEN_CREATING, Invoice
from electrum.invoices import PR_PAID, PR_UNPAID, PR_FAILED, pr_expiration_values, Invoice
from electrum.invoices import PR_PAID, PR_UNPAID, PR_FAILED, PR_EXPIRED, pr_expiration_values, Invoice
from electrum.transaction import (Transaction, PartialTxInput,
PartialTransaction, PartialTxOutput)
from electrum.wallet import (Multisig_Wallet, CannotBumpFee, Abstract_Wallet,
@ -1317,12 +1317,19 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
addr = req.get_address() or ''
amount_sat = req.get_amount_sat() or 0
address_help = '' if addr else _('Amount too small to be received onchain')
URI_help = ''
lnaddr = req.lightning_invoice
bip21_lightning = lnaddr if self.config.get('bip21_lightning', False) else None
URI = req.get_bip21_URI(lightning=bip21_lightning)
lightning_online = self.wallet.lnworker and self.wallet.lnworker.num_peers() > 0
can_receive_lightning = self.wallet.lnworker and amount_sat <= self.wallet.lnworker.num_sats_can_receive()
if lnaddr is None:
has_expired = self.wallet.get_request_status(key) == PR_EXPIRED
if has_expired:
URI_help = ln_help = address_help = _('This request has expired')
URI = lnaddr = address = ''
can_rebalance = False
can_swap = False
elif lnaddr is None:
ln_help = _('This request does not have a Lightning invoice.')
lnaddr = ''
can_rebalance = False
@ -1362,6 +1369,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
self.receive_address_help_text.setText(address_help)
self.receive_URI_e.setText(URI)
self.receive_URI_qr.setData(URI)
self.receive_URI_help.setText(URI_help)
self.receive_lightning_e.setText(lnaddr) # TODO maybe prepend "lightning:" ??
self.receive_lightning_help_text.setText(ln_help)
self.receive_lightning_qr.setData(lnaddr_qr)

Loading…
Cancel
Save