From b37262f2327c3cc30ffd2d5e9aab6163c79b75ac Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Fri, 21 Oct 2022 13:24:39 +0200 Subject: [PATCH] qml: proper check for max amount onchain. move max amount lightning to superclass --- electrum/gui/qml/components/InvoiceDialog.qml | 2 +- electrum/gui/qml/qeinvoice.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/electrum/gui/qml/components/InvoiceDialog.qml b/electrum/gui/qml/components/InvoiceDialog.qml index 9445b4b9b..639e92aaf 100644 --- a/electrum/gui/qml/components/InvoiceDialog.qml +++ b/electrum/gui/qml/components/InvoiceDialog.qml @@ -115,7 +115,7 @@ ElDialog { Label { width: parent.width - text: invoice.lnprops ? invoice.lnprops.pubkey : '' + text: 'pubkey' in invoice.lnprops ? invoice.lnprops.pubkey : '' font.family: FixedFont wrapMode: Text.Wrap } diff --git a/electrum/gui/qml/qeinvoice.py b/electrum/gui/qml/qeinvoice.py index 6eeb48324..9de060a9b 100644 --- a/electrum/gui/qml/qeinvoice.py +++ b/electrum/gui/qml/qeinvoice.py @@ -107,10 +107,13 @@ class QEInvoice(QObject): self.userinfoChanged.emit() def get_max_spendable_onchain(self): - c, u, x = self._wallet.wallet.get_balance() - #TODO determine real max - return c + spendable = self._wallet.confirmedBalance.satsInt + if not self._wallet.wallet.config.get('confirmed_only', False): + spendable += self._wallet.unconfirmedBalance.satsInt + return spendable + def get_max_spendable_lightning(self): + return self._wallet.wallet.lnworker.num_sats_can_send() class QEInvoiceParser(QEInvoice): @@ -303,9 +306,6 @@ 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 setValidOnchainInvoice(self, invoice: Invoice): self._logger.debug('setValidOnchainInvoice') if invoice.is_lightning():