From 888291a8f82136c06adb2f5e378fb8d0afef1b44 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 23 Jun 2023 16:23:12 +0000 Subject: [PATCH] qml: fix lnurl-pay when config.BTC_AMOUNTS_ADD_THOUSANDS_SEP is True when paying an lnurl-pay that provides an amount interval, the amount field is editable by the user and it expects no spaces --- electrum/gui/qml/components/LnurlPayRequestDialog.qml | 2 +- electrum/gui/qml/qeconfig.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/electrum/gui/qml/components/LnurlPayRequestDialog.qml b/electrum/gui/qml/components/LnurlPayRequestDialog.qml index 6cc2030df..c920f71cd 100644 --- a/electrum/gui/qml/components/LnurlPayRequestDialog.qml +++ b/electrum/gui/qml/components/LnurlPayRequestDialog.qml @@ -64,7 +64,7 @@ ElDialog { BtcField { id: amountBtc Layout.preferredWidth: rootLayout.width /3 - text: Config.formatSats(invoiceParser.lnurlData['min_sendable_sat']) + text: Config.formatSatsForEditing(invoiceParser.lnurlData['min_sendable_sat']) enabled: invoiceParser.lnurlData['min_sendable_sat'] != invoiceParser.lnurlData['max_sendable_sat'] color: Material.foreground // override gray-out on disabled fiatfield: amountFiat diff --git a/electrum/gui/qml/qeconfig.py b/electrum/gui/qml/qeconfig.py index 159e3e0d1..49456c3fb 100644 --- a/electrum/gui/qml/qeconfig.py +++ b/electrum/gui/qml/qeconfig.py @@ -211,6 +211,15 @@ class QEConfig(AuthMixin, QObject): self.config.GUI_QML_USER_KNOWS_PRESS_AND_HOLD = userKnowsPressAndHold self.userKnowsPressAndHoldChanged.emit() + @pyqtSlot('qint64', result=str) + @pyqtSlot(QEAmount, result=str) + def formatSatsForEditing(self, satoshis): + if isinstance(satoshis, QEAmount): + satoshis = satoshis.satsInt + return self.config.format_amount( + satoshis, + add_thousands_sep=False, + ) @pyqtSlot('qint64', result=str) @pyqtSlot('qint64', bool, result=str)