change address-only handling: create amount=0 onchain invoice
invoicedialog auto enables edit mode when amount is 0
This commit is contained in:
@@ -325,5 +325,7 @@ ElDialog {
|
||||
if (invoice_key != '') {
|
||||
invoice.initFromKey(invoice_key)
|
||||
}
|
||||
if (invoice.amount.satsInt == 0)
|
||||
amountContainer.editmode = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ Item {
|
||||
id: invoiceParser
|
||||
wallet: Daemon.currentWallet
|
||||
onValidationError: {
|
||||
var dialog = app.messageDialog.createObject(app, {'text': message })
|
||||
var dialog = app.messageDialog.createObject(app, { text: message })
|
||||
dialog.closed.connect(function() {
|
||||
_sendDialog.restart()
|
||||
})
|
||||
@@ -150,7 +150,7 @@ Item {
|
||||
}
|
||||
onValidationWarning: {
|
||||
if (code == 'no_channels') {
|
||||
var dialog = app.messageDialog.createObject(app, {'text': message })
|
||||
var dialog = app.messageDialog.createObject(app, { text: message })
|
||||
dialog.open()
|
||||
// TODO: ask user to open a channel, if funds allow
|
||||
// and maybe store invoice if expiry allows
|
||||
@@ -158,16 +158,8 @@ Item {
|
||||
}
|
||||
onValidationSuccess: {
|
||||
_sendDialog.close()
|
||||
// address only -> fill form fields and clear this instance
|
||||
// else -> show invoice confirmation dialog
|
||||
if (invoiceType == Invoice.OnchainOnlyAddress) {
|
||||
recipient.text = invoice.recipient
|
||||
invoiceParser.clear()
|
||||
} else {
|
||||
var dialog = invoiceDialog.createObject(app, {'invoice': invoiceParser})
|
||||
// dialog.invoice = invoiceParser
|
||||
dialog.open()
|
||||
}
|
||||
var dialog = invoiceDialog.createObject(app, { invoice: invoiceParser })
|
||||
dialog.open()
|
||||
}
|
||||
onInvoiceCreateError: console.log(code + ' ' + message)
|
||||
|
||||
|
||||
@@ -288,11 +288,11 @@ class QEInvoiceParser(QEInvoice):
|
||||
def get_max_spendable_lightning(self):
|
||||
return self._wallet.wallet.lnworker.num_sats_can_send()
|
||||
|
||||
def setValidAddressOnly(self):
|
||||
self._logger.debug('setValidAddressOnly')
|
||||
self.setInvoiceType(QEInvoice.Type.OnchainOnlyAddress)
|
||||
self._effectiveInvoice = None
|
||||
self.invoiceChanged.emit()
|
||||
# def setValidAddressOnly(self):
|
||||
# self._logger.debug('setValidAddressOnly')
|
||||
# self.setInvoiceType(QEInvoice.Type.OnchainOnlyAddress)
|
||||
# self._effectiveInvoice = None
|
||||
# self.invoiceChanged.emit()
|
||||
|
||||
def setValidOnchainInvoice(self, invoice: Invoice):
|
||||
self._logger.debug('setValidOnchainInvoice')
|
||||
@@ -335,7 +335,11 @@ class QEInvoiceParser(QEInvoice):
|
||||
return
|
||||
if ':' not in recipient:
|
||||
# address only
|
||||
self.setValidAddressOnly()
|
||||
# create bare invoice
|
||||
outputs = [PartialTxOutput.from_address_and_value(self._bip21['address'], 0)]
|
||||
invoice = self.create_onchain_invoice(outputs, None, None, None)
|
||||
self._logger.debug(repr(invoice))
|
||||
self.setValidOnchainInvoice(invoice)
|
||||
self.validationSuccess.emit()
|
||||
return
|
||||
else:
|
||||
@@ -387,9 +391,7 @@ class QEInvoiceParser(QEInvoice):
|
||||
self.validationSuccess.emit()
|
||||
else:
|
||||
self._logger.debug('flow without LN but having bip21 uri')
|
||||
if 'amount' not in self._bip21: #TODO can we have amount-less invoices?
|
||||
# self.validationError.emit('no_amount', 'no amount in uri')
|
||||
# return
|
||||
if 'amount' not in self._bip21:
|
||||
amount = 0
|
||||
else:
|
||||
amount = self._bip21['amount']
|
||||
|
||||
Reference in New Issue
Block a user