electrum

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

commit 079cb311ecec0b42df6d28e22b9dd107cb5f6c2c
parent b70f8c888a33060d7d166e2672cab96002d5fd01
Author: ThomasV <thomasv@electrum.org>
Date:   Thu, 29 Oct 2015 05:01:06 +0100

call wallet.wait_until_synchronized before commands

Diffstat:
Melectrum | 3++-
Mgui/android.py | 2+-
Mgui/gtk.py | 4++--
Mgui/qt/installwizard.py | 2+-
Mlib/wallet.py | 23++++++++++-------------
5 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/electrum b/electrum @@ -153,7 +153,7 @@ def init_cmdline(config): wallet.start_threads(network) print_msg("Recovering wallet...") wallet.synchronize() - wallet.restore(lambda x: x) + wallet.wait_until_synchronized() msg = "Recovery successful" if wallet.is_found() else "Found no history for this wallet" else: msg = "This wallet was restored offline. It may contain more addresses than displayed." @@ -247,6 +247,7 @@ def run_command(config, network, password): # start threads if wallet and network: wallet.start_threads(network) + wallet.wait_until_synchronized() # arguments passed to function args = map(lambda x: config.get(x), cmd.params) # decode json arguments diff --git a/gui/android.py b/gui/android.py @@ -953,7 +953,7 @@ class ElectrumGui: droid.dialogShow() wallet.start_threads(network) if action == 'restore': - wallet.restore(lambda x: None) + wallet.wait_until_synchronized() else: wallet.synchronize() droid.dialogDismiss() diff --git a/gui/gtk.py b/gui/gtk.py @@ -1357,8 +1357,8 @@ class ElectrumGui(): dialog.show() def recover_thread( wallet, dialog ): - wallet.restore(lambda x:x) - GObject.idle_add( dialog.destroy ) + wallet.wait_until_synchronized() + GObject.idle_add(dialog.destroy) thread.start_new_thread( recover_thread, ( wallet, dialog ) ) r = dialog.run() diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py @@ -549,7 +549,7 @@ class InstallWizard(QDialog): wallet.start_threads(self.network) if action == 'restore': - self.waiting_dialog(lambda: wallet.restore(self.waiting_label.setText)) + self.waiting_dialog(lambda: wallet.wait_until_synchronized(self.waiting_label.setText)) if self.network: msg = _("Recovery successful") if wallet.is_found() else _("No transactions found for this seed") else: diff --git a/lib/wallet.py b/lib/wallet.py @@ -314,11 +314,6 @@ class Abstract_Wallet(PrintError): def is_up_to_date(self): with self.lock: return self.up_to_date - def update(self): - self.up_to_date = False - while not self.is_up_to_date(): - time.sleep(0.1) - def is_imported(self, addr): account = self.accounts.get(IMPORTED_ACCOUNT) if account: @@ -1135,21 +1130,23 @@ class Abstract_Wallet(PrintError): self.verifier = None self.storage.put('stored_height', self.get_local_height(), True) - def restore(self, callback): + def wait_until_synchronized(self, callback=None): from i18n import _ def wait_for_wallet(): self.set_up_to_date(False) while not self.is_up_to_date(): - msg = "%s\n%s %d"%( - _("Please wait..."), - _("Addresses generated:"), - len(self.addresses(True))) - apply(callback, (msg,)) + if callback: + msg = "%s\n%s %d"%( + _("Please wait..."), + _("Addresses generated:"), + len(self.addresses(True))) + apply(callback, (msg,)) time.sleep(0.1) def wait_for_network(): while not self.network.is_connected(): - msg = "%s \n" % (_("Connecting...")) - apply(callback, (msg,)) + if callback: + msg = "%s \n" % (_("Connecting...")) + apply(callback, (msg,)) time.sleep(0.1) # wait until we are connected, because the user might have selected another server if self.network: