commit 7d7dcf07956fcc1ae32b76feecb58bee9913ef19
parent dd37151d65c628271d0161b315a81741ef2ce27b
Author: SomberNight <somber.night@protonmail.com>
Date: Mon, 1 Mar 2021 16:41:54 +0100
qt/kivy ChannelsList: if node alias is unknown, display node id
instead of "unknown"
Diffstat:
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/electrum/gui/kivy/uix/dialogs/lightning_channels.py b/electrum/gui/kivy/uix/dialogs/lightning_channels.py
@@ -594,7 +594,7 @@ class LightningChannelsDialog(Factory.Popup):
item.active = not i.is_closed()
item.is_backup = i.is_backup()
item._chan = i
- item.node_alias = lnworker.get_node_alias(i.node_id)
+ item.node_alias = lnworker.get_node_alias(i.node_id) or i.node_id.hex()
self.update_item(item)
channel_cards.add_widget(item)
self.update_can_send()
diff --git a/electrum/gui/qt/channels_list.py b/electrum/gui/qt/channels_list.py
@@ -85,7 +85,7 @@ class ChannelsList(MyTreeView):
labels[subject] = label
status = chan.get_state_for_GUI()
closed = chan.is_closed()
- node_alias = self.lnworker.get_node_alias(chan.node_id)
+ node_alias = self.lnworker.get_node_alias(chan.node_id) or chan.node_id.hex()
if isinstance(chan, Channel):
capacity_str = self.parent.format_amount(chan.constraints.capacity)
else:
diff --git a/electrum/lnworker.py b/electrum/lnworker.py
@@ -270,17 +270,18 @@ class LNWorker(Logger, NetworkRetryManager[LNPeerAddr]):
def channels_for_peer(self, node_id: bytes) -> Dict[bytes, Channel]:
return {}
- def get_node_alias(self, node_id: bytes) -> str:
+ def get_node_alias(self, node_id: bytes) -> Optional[str]:
+ """Returns the alias of the node, or None if unknown."""
+ node_alias = None
if self.channel_db:
node_info = self.channel_db.get_node_info_for_node_id(node_id)
- node_alias = (node_info.alias if node_info else '') or node_id.hex()
+ if node_info:
+ node_alias = node_info.alias
else:
for k, v in hardcoded_trampoline_nodes().items():
if v.pubkey == node_id:
node_alias = k
break
- else:
- node_alias = 'unknown'
return node_alias
async def maybe_listen(self):