qml: move payment progress info text updates fully into qeinvoice, qeinvoice now updates itself
directly from backend wallet callbacks
This commit is contained in:
@@ -53,7 +53,9 @@ ElDialog {
|
|||||||
Layout.bottomMargin: constants.paddingLarge
|
Layout.bottomMargin: constants.paddingLarge
|
||||||
visible: text
|
visible: text
|
||||||
text: invoice.userinfo
|
text: invoice.userinfo
|
||||||
iconStyle: InfoTextArea.IconStyle.Warn
|
iconStyle: invoice.status == Invoice.Failed || invoice.status == Invoice.Expired
|
||||||
|
? InfoTextArea.IconStyle.Warn
|
||||||
|
: InfoTextArea.IconStyle.Info
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
@@ -459,33 +461,12 @@ ElDialog {
|
|||||||
invoice.save_invoice()
|
invoice.save_invoice()
|
||||||
}
|
}
|
||||||
doPay() // only signal here
|
doPay() // only signal here
|
||||||
helpText.text = qsTr('Payment in progress...')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: Daemon.currentWallet
|
|
||||||
function onPaymentSucceeded(key) {
|
|
||||||
if (key != invoice.key) {
|
|
||||||
console.log('wrong invoice ' + key + ' != ' + invoice.key)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.log('payment succeeded!')
|
|
||||||
helpText.text = qsTr('Paid!')
|
|
||||||
}
|
|
||||||
function onPaymentFailed(key, reason) {
|
|
||||||
if (key != invoice.key) {
|
|
||||||
console.log('wrong invoice ' + key + ' != ' + invoice.key)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.log('payment failed: ' + reason)
|
|
||||||
helpText.text = qsTr('Payment failed: ' + reason)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (invoice_key != '') {
|
if (invoice_key != '') {
|
||||||
invoice.initFromKey(invoice_key)
|
invoice.initFromKey(invoice_key)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ from electrum.paymentrequest import PaymentRequest
|
|||||||
|
|
||||||
from .qetypes import QEAmount
|
from .qetypes import QEAmount
|
||||||
from .qewallet import QEWallet
|
from .qewallet import QEWallet
|
||||||
from .util import status_update_timer_interval
|
from .util import status_update_timer_interval, QtEventListener, event_listener
|
||||||
|
|
||||||
|
|
||||||
class QEInvoice(QObject):
|
class QEInvoice(QObject):
|
||||||
@@ -120,7 +120,7 @@ class QEInvoice(QObject):
|
|||||||
def get_max_spendable_lightning(self):
|
def get_max_spendable_lightning(self):
|
||||||
return self._wallet.wallet.lnworker.num_sats_can_send() if self._wallet.wallet.lnworker else 0
|
return self._wallet.wallet.lnworker.num_sats_can_send() if self._wallet.wallet.lnworker else 0
|
||||||
|
|
||||||
class QEInvoiceParser(QEInvoice):
|
class QEInvoiceParser(QEInvoice, QtEventListener):
|
||||||
_logger = get_logger(__name__)
|
_logger = get_logger(__name__)
|
||||||
|
|
||||||
invoiceChanged = pyqtSignal()
|
invoiceChanged = pyqtSignal()
|
||||||
@@ -160,6 +160,31 @@ class QEInvoiceParser(QEInvoice):
|
|||||||
|
|
||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
|
self.register_callbacks()
|
||||||
|
self.destroyed.connect(lambda: self.on_destroy())
|
||||||
|
|
||||||
|
def on_destroy(self):
|
||||||
|
self.unregister_callbacks()
|
||||||
|
|
||||||
|
@event_listener
|
||||||
|
def on_event_payment_succeeded(self, wallet, key):
|
||||||
|
if wallet == self._wallet.wallet and key == self.key:
|
||||||
|
self.statusChanged.emit()
|
||||||
|
self.userinfo = _('Paid!')
|
||||||
|
|
||||||
|
@event_listener
|
||||||
|
def on_event_payment_failed(self, wallet, key, reason):
|
||||||
|
if wallet == self._wallet.wallet and key == self.key:
|
||||||
|
self.statusChanged.emit()
|
||||||
|
self.userinfo = _('Payment failed: ') + reason
|
||||||
|
|
||||||
|
@event_listener
|
||||||
|
def on_event_invoice_status(self, wallet, key, status):
|
||||||
|
if wallet == self._wallet.wallet and key == self.key:
|
||||||
|
self.statusChanged.emit()
|
||||||
|
if status in [PR_INFLIGHT, PR_ROUTING]:
|
||||||
|
self.userinfo = _('In progress...')
|
||||||
|
|
||||||
@pyqtProperty(int, notify=invoiceChanged)
|
@pyqtProperty(int, notify=invoiceChanged)
|
||||||
def invoiceType(self):
|
def invoiceType(self):
|
||||||
return self._invoiceType
|
return self._invoiceType
|
||||||
|
|||||||
Reference in New Issue
Block a user