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
|
text: invoice.invoiceType == Invoice.OnchainInvoice
|
||||||
? qsTr('On chain')
|
? qsTr('On chain')
|
||||||
: invoice.invoiceType == Invoice.LightningInvoice
|
: invoice.invoiceType == Invoice.LightningInvoice
|
||||||
? qsTr('Lightning')
|
? invoice.address
|
||||||
|
? qsTr('Lightning with on-chain fallback address')
|
||||||
|
: qsTr('Lightning')
|
||||||
: ''
|
: ''
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -255,11 +255,11 @@ Item {
|
|||||||
height: parent.height
|
height: parent.height
|
||||||
|
|
||||||
onDoPay: {
|
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, {
|
var dialog = confirmPaymentDialog.createObject(mainView, {
|
||||||
'address': invoice.address,
|
address: invoice.address,
|
||||||
'satoshis': invoice.amount,
|
satoshis: invoice.amount,
|
||||||
'message': invoice.message
|
message: invoice.message
|
||||||
})
|
})
|
||||||
var canComplete = !Daemon.currentWallet.isWatchOnly && Daemon.currentWallet.canSignWithoutCosigner
|
var canComplete = !Daemon.currentWallet.isWatchOnly && Daemon.currentWallet.canSignWithoutCosigner
|
||||||
dialog.txaccepted.connect(function() {
|
dialog.txaccepted.connect(function() {
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ class QEInvoice(QObject):
|
|||||||
Invalid = -1
|
Invalid = -1
|
||||||
OnchainInvoice = 0
|
OnchainInvoice = 0
|
||||||
LightningInvoice = 1
|
LightningInvoice = 1
|
||||||
LightningAndOnchainInvoice = 2
|
LNURLPayRequest = 2
|
||||||
LNURLPayRequest = 3
|
|
||||||
|
|
||||||
class Status:
|
class Status:
|
||||||
Unpaid = PR_UNPAID
|
Unpaid = PR_UNPAID
|
||||||
@@ -307,6 +306,10 @@ class QEInvoiceParser(QEInvoice):
|
|||||||
self.userinfo = _('Cannot pay less than the amount specified in the invoice')
|
self.userinfo = _('Cannot pay less than the amount specified in the invoice')
|
||||||
else:
|
else:
|
||||||
self.canPay = True
|
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:
|
else:
|
||||||
self.userinfo = _('Insufficient balance')
|
self.userinfo = _('Insufficient balance')
|
||||||
else:
|
else:
|
||||||
@@ -323,7 +326,7 @@ class QEInvoiceParser(QEInvoice):
|
|||||||
# TODO: dust limit?
|
# TODO: dust limit?
|
||||||
self.canPay = True
|
self.canPay = True
|
||||||
elif self.get_max_spendable_onchain() >= self.amount.satsInt:
|
elif self.get_max_spendable_onchain() >= self.amount.satsInt:
|
||||||
# TODO: dust limit?
|
# TODO: subtract fee?
|
||||||
self.canPay = True
|
self.canPay = True
|
||||||
else:
|
else:
|
||||||
self.userinfo = _('Insufficient balance')
|
self.userinfo = _('Insufficient balance')
|
||||||
|
|||||||
Reference in New Issue
Block a user