diff --git a/electrum/gui/kivy/uix/dialogs/invoice_dialog.py b/electrum/gui/kivy/uix/dialogs/invoice_dialog.py index ead297d22..a84432cd6 100644 --- a/electrum/gui/kivy/uix/dialogs/invoice_dialog.py +++ b/electrum/gui/kivy/uix/dialogs/invoice_dialog.py @@ -137,5 +137,8 @@ class InvoiceDialog(Factory.Popup): def show_log(self): if self.log: - log_str = _('Payment log:') + '\n\n' + '\n'.join([str(x.exception) for x in self.log]) + log_str = _('Payment log:') + '\n\n' + for payment_attempt_log in self.log: + route_str, chan_str, message = payment_attempt_log.formatted_tuple() + log_str += chan_str + ' --- ' + message + '\n' self.app.show_info(log_str) diff --git a/electrum/gui/qt/invoice_list.py b/electrum/gui/qt/invoice_list.py index dea2a152b..9b38db6f5 100644 --- a/electrum/gui/qt/invoice_list.py +++ b/electrum/gui/qt/invoice_list.py @@ -29,7 +29,7 @@ from typing import Sequence from PyQt5.QtCore import Qt, QItemSelectionModel from PyQt5.QtGui import QStandardItemModel, QStandardItem from PyQt5.QtWidgets import QAbstractItemView -from PyQt5.QtWidgets import QMenu, QVBoxLayout, QTreeWidget, QTreeWidgetItem +from PyQt5.QtWidgets import QMenu, QVBoxLayout, QTreeWidget, QTreeWidgetItem, QHeaderView from electrum.i18n import _ from electrum.util import format_time, PR_UNPAID, PR_PAID, PR_INFLIGHT, PR_FAILED @@ -173,32 +173,15 @@ class InvoiceList(MyTreeView): def show_log(self, key, log: Sequence[PaymentAttemptLog]): d = WindowModalDialog(self, _("Payment log")) - d.setMinimumWidth(800) + d.setMinimumWidth(600) vbox = QVBoxLayout(d) log_w = QTreeWidget() - log_w.setHeaderLabels([_('Route'), _('Channel ID'), _('Message'), _('Blacklist')]) + log_w.setHeaderLabels([_('Hops'), _('Channel ID'), _('Message')]) + log_w.header().setSectionResizeMode(2, QHeaderView.Stretch) + log_w.header().setSectionResizeMode(1, QHeaderView.ResizeToContents) for payment_attempt_log in log: - if not payment_attempt_log.exception: - route = payment_attempt_log.route - route_str = '%d'%len(route) - if not payment_attempt_log.success: - sender_idx = payment_attempt_log.failure_details.sender_idx - failure_msg = payment_attempt_log.failure_details.failure_msg - blacklist_msg = str(payment_attempt_log.failure_details.is_blacklisted) - short_channel_id = route[sender_idx+1].short_channel_id - data = failure_msg.data - message = repr(failure_msg.code) - else: - short_channel_id = route[-1].short_channel_id - message = _('Success') - blacklist_msg = str(False) - chan_str = str(short_channel_id) - else: - route_str = 'None' - chan_str = 'N/A' - message = str(payment_attempt_log.exception) - blacklist_msg = 'N/A' - x = QTreeWidgetItem([route_str, chan_str, message, blacklist_msg]) + route_str, chan_str, message = payment_attempt_log.formatted_tuple() + x = QTreeWidgetItem([route_str, chan_str, message]) log_w.addTopLevelItem(x) vbox.addWidget(log_w) vbox.addLayout(Buttons(CloseButton(d))) diff --git a/electrum/lnutil.py b/electrum/lnutil.py index 3a7eec25d..41a7b8511 100644 --- a/electrum/lnutil.py +++ b/electrum/lnutil.py @@ -119,6 +119,26 @@ class PaymentAttemptLog(NamedTuple): failure_details: Optional[PaymentAttemptFailureDetails] = None exception: Optional[Exception] = None + def formatted_tuple(self): + if not self.exception: + route = self.route + route_str = '%d'%len(route) + if not self.success: + sender_idx = self.failure_details.sender_idx + failure_msg = self.failure_details.failure_msg + short_channel_id = route[sender_idx+1].short_channel_id + data = failure_msg.data + message = str(failure_msg.code.name) + else: + short_channel_id = route[-1].short_channel_id + message = _('Success') + chan_str = str(short_channel_id) + else: + route_str = 'None' + chan_str = 'N/A' + message = str(self.exception) + return route_str, chan_str, message + class LightningError(Exception): pass class LightningPeerConnectionClosed(LightningError): pass