From a1fac70ebc7521fb3c71509e7f5624ce38646aca Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Fri, 21 Oct 2022 13:01:45 +0200 Subject: [PATCH] qml: fix bug with lingering info text from previous shown invoice --- electrum/gui/qml/components/InvoiceDialog.qml | 1 + electrum/gui/qml/qeinvoice.py | 21 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/electrum/gui/qml/components/InvoiceDialog.qml b/electrum/gui/qml/components/InvoiceDialog.qml index c01dc69c1..9445b4b9b 100644 --- a/electrum/gui/qml/components/InvoiceDialog.qml +++ b/electrum/gui/qml/components/InvoiceDialog.qml @@ -296,6 +296,7 @@ ElDialog { InfoTextArea { Layout.columnSpan: 2 Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: parent.width * 3/4 visible: invoice.userinfo text: invoice.userinfo } diff --git a/electrum/gui/qml/qeinvoice.py b/electrum/gui/qml/qeinvoice.py index 8672d7f6b..6eeb48324 100644 --- a/electrum/gui/qml/qeinvoice.py +++ b/electrum/gui/qml/qeinvoice.py @@ -265,8 +265,10 @@ class QEInvoiceParser(QEInvoice): self.statusChanged.emit() def determine_can_pay(self): - if self.amount.satsInt == 0: - self.canPay = False + self.canPay = False + self.userinfo = '' + + if self.amount.isEmpty: # unspecified amount return if self.invoiceType == QEInvoice.Type.LightningInvoice: @@ -274,7 +276,7 @@ class QEInvoiceParser(QEInvoice): if self.get_max_spendable_lightning() >= self.amount.satsInt: self.canPay = True else: - self.userinfo = _('Can\'t pay, insufficient balance') + self.userinfo = _('Insufficient balance') else: self.userinfo = { PR_EXPIRED: _('Invoice is expired'), @@ -285,7 +287,11 @@ class QEInvoiceParser(QEInvoice): }[self.status] elif self.invoiceType == QEInvoice.Type.OnchainInvoice: if self.status in [PR_UNPAID, PR_FAILED]: - if self.get_max_spendable_onchain() >= self.amount.satsInt: + if self.amount.isMax and self.get_max_spendable_onchain() > 0: + # TODO: dust limit? + self.canPay = True + elif self.get_max_spendable_onchain() >= self.amount.satsInt: + # TODO: dust limit? self.canPay = True else: self.userinfo = _('Insufficient balance') @@ -297,16 +303,9 @@ class QEInvoiceParser(QEInvoice): PR_UNKNOWN: _('Invoice has unknown status'), }[self.status] - def get_max_spendable_lightning(self): return self._wallet.wallet.lnworker.num_sats_can_send() - # def setValidAddressOnly(self): - # self._logger.debug('setValidAddressOnly') - # self.setInvoiceType(QEInvoice.Type.OnchainOnlyAddress) - # self._effectiveInvoice = None - # self.invoiceChanged.emit() - def setValidOnchainInvoice(self, invoice: Invoice): self._logger.debug('setValidOnchainInvoice') if invoice.is_lightning():