1
0

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:
Sander van Grieken
2023-03-13 17:50:00 +01:00
parent dd27c6beff
commit faf0c80893
3 changed files with 13 additions and 8 deletions

View File

@@ -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')