qml: enable canPay in InvoiceDialog if wallet has insufficient funds to pay via lightning
and invoice has fallback address and amount can be paid on-chain. In WalletMainView, follow on-chain payment path if available lighting balance is insufficient for the invoice amount
This commit is contained in:
@@ -78,7 +78,9 @@ ElDialog {
|
||||
text: invoice.invoiceType == Invoice.OnchainInvoice
|
||||
? qsTr('On chain')
|
||||
: invoice.invoiceType == Invoice.LightningInvoice
|
||||
? qsTr('Lightning')
|
||||
? invoice.address
|
||||
? qsTr('Lightning with on-chain fallback address')
|
||||
: qsTr('Lightning')
|
||||
: ''
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
@@ -255,11 +255,11 @@ Item {
|
||||
height: parent.height
|
||||
|
||||
onDoPay: {
|
||||
if (invoice.invoiceType == Invoice.OnchainInvoice) {
|
||||
if (invoice.invoiceType == Invoice.OnchainInvoice || (invoice.invoiceType == Invoice.LightningInvoice && invoice.amount.satsInt > Daemon.currentWallet.lightningCanSend ) ) {
|
||||
var dialog = confirmPaymentDialog.createObject(mainView, {
|
||||
'address': invoice.address,
|
||||
'satoshis': invoice.amount,
|
||||
'message': invoice.message
|
||||
address: invoice.address,
|
||||
satoshis: invoice.amount,
|
||||
message: invoice.message
|
||||
})
|
||||
var canComplete = !Daemon.currentWallet.isWatchOnly && Daemon.currentWallet.canSignWithoutCosigner
|
||||
dialog.txaccepted.connect(function() {
|
||||
|
||||
@@ -27,8 +27,7 @@ class QEInvoice(QObject):
|
||||
Invalid = -1
|
||||
OnchainInvoice = 0
|
||||
LightningInvoice = 1
|
||||
LightningAndOnchainInvoice = 2
|
||||
LNURLPayRequest = 3
|
||||
LNURLPayRequest = 2
|
||||
|
||||
class Status:
|
||||
Unpaid = PR_UNPAID
|
||||
@@ -307,6 +306,10 @@ class QEInvoiceParser(QEInvoice):
|
||||
self.userinfo = _('Cannot pay less than the amount specified in the invoice')
|
||||
else:
|
||||
self.canPay = True
|
||||
elif self.address and self.get_max_spendable_onchain() > self.amount.satsInt:
|
||||
# TODO: validate address?
|
||||
# TODO: subtract fee?
|
||||
self.canPay = True
|
||||
else:
|
||||
self.userinfo = _('Insufficient balance')
|
||||
else:
|
||||
@@ -323,7 +326,7 @@ class QEInvoiceParser(QEInvoice):
|
||||
# TODO: dust limit?
|
||||
self.canPay = True
|
||||
elif self.get_max_spendable_onchain() >= self.amount.satsInt:
|
||||
# TODO: dust limit?
|
||||
# TODO: subtract fee?
|
||||
self.canPay = True
|
||||
else:
|
||||
self.userinfo = _('Insufficient balance')
|
||||
|
||||
Reference in New Issue
Block a user