Browse Source

qml: always try to generate an address for request regardless of bolt11_fallback config.

patch-4
Sander van Grieken 2 years ago
parent
commit
ad04ca84d8
  1. 24
      electrum/gui/qml/components/WalletDetails.qml
  2. 13
      electrum/gui/qml/qewallet.py
  3. 5
      electrum/invoices.py

24
electrum/gui/qml/components/WalletDetails.qml

@ -13,6 +13,8 @@ Pane {
padding: 0 padding: 0
property bool _is2fa: Daemon.currentWallet && Daemon.currentWallet.walletType == '2fa'
function enableLightning() { function enableLightning() {
var dialog = app.messageDialog.createObject(rootItem, var dialog = app.messageDialog.createObject(rootItem,
{'text': qsTr('Enable Lightning for this wallet?'), 'yesno': true}) {'text': qsTr('Enable Lightning for this wallet?'), 'yesno': true})
@ -168,32 +170,33 @@ Pane {
} }
GridLayout { GridLayout {
visible: Daemon.currentWallet && Daemon.currentWallet.walletType == '2fa'
Layout.preferredWidth: parent.width Layout.preferredWidth: parent.width
visible: Daemon.currentWallet
columns: 2 columns: 2
Label { Label {
visible: _is2fa
text: qsTr('2FA') text: qsTr('2FA')
color: Material.accentColor color: Material.accentColor
} }
Label { Label {
Layout.fillWidth: true Layout.fillWidth: true
visible: _is2fa
text: Daemon.currentWallet.canSignWithoutServer text: Daemon.currentWallet.canSignWithoutServer
? qsTr('disabled (can sign without server') ? qsTr('disabled (can sign without server)')
: qsTr('enabled') : qsTr('enabled')
} }
Label { Label {
visible: !Daemon.currentWallet.canSignWithoutServer visible: _is2fa && !Daemon.currentWallet.canSignWithoutServer
text: qsTr('Remaining TX') text: qsTr('Remaining TX')
color: Material.accentColor color: Material.accentColor
} }
Label { Label {
Layout.fillWidth: true Layout.fillWidth: true
visible: !Daemon.currentWallet.canSignWithoutServer visible: _is2fa && !Daemon.currentWallet.canSignWithoutServer
text: 'tx_remaining' in Daemon.currentWallet.billingInfo text: 'tx_remaining' in Daemon.currentWallet.billingInfo
? Daemon.currentWallet.billingInfo['tx_remaining'] ? Daemon.currentWallet.billingInfo['tx_remaining']
: qsTr('unknown') : qsTr('unknown')
@ -201,7 +204,7 @@ Pane {
Label { Label {
Layout.columnSpan: 2 Layout.columnSpan: 2
visible: !Daemon.currentWallet.canSignWithoutServer visible: _is2fa && !Daemon.currentWallet.canSignWithoutServer
text: qsTr('Billing') text: qsTr('Billing')
color: Material.accentColor color: Material.accentColor
} }
@ -209,6 +212,7 @@ Pane {
TextHighlightPane { TextHighlightPane {
Layout.columnSpan: 2 Layout.columnSpan: 2
Layout.fillWidth: true Layout.fillWidth: true
visible: _is2fa && !Daemon.currentWallet.canSignWithoutServer
ColumnLayout { ColumnLayout {
spacing: 0 spacing: 0
@ -242,14 +246,6 @@ Pane {
} }
} }
}
GridLayout {
id: detailsLayout
visible: Daemon.currentWallet
Layout.preferredWidth: parent.width
columns: 2
Label { Label {
text: qsTr('Derivation prefix') text: qsTr('Derivation prefix')
visible: Daemon.currentWallet.derivationPrefix visible: Daemon.currentWallet.derivationPrefix

13
electrum/gui/qml/qewallet.py

@ -607,19 +607,16 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
try: try:
default_expiry = self.wallet.config.get('request_expiry', PR_DEFAULT_EXPIRATION_WHEN_CREATING) default_expiry = self.wallet.config.get('request_expiry', PR_DEFAULT_EXPIRATION_WHEN_CREATING)
if self.wallet.lnworker and self.wallet.lnworker.channels: if self.wallet.lnworker and self.wallet.lnworker.channels:
addr = None addr = self.wallet.get_unused_address()
if self.wallet.config.get('bolt11_fallback', True): # if addr is None, we ran out of addresses
addr = self.wallet.get_unused_address() if addr is None:
# if addr is None, we ran out of addresses # TODO: remove oldest unpaid request having a fallback address and try again
if addr is None: pass
# TODO: remove oldest unpaid request having a fallback address and try again
pass
key = self.wallet.create_request(None, None, default_expiry, addr) key = self.wallet.create_request(None, None, default_expiry, addr)
else: else:
key, addr = self.create_bitcoin_request(None, None, default_expiry, ignore_gap) key, addr = self.create_bitcoin_request(None, None, default_expiry, ignore_gap)
if not key: if not key:
return return
# self.addressModel.init_model()
except InvoiceError as e: except InvoiceError as e:
self.requestCreateError.emit('fatal',_('Error creating payment request') + ':\n' + str(e)) self.requestCreateError.emit('fatal',_('Error creating payment request') + ':\n' + str(e))
return return

5
electrum/invoices.py

@ -122,9 +122,8 @@ class Invoice(StoredObject):
address = None address = None
if self.outputs: if self.outputs:
address = self.outputs[0].address if len(self.outputs) > 0 else None address = self.outputs[0].address if len(self.outputs) > 0 else None
if not address: if not address and self.is_lightning():
if self.is_lightning(): address = self._lnaddr.get_fallback_address() or None
address = self._lnaddr.get_fallback_address() or None
return address return address
def get_outputs(self): def get_outputs(self):

Loading…
Cancel
Save