def network_dialog(self): if not self.network: return net_params = self.network.get_parameters() server_addr = net_params.server proxy_config, auto_connect = net_params.proxy, net_params.auto_connect srv = 'auto-connect' if auto_connect else str(self.network.default_server) out = self.run_dialog('Network', [ {'label':'server', 'type':'str', 'value':srv}, {'label':'proxy', 'type':'str', 'value':self.config.get('proxy', '')}, ], buttons = 1) if out: if out.get('server'): server_str = out.get('server') auto_connect = server_str == 'auto-connect' if not auto_connect: try: server_addr = ServerAddr.from_str(server_str) except Exception: self.show_message("Error:" + server_str + "\nIn doubt, type \"auto-connect\"") return False if out.get('server') or out.get('proxy'): proxy = electrum.network.deserialize_proxy(out.get('proxy')) if out.get('proxy') else proxy_config net_params = NetworkParameters(server=server_addr, proxy=proxy, auto_connect=auto_connect) self.network.run_from_another_thread(self.network.set_parameters(net_params))
def network_dialog(self): if not self.network: return net_params = self.network.get_parameters() host, port, protocol = net_params.host, net_params.port, net_params.protocol proxy_config, auto_connect = net_params.proxy, net_params.auto_connect srv = 'auto-connect' if auto_connect else self.network.default_server out = self.run_dialog('Network', [ { 'label': 'server', 'type': 'str', 'value': srv }, { 'label': 'proxy', 'type': 'str', 'value': self.config.get('proxy', '') }, ], buttons=1) if out: if out.get('server'): server = out.get('server') auto_connect = server == 'auto-connect' if not auto_connect: try: host, port, protocol = deserialize_server(server) except Exception: self.show_message("Error:" + server + "\nIn doubt, type \"auto-connect\"") return False if out.get('server') or out.get('proxy'): proxy = electrum.network.deserialize_proxy( out.get('proxy')) if out.get('proxy') else proxy_config self.network.set_parameters( NetworkParameters(host, port, protocol, proxy, auto_connect))