electrum

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

commit 8b4410d86a9868a12a35c81e7be01659628e63c5
parent 21121297032f55c273bd8cda779c778afcd73917
Author: ecdsa <ecdsa@github>
Date:   Fri, 13 Dec 2013 07:30:35 +0100

detect if electrum is offline during wallet creation

Diffstat:
Mgui/qt/installwizard.py | 10+++++++---
Mgui/qt/main_window.py | 2+-
Mlib/network.py | 15+++++++++------
3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py @@ -268,7 +268,7 @@ class InstallWizard(QDialog): return if not self.verify_seed(wallet): return - ok, _, password = self.password_dialog(wallet) + ok, old_password, password = self.password_dialog(wallet) def create(): wallet.save_seed(password) wallet.synchronize() # generate first addresses offline @@ -287,7 +287,7 @@ class InstallWizard(QDialog): QMessageBox.warning(None, _('Error'), _('Incorrect seed'), _('OK')) return - ok, _, password = self.password_dialog(wallet) + ok, old_password, password = self.password_dialog(wallet) wallet.save_seed(password) @@ -302,7 +302,11 @@ class InstallWizard(QDialog): #if not self.config.get('server'): if self.network: - self.network_dialog() + if self.network.interfaces: + self.network_dialog() + else: + QMessageBox.information(None, _('Warning'), _('You are offline'), _('OK')) + self.network.stop() # start wallet threads wallet.start_threads(self.network) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -533,7 +533,7 @@ class ElectrumWindow(QMainWindow): def update_status(self): - if self.network is None: + if self.network is None or not self.network.is_running(): text = _("Offline") icon = QIcon(":icons/status_disconnected.png") diff --git a/lib/network.py b/lib/network.py @@ -151,8 +151,9 @@ class Network(threading.Thread): if server in self.interfaces.keys(): return i = interface.Interface(server, self.config) - self.interfaces[server] = i + # add it only if it gets connected i.start(self.queue) + return i def start_random_interface(self): server = self.random_server() @@ -160,8 +161,8 @@ class Network(threading.Thread): self.start_interface(server) def start_interfaces(self): - self.start_interface(self.default_server) - self.interface = self.interfaces[self.default_server] + self.interface = self.start_interface(self.default_server) + #self.interface = self.interfaces[self.default_server] for i in range(self.num_server): self.start_random_interface() @@ -252,8 +253,7 @@ class Network(threading.Thread): if server in self.interfaces.keys(): self.switch_to_interface( self.interfaces[server] ) else: - self.start_interface(server) - self.interface = self.interfaces[server] + self.interface = self.start_interface(server) def add_recent_server(self, i): @@ -296,6 +296,8 @@ class Network(threading.Thread): continue if i.is_connected: + #if i.server in self.interfaces: raise + self.interfaces[i.server] = i self.add_recent_server(i) i.send([ ('blockchain.headers.subscribe',[])], self.on_header) if i == self.interface: @@ -304,7 +306,8 @@ class Network(threading.Thread): self.trigger_callback('connected') else: self.disconnected_servers.append(i.server) - self.interfaces.pop(i.server) + if i.server in self.interfaces: + self.interfaces.pop(i.server) if i.server in self.heights: self.heights.pop(i.server) if i == self.interface: