1
0

qml: show lightning invoice amounts with msat precision, allow msat precision entry for no-amount lightning invoices

This commit is contained in:
Sander van Grieken
2025-11-26 16:53:24 +01:00
parent e137c888a1
commit c519083b9b
4 changed files with 9 additions and 4 deletions

View File

@@ -181,7 +181,9 @@ ElDialog {
font.pixelSize: constants.fontSizeXLarge
font.family: FixedFont
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 {
@@ -223,12 +225,13 @@ ElDialog {
Layout.preferredWidth: amountFontMetrics.advanceWidth('0') * 14 + leftPadding + rightPadding
fiatfield: amountFiat
readOnly: amountMax.checked
msatPrecision: invoice.invoiceType == Invoice.LightningInvoice
color: readOnly
? Material.accentColor
: Material.foreground
onTextAsSatsChanged: {
if (!amountMax.checked)
invoice.amountOverride.satsInt = textAsSats.satsInt
invoice.amountOverride.copyFrom(textAsSats)
}
Connections {
target: invoice.amountOverride

View File

@@ -7,12 +7,13 @@ TextField {
id: amount
required property TextField fiatfield
property bool msatPrecision: false
font.family: FixedFont
placeholderText: qsTr('Amount')
inputMethodHints: Qt.ImhDigitsOnly
validator: RegularExpressionValidator {
regularExpression: Config.btcAmountRegex
regularExpression: msatPrecision ? Config.btcAmountRegexMsat : Config.btcAmountRegex
}
property Amount textAsSats

View File

@@ -383,7 +383,7 @@ class QEInvoice(QObject, QtEventListener):
if self.amount.isEmpty:
if self.amountOverride.isEmpty:
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)

View File

@@ -90,6 +90,7 @@ class QEAmount(QObject):
self._is_max = False
self.valueChanged.emit()
@pyqtSlot('QVariant')
def copyFrom(self, amount):
if not amount:
self._logger.warning('copyFrom with None argument. assuming 0') # TODO