From ad04ca84d887a3188fa6b303300f090bc6397d0d Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Fri, 18 Nov 2022 18:32:43 +0100 Subject: [PATCH] qml: always try to generate an address for request regardless of bolt11_fallback config. --- electrum/gui/qml/components/WalletDetails.qml | 24 ++++++++----------- electrum/gui/qml/qewallet.py | 13 ++++------ electrum/invoices.py | 5 ++-- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/electrum/gui/qml/components/WalletDetails.qml b/electrum/gui/qml/components/WalletDetails.qml index 2b63421a8..1fd9cb7b9 100644 --- a/electrum/gui/qml/components/WalletDetails.qml +++ b/electrum/gui/qml/components/WalletDetails.qml @@ -13,6 +13,8 @@ Pane { padding: 0 + property bool _is2fa: Daemon.currentWallet && Daemon.currentWallet.walletType == '2fa' + function enableLightning() { var dialog = app.messageDialog.createObject(rootItem, {'text': qsTr('Enable Lightning for this wallet?'), 'yesno': true}) @@ -168,32 +170,33 @@ Pane { } GridLayout { - visible: Daemon.currentWallet && Daemon.currentWallet.walletType == '2fa' Layout.preferredWidth: parent.width - + visible: Daemon.currentWallet columns: 2 Label { + visible: _is2fa text: qsTr('2FA') color: Material.accentColor } Label { Layout.fillWidth: true + visible: _is2fa text: Daemon.currentWallet.canSignWithoutServer - ? qsTr('disabled (can sign without server') + ? qsTr('disabled (can sign without server)') : qsTr('enabled') } Label { - visible: !Daemon.currentWallet.canSignWithoutServer + visible: _is2fa && !Daemon.currentWallet.canSignWithoutServer text: qsTr('Remaining TX') color: Material.accentColor } Label { Layout.fillWidth: true - visible: !Daemon.currentWallet.canSignWithoutServer + visible: _is2fa && !Daemon.currentWallet.canSignWithoutServer text: 'tx_remaining' in Daemon.currentWallet.billingInfo ? Daemon.currentWallet.billingInfo['tx_remaining'] : qsTr('unknown') @@ -201,7 +204,7 @@ Pane { Label { Layout.columnSpan: 2 - visible: !Daemon.currentWallet.canSignWithoutServer + visible: _is2fa && !Daemon.currentWallet.canSignWithoutServer text: qsTr('Billing') color: Material.accentColor } @@ -209,6 +212,7 @@ Pane { TextHighlightPane { Layout.columnSpan: 2 Layout.fillWidth: true + visible: _is2fa && !Daemon.currentWallet.canSignWithoutServer ColumnLayout { spacing: 0 @@ -242,14 +246,6 @@ Pane { } } - } - - GridLayout { - id: detailsLayout - visible: Daemon.currentWallet - Layout.preferredWidth: parent.width - - columns: 2 Label { text: qsTr('Derivation prefix') visible: Daemon.currentWallet.derivationPrefix diff --git a/electrum/gui/qml/qewallet.py b/electrum/gui/qml/qewallet.py index d8b6612a5..33678b0de 100644 --- a/electrum/gui/qml/qewallet.py +++ b/electrum/gui/qml/qewallet.py @@ -607,19 +607,16 @@ class QEWallet(AuthMixin, QObject, QtEventListener): try: default_expiry = self.wallet.config.get('request_expiry', PR_DEFAULT_EXPIRATION_WHEN_CREATING) if self.wallet.lnworker and self.wallet.lnworker.channels: - addr = None - if self.wallet.config.get('bolt11_fallback', True): - addr = self.wallet.get_unused_address() - # if addr is None, we ran out of addresses - if addr is None: - # TODO: remove oldest unpaid request having a fallback address and try again - pass + addr = self.wallet.get_unused_address() + # if addr is None, we ran out of addresses + if addr is None: + # TODO: remove oldest unpaid request having a fallback address and try again + pass key = self.wallet.create_request(None, None, default_expiry, addr) else: key, addr = self.create_bitcoin_request(None, None, default_expiry, ignore_gap) if not key: return - # self.addressModel.init_model() except InvoiceError as e: self.requestCreateError.emit('fatal',_('Error creating payment request') + ':\n' + str(e)) return diff --git a/electrum/invoices.py b/electrum/invoices.py index 44d28c463..8bc9b5bea 100644 --- a/electrum/invoices.py +++ b/electrum/invoices.py @@ -122,9 +122,8 @@ class Invoice(StoredObject): address = None if self.outputs: address = self.outputs[0].address if len(self.outputs) > 0 else None - if not address: - if self.is_lightning(): - address = self._lnaddr.get_fallback_address() or None + if not address and self.is_lightning(): + address = self._lnaddr.get_fallback_address() or None return address def get_outputs(self):