electrum

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

commit b505763867f8283aeab62412981c758d45b88d56
parent e6e587b7da58a4fb3da451fef4af8fddd8715d01
Author: ThomasV <thomasv@electrum.org>
Date:   Fri, 29 May 2020 19:23:29 +0200

Qt: do not show node_id in channels_list

Diffstat:
Melectrum/channel_db.py | 1+
Melectrum/gui/qt/channels_list.py | 37+++++++++++++++++++++----------------
Melectrum/gui/qt/main_window.py | 4+++-
3 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/electrum/channel_db.py b/electrum/channel_db.py @@ -650,6 +650,7 @@ class ChannelDB(SqlDB): self.logger.info(f'num_channels_partitioned_by_policy_count. ' f'0p: {nchans_with_0p}, 1p: {nchans_with_1p}, 2p: {nchans_with_2p}') self.data_loaded.set() + util.trigger_callback('gossip_db_loaded') def _update_num_policies_for_chan(self, short_channel_id: ShortChannelID) -> None: channel_info = self.get_channel_info(short_channel_id) diff --git a/electrum/gui/qt/channels_list.py b/electrum/gui/qt/channels_list.py @@ -27,18 +27,17 @@ ROLE_CHANNEL_ID = Qt.UserRole class ChannelsList(MyTreeView): update_rows = QtCore.pyqtSignal(Abstract_Wallet) update_single_row = QtCore.pyqtSignal(AbstractChannel) + gossip_db_loaded = QtCore.pyqtSignal() class Columns(IntEnum): SHORT_CHANID = 0 - NODE_ID = 1 - NODE_ALIAS = 2 - LOCAL_BALANCE = 3 - REMOTE_BALANCE = 4 - CHANNEL_STATUS = 5 + NODE_ALIAS = 1 + LOCAL_BALANCE = 2 + REMOTE_BALANCE = 3 + CHANNEL_STATUS = 4 headers = { Columns.SHORT_CHANID: _('Short Channel ID'), - Columns.NODE_ID: _('Node ID'), Columns.NODE_ALIAS: _('Node alias'), Columns.LOCAL_BALANCE: _('Local'), Columns.REMOTE_BALANCE: _('Remote'), @@ -48,11 +47,12 @@ class ChannelsList(MyTreeView): _default_item_bg_brush = None # type: Optional[QBrush] def __init__(self, parent): - super().__init__(parent, self.create_menu, stretch_column=self.Columns.NODE_ID, + super().__init__(parent, self.create_menu, stretch_column=self.Columns.NODE_ALIAS, editable_columns=[]) self.setModel(QtGui.QStandardItemModel(self)) self.setSelectionMode(QAbstractItemView.ExtendedSelection) self.main_window = parent + self.gossip_db_loaded.connect(self.on_gossip_db) self.update_rows.connect(self.do_update_rows) self.update_single_row.connect(self.do_update_single_row) self.network = self.parent.network @@ -80,7 +80,6 @@ class ChannelsList(MyTreeView): node_alias = '' return [ chan.short_id_for_GUI(), - bh2u(chan.node_id), node_alias, '' if closed else labels[LOCAL], '' if closed else labels[REMOTE], @@ -141,7 +140,7 @@ class ChannelsList(MyTreeView): def create_menu(self, position): menu = QMenu() menu.setSeparatorsCollapsible(True) # consecutive separators are merged together - selected = self.selected_in_column(self.Columns.NODE_ID) + selected = self.selected_in_column(self.Columns.NODE_ALIAS) if not selected: return multi_select = len(selected) > 1 @@ -153,7 +152,7 @@ class ChannelsList(MyTreeView): item = self.model().itemFromIndex(idx) if not item: return - channel_id = idx.sibling(idx.row(), self.Columns.NODE_ID).data(ROLE_CHANNEL_ID) + channel_id = idx.sibling(idx.row(), self.Columns.NODE_ALIAS).data(ROLE_CHANNEL_ID) if channel_id in self.lnbackups.channel_backups: menu.addAction(_("Request force-close"), lambda: self.request_force_close(channel_id)) menu.addAction(_("Delete"), lambda: self.remove_channel_backup(channel_id)) @@ -162,8 +161,10 @@ class ChannelsList(MyTreeView): chan = self.lnworker.channels[channel_id] menu.addAction(_("Details..."), lambda: self.parent.show_channel(channel_id)) cc = self.add_copy_menu(menu, idx) - cc.addAction(_("Long Channel ID"), lambda: self.place_text_on_clipboard(channel_id.hex(), - title=_("Long Channel ID"))) + cc.addAction(_("Node ID"), lambda: self.place_text_on_clipboard( + chan.node_id.hex(), title=_("Node ID"))) + cc.addAction(_("Long Channel ID"), lambda: self.place_text_on_clipboard( + channel_id.hex(), title=_("Long Channel ID"))) if not chan.is_closed(): if not chan.is_frozen_for_sending(): menu.addAction(_("Freeze (for sending)"), lambda: chan.set_frozen_for_sending(True)) @@ -202,7 +203,7 @@ class ChannelsList(MyTreeView): if not lnworker: return for row in range(self.model().rowCount()): - item = self.model().item(row, self.Columns.NODE_ID) + item = self.model().item(row, self.Columns.NODE_ALIAS) if item.data(ROLE_CHANNEL_ID) != chan.channel_id: continue for column, v in enumerate(self.format_fields(chan)): @@ -211,6 +212,10 @@ class ChannelsList(MyTreeView): self._update_chan_frozen_bg(chan=chan, items=items) self.update_can_send(lnworker) + @QtCore.pyqtSlot() + def on_gossip_db(self): + self.do_update_rows(self.parent.wallet) + @QtCore.pyqtSlot(Abstract_Wallet) def do_update_rows(self, wallet): if wallet != self.parent.wallet: @@ -225,9 +230,9 @@ class ChannelsList(MyTreeView): items = [QtGui.QStandardItem(x) for x in self.format_fields(chan)] self.set_editability(items) if self._default_item_bg_brush is None: - self._default_item_bg_brush = items[self.Columns.NODE_ID].background() - items[self.Columns.NODE_ID].setData(chan.channel_id, ROLE_CHANNEL_ID) - items[self.Columns.NODE_ID].setFont(QFont(MONOSPACE_FONT)) + self._default_item_bg_brush = items[self.Columns.NODE_ALIAS].background() + items[self.Columns.NODE_ALIAS].setData(chan.channel_id, ROLE_CHANNEL_ID) + items[self.Columns.NODE_ALIAS].setFont(QFont(MONOSPACE_FONT)) items[self.Columns.LOCAL_BALANCE].setFont(QFont(MONOSPACE_FONT)) items[self.Columns.REMOTE_BALANCE].setFont(QFont(MONOSPACE_FONT)) self._update_chan_frozen_bg(chan=chan, items=items) diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py @@ -262,7 +262,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): 'on_history', 'channel', 'channels_updated', 'payment_failed', 'payment_succeeded', 'invoice_status', 'request_status', 'ln_gossip_sync_progress', - 'cert_mismatch'] + 'cert_mismatch', 'gossip_db_loaded'] # To avoid leaking references to "self" that prevent the # window from being GC-ed when closed, callbacks should be # methods of this class only, and specifically not be @@ -411,6 +411,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): self.on_fx_quotes() elif event == 'on_history': self.on_fx_history() + elif event == 'gossip_db_loaded': + self.channels_list.gossip_db_loaded.emit(*args) elif event == 'channels_updated': self.channels_list.update_rows.emit(*args) elif event == 'channel':