tkivy: fix "choose from peers" in network server-select popup - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 6d1acc929ad77c7ead58489c7db78b446c240aa8 DIR parent 41aa50a3f366e9923c843ea00944558741b86011 HTML Author: SomberNight <somber.night@protonmail.com> Date: Wed, 13 May 2020 19:05:07 +0200 kivy: fix "choose from peers" in network server-select popup follow-up 9e57ae630ba96e6d2c40288d2633aeca8d20764d fixes #6161 Diffstat: M electrum/gui/kivy/main_window.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) --- DIR diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py t@@ -19,6 +19,7 @@ from electrum.util import (profiler, InvalidPassword, send_exception_to_crash_re PR_PAID, PR_FAILED, maybe_extract_bolt11_invoice) from electrum import blockchain from electrum.network import Network, TxBroadcastError, BestEffortRequestFailed +from electrum.interface import PREFERRED_NETWORK_PROTOCOL, ServerAddr from .i18n import _ from kivy.app import App t@@ -135,18 +136,19 @@ class ElectrumWindow(App): def choose_server_dialog(self, popup): from .uix.dialogs.choice_dialog import ChoiceDialog - protocol = 's' - def cb2(host): - from electrum import constants - pp = servers.get(host, constants.net.DEFAULT_PORTS) - port = pp.get(protocol, '') - popup.ids.host.text = host - popup.ids.port.text = port + protocol = PREFERRED_NETWORK_PROTOCOL + def cb2(server_str): + popup.ids.server_str.text = server_str servers = self.network.get_servers() - ChoiceDialog(_('Choose a server'), sorted(servers), popup.ids.host.text, cb2).open() + server_choices = {} + for _host, d in sorted(servers.items()): + port = d.get(protocol) + if port: + server = ServerAddr(_host, port, protocol=protocol) + server_choices[server.net_addr_str()] = _host + ChoiceDialog(_('Choose a server'), server_choices, popup.ids.server_str.text, cb2).open() def maybe_switch_to_server(self, server_str: str): - from electrum.interface import ServerAddr net_params = self.network.get_parameters() try: server = ServerAddr.from_str_with_inference(server_str)