qml: show lightning invoice amounts with msat precision, allow msat precision entry for no-amount lightning invoices
This commit is contained in:
@@ -181,7 +181,9 @@ ElDialog {
|
|||||||
font.pixelSize: constants.fontSizeXLarge
|
font.pixelSize: constants.fontSizeXLarge
|
||||||
font.family: FixedFont
|
font.family: FixedFont
|
||||||
font.bold: true
|
font.bold: true
|
||||||
text: Config.formatSats(invoice.amount, false)
|
text: invoice.invoiceType == Invoice.LightningInvoice
|
||||||
|
? Config.formatMilliSats(invoice.amount, false)
|
||||||
|
: Config.formatSats(invoice.amount, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
@@ -223,12 +225,13 @@ ElDialog {
|
|||||||
Layout.preferredWidth: amountFontMetrics.advanceWidth('0') * 14 + leftPadding + rightPadding
|
Layout.preferredWidth: amountFontMetrics.advanceWidth('0') * 14 + leftPadding + rightPadding
|
||||||
fiatfield: amountFiat
|
fiatfield: amountFiat
|
||||||
readOnly: amountMax.checked
|
readOnly: amountMax.checked
|
||||||
|
msatPrecision: invoice.invoiceType == Invoice.LightningInvoice
|
||||||
color: readOnly
|
color: readOnly
|
||||||
? Material.accentColor
|
? Material.accentColor
|
||||||
: Material.foreground
|
: Material.foreground
|
||||||
onTextAsSatsChanged: {
|
onTextAsSatsChanged: {
|
||||||
if (!amountMax.checked)
|
if (!amountMax.checked)
|
||||||
invoice.amountOverride.satsInt = textAsSats.satsInt
|
invoice.amountOverride.copyFrom(textAsSats)
|
||||||
}
|
}
|
||||||
Connections {
|
Connections {
|
||||||
target: invoice.amountOverride
|
target: invoice.amountOverride
|
||||||
|
|||||||
@@ -7,12 +7,13 @@ TextField {
|
|||||||
id: amount
|
id: amount
|
||||||
|
|
||||||
required property TextField fiatfield
|
required property TextField fiatfield
|
||||||
|
property bool msatPrecision: false
|
||||||
|
|
||||||
font.family: FixedFont
|
font.family: FixedFont
|
||||||
placeholderText: qsTr('Amount')
|
placeholderText: qsTr('Amount')
|
||||||
inputMethodHints: Qt.ImhDigitsOnly
|
inputMethodHints: Qt.ImhDigitsOnly
|
||||||
validator: RegularExpressionValidator {
|
validator: RegularExpressionValidator {
|
||||||
regularExpression: Config.btcAmountRegex
|
regularExpression: msatPrecision ? Config.btcAmountRegexMsat : Config.btcAmountRegex
|
||||||
}
|
}
|
||||||
|
|
||||||
property Amount textAsSats
|
property Amount textAsSats
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ class QEInvoice(QObject, QtEventListener):
|
|||||||
if self.amount.isEmpty:
|
if self.amount.isEmpty:
|
||||||
if self.amountOverride.isEmpty:
|
if self.amountOverride.isEmpty:
|
||||||
raise Exception('can not pay 0 amount')
|
raise Exception('can not pay 0 amount')
|
||||||
amount_msat = self.amountOverride.satsInt * 1000
|
amount_msat = self.amountOverride.msatsInt
|
||||||
|
|
||||||
self._wallet.pay_lightning_invoice(self._effectiveInvoice, amount_msat)
|
self._wallet.pay_lightning_invoice(self._effectiveInvoice, amount_msat)
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ class QEAmount(QObject):
|
|||||||
self._is_max = False
|
self._is_max = False
|
||||||
self.valueChanged.emit()
|
self.valueChanged.emit()
|
||||||
|
|
||||||
|
@pyqtSlot('QVariant')
|
||||||
def copyFrom(self, amount):
|
def copyFrom(self, amount):
|
||||||
if not amount:
|
if not amount:
|
||||||
self._logger.warning('copyFrom with None argument. assuming 0') # TODO
|
self._logger.warning('copyFrom with None argument. assuming 0') # TODO
|
||||||
|
|||||||
Reference in New Issue
Block a user