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()
|
self._trigger_update_history()
|
||||||
|
|
||||||
@event_listener
|
@event_listener
|
||||||
def on_event_invoice_status(self, wallet, key):
|
def on_event_invoice_status(self, wallet, key, status):
|
||||||
if wallet != self.wallet:
|
if wallet != self.wallet:
|
||||||
return
|
return
|
||||||
req = self.wallet.get_invoice(key)
|
req = self.wallet.get_invoice(key)
|
||||||
if req is None:
|
if req is None:
|
||||||
return
|
return
|
||||||
status = self.wallet.get_invoice_status(req)
|
|
||||||
if self.send_screen:
|
if self.send_screen:
|
||||||
if status == PR_PAID:
|
if status == PR_PAID:
|
||||||
self.send_screen.update()
|
self.send_screen.update()
|
||||||
|
|||||||
@@ -140,16 +140,10 @@ class QEInvoiceListModel(QEAbstractInvoiceListModel, QtEventListener):
|
|||||||
self.unregister_callbacks()
|
self.unregister_callbacks()
|
||||||
|
|
||||||
@qt_event_listener
|
@qt_event_listener
|
||||||
def on_event_invoice_status(self, wallet, key):
|
def on_event_invoice_status(self, wallet, key, status):
|
||||||
if wallet == self.wallet:
|
if wallet == self.wallet:
|
||||||
self._logger.debug('invoice status update for key %s' % key)
|
self._logger.debug(f'invoice status update for key {key} to {status}')
|
||||||
# FIXME event doesn't pass the new status, so we need to retrieve
|
self.updateInvoice(key, status)
|
||||||
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}')
|
|
||||||
|
|
||||||
def invoice_to_model(self, invoice: Invoice):
|
def invoice_to_model(self, invoice: Invoice):
|
||||||
item = super().invoice_to_model(invoice)
|
item = super().invoice_to_model(invoice)
|
||||||
@@ -181,7 +175,7 @@ class QERequestListModel(QEAbstractInvoiceListModel, QtEventListener):
|
|||||||
@qt_event_listener
|
@qt_event_listener
|
||||||
def on_event_request_status(self, wallet, key, status):
|
def on_event_request_status(self, wallet, key, status):
|
||||||
if wallet == self.wallet:
|
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)
|
self.updateRequest(key, status)
|
||||||
|
|
||||||
def invoice_to_model(self, invoice: Invoice):
|
def invoice_to_model(self, invoice: Invoice):
|
||||||
|
|||||||
@@ -158,16 +158,10 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
|||||||
self.historyModel.init_model()
|
self.historyModel.init_model()
|
||||||
|
|
||||||
@event_listener
|
@event_listener
|
||||||
def on_event_invoice_status(self, wallet, key):
|
def on_event_invoice_status(self, wallet, key, status):
|
||||||
if wallet == self.wallet:
|
if wallet == self.wallet:
|
||||||
self._logger.debug('invoice status update for key %s' % key)
|
self._logger.debug(f'invoice status update for key {key} to {status}')
|
||||||
# FIXME event doesn't pass the new status, so we need to retrieve
|
self.invoiceStatusChanged.emit(key, status)
|
||||||
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}')
|
|
||||||
|
|
||||||
@qt_event_listener
|
@qt_event_listener
|
||||||
def on_event_new_transaction(self, wallet, tx):
|
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)
|
self.receive_tab.request_list.refresh_item(key)
|
||||||
|
|
||||||
@qt_event_listener
|
@qt_event_listener
|
||||||
def on_event_invoice_status(self, wallet, key):
|
def on_event_invoice_status(self, wallet, key, status):
|
||||||
if wallet != self.wallet:
|
if wallet != self.wallet:
|
||||||
return
|
return
|
||||||
invoice = self.wallet.get_invoice(key)
|
|
||||||
if invoice is None:
|
|
||||||
return
|
|
||||||
status = self.wallet.get_invoice_status(invoice)
|
|
||||||
if status == PR_PAID:
|
if status == PR_PAID:
|
||||||
self.send_tab.invoice_list.delete_item(key)
|
self.send_tab.invoice_list.delete_item(key)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1268,7 +1268,10 @@ class LNWallet(LNWorker):
|
|||||||
trampoline_onion=trampoline_onion,
|
trampoline_onion=trampoline_onion,
|
||||||
trampoline_fee_level=self.trampoline_fee_level,
|
trampoline_fee_level=self.trampoline_fee_level,
|
||||||
trampoline_route=trampoline_route)
|
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
|
# 3. await a queue
|
||||||
self.logger.info(f"amount inflight {amount_inflight}")
|
self.logger.info(f"amount inflight {amount_inflight}")
|
||||||
htlc_log = await self.sent_htlcs[payment_hash].get()
|
htlc_log = await self.sent_htlcs[payment_hash].get()
|
||||||
@@ -1900,7 +1903,8 @@ class LNWallet(LNWorker):
|
|||||||
self.inflight_payments.remove(key)
|
self.inflight_payments.remove(key)
|
||||||
if status in SAVED_PR_STATUS:
|
if status in SAVED_PR_STATUS:
|
||||||
self.set_payment_status(bfh(key), 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:
|
def set_request_status(self, payment_hash: bytes, status: int) -> None:
|
||||||
if self.get_payment_status(payment_hash) == status:
|
if self.get_payment_status(payment_hash) == status:
|
||||||
|
|||||||
Reference in New Issue
Block a user