qml: let user enter lnurl6 amount
This commit is contained in:
@@ -46,18 +46,27 @@ ElDialog {
|
||||
Layout.fillWidth: true
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
Label {
|
||||
text: invoiceParser.lnurlData['min_sendable_sat'] == invoiceParser.lnurlData['max_sendable_sat']
|
||||
? qsTr('Amount')
|
||||
: qsTr('Amount range')
|
||||
text: qsTr('Amount')
|
||||
color: Material.accentColor
|
||||
}
|
||||
|
||||
BtcField {
|
||||
id: amountBtc
|
||||
text: Config.formatSats(invoiceParser.lnurlData['min_sendable_sat'])
|
||||
enabled: invoiceParser.lnurlData['min_sendable_sat'] != invoiceParser.lnurlData['max_sendable_sat']
|
||||
fiatfield: null
|
||||
Layout.preferredWidth: parent.width /3
|
||||
onTextAsSatsChanged: {
|
||||
invoiceParser.amountOverride = textAsSats
|
||||
}
|
||||
}
|
||||
Label {
|
||||
Layout.columnSpan: 2
|
||||
text: invoiceParser.lnurlData['min_sendable_sat'] == invoiceParser.lnurlData['max_sendable_sat']
|
||||
? invoiceParser.lnurlData['min_sendable_sat'] == 0
|
||||
? qsTr('Unspecified')
|
||||
: invoiceParser.lnurlData['min_sendable_sat']
|
||||
: invoiceParser.lnurlData['min_sendable_sat'] + ' < amount < ' + invoiceParser.lnurlData['max_sendable_sat']
|
||||
? ''
|
||||
: qsTr('Amount must be between %1 and %2').arg(Config.formatSats(invoiceParser.lnurlData['min_sendable_sat'])).arg(Config.formatSats(invoiceParser.lnurlData['max_sendable_sat'])) + Config.baseUnit
|
||||
}
|
||||
|
||||
TextArea {
|
||||
@@ -86,7 +95,7 @@ ElDialog {
|
||||
icon.source: '../../icons/confirmed.png'
|
||||
enabled: valid
|
||||
onClicked: {
|
||||
invoiceParser.lnurlGetInvoice(invoiceParser.lnurlData['min_sendable_sat'], comment.text)
|
||||
invoiceParser.lnurlGetInvoice(comment.text)
|
||||
dialog.close()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,6 +552,15 @@ class QEInvoiceParser(QEInvoice):
|
||||
def lnurlGetInvoice(self, amount, comment=None):
|
||||
assert self._lnurlData
|
||||
|
||||
amount = self.amountOverride.satsInt
|
||||
if self.lnurlData['min_sendable_sat'] != 0:
|
||||
try:
|
||||
assert amount >= self.lnurlData['min_sendable_sat']
|
||||
assert amount <= self.lnurlData['max_sendable_sat']
|
||||
except:
|
||||
self.lnurlError.emit('lnurl', _('Amount out of bounds'))
|
||||
return
|
||||
|
||||
if self._lnurlData['comment_allowed'] == 0:
|
||||
comment = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user