mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
call wallet.wait_until_synchronized before commands
This commit is contained in:
parent
b70f8c888a
commit
079cb311ec
5 changed files with 16 additions and 18 deletions
3
electrum
3
electrum
|
@ -153,7 +153,7 @@ def init_cmdline(config):
|
||||||
wallet.start_threads(network)
|
wallet.start_threads(network)
|
||||||
print_msg("Recovering wallet...")
|
print_msg("Recovering wallet...")
|
||||||
wallet.synchronize()
|
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"
|
msg = "Recovery successful" if wallet.is_found() else "Found no history for this wallet"
|
||||||
else:
|
else:
|
||||||
msg = "This wallet was restored offline. It may contain more addresses than displayed."
|
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
|
# start threads
|
||||||
if wallet and network:
|
if wallet and network:
|
||||||
wallet.start_threads(network)
|
wallet.start_threads(network)
|
||||||
|
wallet.wait_until_synchronized()
|
||||||
# arguments passed to function
|
# arguments passed to function
|
||||||
args = map(lambda x: config.get(x), cmd.params)
|
args = map(lambda x: config.get(x), cmd.params)
|
||||||
# decode json arguments
|
# decode json arguments
|
||||||
|
|
|
@ -953,7 +953,7 @@ class ElectrumGui:
|
||||||
droid.dialogShow()
|
droid.dialogShow()
|
||||||
wallet.start_threads(network)
|
wallet.start_threads(network)
|
||||||
if action == 'restore':
|
if action == 'restore':
|
||||||
wallet.restore(lambda x: None)
|
wallet.wait_until_synchronized()
|
||||||
else:
|
else:
|
||||||
wallet.synchronize()
|
wallet.synchronize()
|
||||||
droid.dialogDismiss()
|
droid.dialogDismiss()
|
||||||
|
|
|
@ -1357,8 +1357,8 @@ class ElectrumGui():
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
def recover_thread( wallet, dialog ):
|
def recover_thread( wallet, dialog ):
|
||||||
wallet.restore(lambda x:x)
|
wallet.wait_until_synchronized()
|
||||||
GObject.idle_add( dialog.destroy )
|
GObject.idle_add(dialog.destroy)
|
||||||
|
|
||||||
thread.start_new_thread( recover_thread, ( wallet, dialog ) )
|
thread.start_new_thread( recover_thread, ( wallet, dialog ) )
|
||||||
r = dialog.run()
|
r = dialog.run()
|
||||||
|
|
|
@ -549,7 +549,7 @@ class InstallWizard(QDialog):
|
||||||
wallet.start_threads(self.network)
|
wallet.start_threads(self.network)
|
||||||
|
|
||||||
if action == 'restore':
|
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:
|
if self.network:
|
||||||
msg = _("Recovery successful") if wallet.is_found() else _("No transactions found for this seed")
|
msg = _("Recovery successful") if wallet.is_found() else _("No transactions found for this seed")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -314,11 +314,6 @@ class Abstract_Wallet(PrintError):
|
||||||
def is_up_to_date(self):
|
def is_up_to_date(self):
|
||||||
with self.lock: return self.up_to_date
|
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):
|
def is_imported(self, addr):
|
||||||
account = self.accounts.get(IMPORTED_ACCOUNT)
|
account = self.accounts.get(IMPORTED_ACCOUNT)
|
||||||
if account:
|
if account:
|
||||||
|
@ -1135,21 +1130,23 @@ class Abstract_Wallet(PrintError):
|
||||||
self.verifier = None
|
self.verifier = None
|
||||||
self.storage.put('stored_height', self.get_local_height(), True)
|
self.storage.put('stored_height', self.get_local_height(), True)
|
||||||
|
|
||||||
def restore(self, callback):
|
def wait_until_synchronized(self, callback=None):
|
||||||
from i18n import _
|
from i18n import _
|
||||||
def wait_for_wallet():
|
def wait_for_wallet():
|
||||||
self.set_up_to_date(False)
|
self.set_up_to_date(False)
|
||||||
while not self.is_up_to_date():
|
while not self.is_up_to_date():
|
||||||
msg = "%s\n%s %d"%(
|
if callback:
|
||||||
_("Please wait..."),
|
msg = "%s\n%s %d"%(
|
||||||
_("Addresses generated:"),
|
_("Please wait..."),
|
||||||
len(self.addresses(True)))
|
_("Addresses generated:"),
|
||||||
apply(callback, (msg,))
|
len(self.addresses(True)))
|
||||||
|
apply(callback, (msg,))
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
def wait_for_network():
|
def wait_for_network():
|
||||||
while not self.network.is_connected():
|
while not self.network.is_connected():
|
||||||
msg = "%s \n" % (_("Connecting..."))
|
if callback:
|
||||||
apply(callback, (msg,))
|
msg = "%s \n" % (_("Connecting..."))
|
||||||
|
apply(callback, (msg,))
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
# wait until we are connected, because the user might have selected another server
|
# wait until we are connected, because the user might have selected another server
|
||||||
if self.network:
|
if self.network:
|
||||||
|
|
Loading…
Add table
Reference in a new issue