Browse Source

restore: try old wallet first

283
thomasv 12 years ago
parent
commit
9b986f8cb6
  1. 53
      gui/installwizard.py
  2. 4
      lib/wallet.py

53
gui/installwizard.py

@ -123,14 +123,18 @@ class InstallWizard(QDialog):
waiting = lambda: False if wallet.is_up_to_date() else "%s\n%s %d\n%s %.1f"\
%(_("Please wait..."),_("Addresses generated:"),len(wallet.addresses(True)),_("Kilobytes received:"), wallet.interface.bytes_received/1024.)
# try to restore old account
wallet.create_old_account()
wallet.set_up_to_date(False)
wallet.interface.poke('synchronizer')
waiting_dialog(waiting)
# try to restore old account
if not wallet.is_found():
print "trying old method"
wallet.create_old_account()
if wallet.is_found():
wallet.seed_version = 4
wallet.storage.put('seed_version', wallet.seed_version, True)
else:
wallet.accounts.pop(0)
wallet.create_accounts()
wallet.set_up_to_date(False)
wallet.interface.poke('synchronizer')
waiting_dialog(waiting)
@ -145,25 +149,39 @@ class InstallWizard(QDialog):
def run(self):
a = self.restore_or_create()
if not a: exit()
action = self.restore_or_create()
if not action: exit()
# select a server.
s = self.network_dialog()
if s is None:
self.config.set_key("server", None, True)
self.config.set_key('auto_cycle', False, True)
wallet = Wallet(self.storage)
if a =='create':
if action =='create':
wallet.init_seed(None)
self.show_seed(wallet)
if self.verify_seed(wallet):
wallet.save_seed()
wallet.create_accounts()
# generate first addresses offline
wallet.synchronize()
else:
exit()
else:
return
elif action == 'restore':
# ask for seed and gap.
sg = self.seed_dialog()
if not sg: exit()
if not sg:
return
seed, gap = sg
if not seed: exit()
if not seed:
return
wallet.gap_limit = gap
if len(seed) == 128:
wallet.seed = ''
wallet.init_sequence(str(seed))
@ -171,21 +189,14 @@ class InstallWizard(QDialog):
wallet.init_seed(str(seed))
wallet.save_seed()
# select a server.
s = self.network_dialog()
if s is None:
self.config.set_key("server", None, True)
self.config.set_key('auto_cycle', False, True)
# generate the first addresses, in case we are offline
if s is None or a == 'create':
wallet.synchronize()
# start wallet threads
wallet.start_threads(self.interface, self.blockchain)
# if it is a creation, use 5
# if restore, use 4 then 5
if a == 'restore' and s is not None:
if action == 'restore' and s is not None:
try:
keep_it = self.restore_wallet(wallet)
wallet.fill_addressbook()

4
lib/wallet.py

@ -238,6 +238,9 @@ class Wallet:
self.storage.put('seed', self.seed, True)
self.storage.put('seed_version', self.seed_version, True)
def create_accounts(self):
master_k, master_c, master_K, master_cK = bip32_init(self.seed)
# normal accounts
@ -1331,6 +1334,7 @@ class Wallet:
class WalletSynchronizer(threading.Thread):

Loading…
Cancel
Save