add invoice status to invoice_status callback (#8020)
* add invoice status to invoice_status callback * debug statement fails tests * removed commented lines, added progress/attempt counter comment in lnworker.pay_to_node, and update the invoice_status event handler in qeinvoicelistmodel.py
This commit is contained in:
@@ -288,13 +288,12 @@ class ElectrumWindow(App, Logger, EventListener):
|
||||
self._trigger_update_history()
|
||||
|
||||
@event_listener
|
||||
def on_event_invoice_status(self, wallet, key):
|
||||
def on_event_invoice_status(self, wallet, key, status):
|
||||
if wallet != self.wallet:
|
||||
return
|
||||
req = self.wallet.get_invoice(key)
|
||||
if req is None:
|
||||
return
|
||||
status = self.wallet.get_invoice_status(req)
|
||||
if self.send_screen:
|
||||
if status == PR_PAID:
|
||||
self.send_screen.update()
|
||||
|
||||
@@ -140,16 +140,10 @@ class QEInvoiceListModel(QEAbstractInvoiceListModel, QtEventListener):
|
||||
self.unregister_callbacks()
|
||||
|
||||
@qt_event_listener
|
||||
def on_event_invoice_status(self, wallet, key):
|
||||
def on_event_invoice_status(self, wallet, key, status):
|
||||
if wallet == self.wallet:
|
||||
self._logger.debug('invoice status update for key %s' % key)
|
||||
# FIXME event doesn't pass the new status, so we need to retrieve
|
||||
invoice = self.wallet.get_invoice(key)
|
||||
if invoice:
|
||||
status = self.wallet.get_invoice_status(invoice)
|
||||
self.updateInvoice(key, status)
|
||||
else:
|
||||
self._logger.debug(f'No invoice found for key {key}')
|
||||
self._logger.debug(f'invoice status update for key {key} to {status}')
|
||||
self.updateInvoice(key, status)
|
||||
|
||||
def invoice_to_model(self, invoice: Invoice):
|
||||
item = super().invoice_to_model(invoice)
|
||||
@@ -181,7 +175,7 @@ class QERequestListModel(QEAbstractInvoiceListModel, QtEventListener):
|
||||
@qt_event_listener
|
||||
def on_event_request_status(self, wallet, key, status):
|
||||
if wallet == self.wallet:
|
||||
self._logger.debug('request status update for key %s' % key)
|
||||
self._logger.debug(f'request status update for key {key} to {status}')
|
||||
self.updateRequest(key, status)
|
||||
|
||||
def invoice_to_model(self, invoice: Invoice):
|
||||
|
||||
@@ -158,16 +158,10 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
||||
self.historyModel.init_model()
|
||||
|
||||
@event_listener
|
||||
def on_event_invoice_status(self, wallet, key):
|
||||
def on_event_invoice_status(self, wallet, key, status):
|
||||
if wallet == self.wallet:
|
||||
self._logger.debug('invoice status update for key %s' % key)
|
||||
# FIXME event doesn't pass the new status, so we need to retrieve
|
||||
invoice = self.wallet.get_invoice(key)
|
||||
if invoice:
|
||||
status = self.wallet.get_invoice_status(invoice)
|
||||
self.invoiceStatusChanged.emit(key, status)
|
||||
else:
|
||||
self._logger.debug(f'No invoice found for key {key}')
|
||||
self._logger.debug(f'invoice status update for key {key} to {status}')
|
||||
self.invoiceStatusChanged.emit(key, status)
|
||||
|
||||
@qt_event_listener
|
||||
def on_event_new_transaction(self, wallet, tx):
|
||||
|
||||
@@ -1157,13 +1157,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
|
||||
self.receive_tab.request_list.refresh_item(key)
|
||||
|
||||
@qt_event_listener
|
||||
def on_event_invoice_status(self, wallet, key):
|
||||
def on_event_invoice_status(self, wallet, key, status):
|
||||
if wallet != self.wallet:
|
||||
return
|
||||
invoice = self.wallet.get_invoice(key)
|
||||
if invoice is None:
|
||||
return
|
||||
status = self.wallet.get_invoice_status(invoice)
|
||||
if status == PR_PAID:
|
||||
self.send_tab.invoice_list.delete_item(key)
|
||||
else:
|
||||
|
||||
@@ -1268,7 +1268,10 @@ class LNWallet(LNWorker):
|
||||
trampoline_onion=trampoline_onion,
|
||||
trampoline_fee_level=self.trampoline_fee_level,
|
||||
trampoline_route=trampoline_route)
|
||||
util.trigger_callback('invoice_status', self.wallet, payment_hash.hex())
|
||||
# invoice_status is triggered in self.set_invoice_status when it actally changes.
|
||||
# It is also triggered here to update progress for a lightning payment in the GUI
|
||||
# (e.g. attempt counter)
|
||||
util.trigger_callback('invoice_status', self.wallet, payment_hash.hex(), PR_INFLIGHT)
|
||||
# 3. await a queue
|
||||
self.logger.info(f"amount inflight {amount_inflight}")
|
||||
htlc_log = await self.sent_htlcs[payment_hash].get()
|
||||
@@ -1900,7 +1903,8 @@ class LNWallet(LNWorker):
|
||||
self.inflight_payments.remove(key)
|
||||
if status in SAVED_PR_STATUS:
|
||||
self.set_payment_status(bfh(key), status)
|
||||
util.trigger_callback('invoice_status', self.wallet, key)
|
||||
util.trigger_callback('invoice_status', self.wallet, key, status)
|
||||
self.logger.info(f"invoice status triggered (2) for key {key} and status {status}")
|
||||
|
||||
def set_request_status(self, payment_hash: bytes, status: int) -> None:
|
||||
if self.get_payment_status(payment_hash) == status:
|
||||
|
||||
Reference in New Issue
Block a user