electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 6c2ef176cceb7a1cb1c08550a22d0ee4c1b27d6b
parent d19fc56eb8875c16ced4ee7be0f048277f95189a
Author: ThomasV <thomasv@electrum.org>
Date:   Tue, 10 Mar 2020 16:44:23 +0100

kivy: show payment log details

Diffstat:
Melectrum/gui/kivy/uix/dialogs/invoice_dialog.py | 5++++-
Melectrum/gui/qt/invoice_list.py | 31+++++++------------------------
Melectrum/lnutil.py | 20++++++++++++++++++++
3 files changed, 31 insertions(+), 25 deletions(-)

diff --git 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 @@ -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 @@ -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