qml: disable pay button while editing amount, perform minimum amount check for lightning invoices, update amount in invoice list.
This commit is contained in:
@@ -14,6 +14,7 @@ ElDialog {
|
|||||||
property string invoice_key
|
property string invoice_key
|
||||||
|
|
||||||
signal doPay
|
signal doPay
|
||||||
|
signal invoiceAmountChanged
|
||||||
|
|
||||||
title: qsTr('Invoice')
|
title: qsTr('Invoice')
|
||||||
standardButtons: invoice_key != '' ? Dialog.Close : Dialog.Cancel
|
standardButtons: invoice_key != '' ? Dialog.Close : Dialog.Cancel
|
||||||
@@ -121,6 +122,29 @@ ElDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
visible: invoice.invoiceType == Invoice.LightningInvoice
|
||||||
|
text: qsTr('Payment hash')
|
||||||
|
color: Material.accentColor
|
||||||
|
}
|
||||||
|
|
||||||
|
TextHighlightPane {
|
||||||
|
visible: invoice.invoiceType == Invoice.LightningInvoice
|
||||||
|
|
||||||
|
Layout.columnSpan: 2
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
padding: 0
|
||||||
|
leftPadding: constants.paddingMedium
|
||||||
|
|
||||||
|
Label {
|
||||||
|
width: parent.width
|
||||||
|
text: 'payment_hash' in invoice.lnprops ? invoice.lnprops.payment_hash : ''
|
||||||
|
font.family: FixedFont
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: qsTr('Description')
|
text: qsTr('Description')
|
||||||
visible: invoice.message
|
visible: invoice.message
|
||||||
@@ -278,6 +302,7 @@ ElDialog {
|
|||||||
onClicked: {
|
onClicked: {
|
||||||
amountContainer.editmode = false
|
amountContainer.editmode = false
|
||||||
invoice.amount = amountMax.checked ? MAX : Config.unitsToSats(amountBtc.text)
|
invoice.amount = amountMax.checked ? MAX : Config.unitsToSats(amountBtc.text)
|
||||||
|
invoiceAmountChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ToolButton {
|
ToolButton {
|
||||||
@@ -308,7 +333,7 @@ ElDialog {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: qsTr('Pay')
|
text: qsTr('Pay')
|
||||||
icon.source: '../../icons/confirmed.png'
|
icon.source: '../../icons/confirmed.png'
|
||||||
enabled: invoice.invoiceType != Invoice.Invalid && invoice.canPay
|
enabled: invoice.invoiceType != Invoice.Invalid && invoice.canPay && !amountContainer.editmode
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (invoice_key == '') // save invoice if not retrieved from key
|
if (invoice_key == '') // save invoice if not retrieved from key
|
||||||
invoice.save_invoice()
|
invoice.save_invoice()
|
||||||
|
|||||||
@@ -42,7 +42,12 @@ Pane {
|
|||||||
id: delegateModel
|
id: delegateModel
|
||||||
model: Daemon.currentWallet.invoiceModel
|
model: Daemon.currentWallet.invoiceModel
|
||||||
delegate: InvoiceDelegate {
|
delegate: InvoiceDelegate {
|
||||||
onClicked: app.stack.getRoot().openInvoice(model.key)
|
onClicked: {
|
||||||
|
var dialog = app.stack.getRoot().openInvoice(model.key)
|
||||||
|
dialog.invoiceAmountChanged.connect(function () {
|
||||||
|
Daemon.currentWallet.invoiceModel.init_model()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ ElDialog {
|
|||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: content
|
id: content
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
@@ -92,15 +93,18 @@ ElDialog {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: helpText
|
id: helpText
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
text: qsTr('Paying...')
|
text: qsTr('Paying...')
|
||||||
font.pixelSize: constants.fontSizeXXLarge
|
font.pixelSize: constants.fontSizeXXLarge
|
||||||
Layout.alignment: Qt.AlignHCenter
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: errorText
|
id: errorText
|
||||||
font.pixelSize: constants.fontSizeLarge
|
Layout.preferredWidth: parent.width
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
font.pixelSize: constants.fontSizeLarge
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from electrum.transaction import PartialTxOutput
|
|||||||
from electrum.util import (parse_URI, InvalidBitcoinURI, InvoiceError,
|
from electrum.util import (parse_URI, InvalidBitcoinURI, InvoiceError,
|
||||||
maybe_extract_lightning_payment_identifier)
|
maybe_extract_lightning_payment_identifier)
|
||||||
from electrum.lnurl import decode_lnurl, request_lnurl, callback_lnurl
|
from electrum.lnurl import decode_lnurl, request_lnurl, callback_lnurl
|
||||||
|
from electrum.bitcoin import COIN
|
||||||
|
|
||||||
from .qetypes import QEAmount
|
from .qetypes import QEAmount
|
||||||
from .qewallet import QEWallet
|
from .qewallet import QEWallet
|
||||||
@@ -226,6 +227,7 @@ class QEInvoiceParser(QEInvoice):
|
|||||||
self._logger.debug(str(lnaddr.get_routing_info('t')))
|
self._logger.debug(str(lnaddr.get_routing_info('t')))
|
||||||
return {
|
return {
|
||||||
'pubkey': lnaddr.pubkey.serialize().hex(),
|
'pubkey': lnaddr.pubkey.serialize().hex(),
|
||||||
|
'payment_hash': lnaddr.paymenthash.hex(),
|
||||||
't': '', #lnaddr.get_routing_info('t')[0][0].hex(),
|
't': '', #lnaddr.get_routing_info('t')[0][0].hex(),
|
||||||
'r': '' #lnaddr.get_routing_info('r')[0][0][0].hex()
|
'r': '' #lnaddr.get_routing_info('r')[0][0][0].hex()
|
||||||
}
|
}
|
||||||
@@ -277,7 +279,11 @@ class QEInvoiceParser(QEInvoice):
|
|||||||
if self.invoiceType == QEInvoice.Type.LightningInvoice:
|
if self.invoiceType == QEInvoice.Type.LightningInvoice:
|
||||||
if self.status in [PR_UNPAID, PR_FAILED]:
|
if self.status in [PR_UNPAID, PR_FAILED]:
|
||||||
if self.get_max_spendable_lightning() >= self.amount.satsInt:
|
if self.get_max_spendable_lightning() >= self.amount.satsInt:
|
||||||
self.canPay = True
|
lnaddr = self._effectiveInvoice._lnaddr
|
||||||
|
if self.amount.satsInt < lnaddr.amount * COIN:
|
||||||
|
self.userinfo = _('Cannot pay less than the amount specified in the invoice')
|
||||||
|
else:
|
||||||
|
self.canPay = True
|
||||||
else:
|
else:
|
||||||
self.userinfo = _('Insufficient balance')
|
self.userinfo = _('Insufficient balance')
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user