android create and restore
This commit is contained in:
parent
ed59498ccc
commit
52b43c57b8
|
@ -907,31 +907,43 @@ class ElectrumGui:
|
||||||
storage = WalletStorage(config)
|
storage = WalletStorage(config)
|
||||||
if not storage.file_exists:
|
if not storage.file_exists:
|
||||||
action = self.restore_or_create()
|
action = self.restore_or_create()
|
||||||
if not action: exit()
|
if not action:
|
||||||
|
exit()
|
||||||
|
|
||||||
|
password = droid.dialogGetPassword('Choose a password').result
|
||||||
|
if password:
|
||||||
|
password2 = droid.dialogGetPassword('Confirm password').result
|
||||||
|
if password != password2:
|
||||||
|
modal_dialog('Error','passwords do not match')
|
||||||
|
exit()
|
||||||
|
|
||||||
wallet = Wallet(storage)
|
|
||||||
if action == 'create':
|
if action == 'create':
|
||||||
wallet.init_seed(None)
|
wallet = Wallet(storage)
|
||||||
self.show_seed()
|
seed = wallet.make_seed()
|
||||||
wallet.save_seed(None)
|
modal_dialog('Your seed is:', seed)
|
||||||
wallet.synchronize() # generate first addresses offline
|
|
||||||
|
|
||||||
elif action == 'restore':
|
elif action == 'restore':
|
||||||
seed = self.seed_dialog()
|
seed = self.seed_dialog()
|
||||||
if not seed:
|
if not seed:
|
||||||
exit()
|
exit()
|
||||||
wallet.init_seed(str(seed))
|
if not Wallet.is_seed(seed):
|
||||||
wallet.save_seed(None)
|
exit()
|
||||||
|
wallet = Wallet.from_seed(seed, storage)
|
||||||
else:
|
else:
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
msg = "Creating wallet" if action == 'create' else "Restoring wallet"
|
||||||
|
droid.dialogCreateSpinnerProgress("Electrum", msg)
|
||||||
|
droid.dialogShow()
|
||||||
|
wallet.add_seed(seed, password)
|
||||||
|
wallet.create_master_keys(password)
|
||||||
|
wallet.create_main_account(password)
|
||||||
wallet.start_threads(network)
|
wallet.start_threads(network)
|
||||||
|
|
||||||
if action == 'restore':
|
if action == 'restore':
|
||||||
if not self.restore_wallet():
|
wallet.restore(lambda x: None)
|
||||||
exit()
|
else:
|
||||||
|
wallet.synchronize()
|
||||||
self.password_dialog()
|
droid.dialogDismiss()
|
||||||
|
droid.vibrate()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
wallet = Wallet(storage)
|
wallet = Wallet(storage)
|
||||||
|
@ -978,7 +990,6 @@ class ElectrumGui:
|
||||||
if not response: return
|
if not response: return
|
||||||
if response.get('which') == 'negative':
|
if response.get('which') == 'negative':
|
||||||
return
|
return
|
||||||
|
|
||||||
return 'restore' if response.get('which') == 'neutral' else 'create'
|
return 'restore' if response.get('which') == 'neutral' else 'create'
|
||||||
|
|
||||||
|
|
||||||
|
@ -992,39 +1003,6 @@ class ElectrumGui:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
m = modal_input('Mnemonic','please enter your code')
|
m = modal_input('Mnemonic','please enter your code')
|
||||||
|
|
||||||
return str(seed)
|
return str(seed)
|
||||||
|
|
||||||
|
|
||||||
def network_dialog(self):
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def show_seed(self):
|
|
||||||
modal_dialog('Your seed is:', wallet.get_mnemonic(None))
|
|
||||||
|
|
||||||
|
|
||||||
def password_dialog(self):
|
|
||||||
change_password_dialog()
|
|
||||||
|
|
||||||
|
|
||||||
def restore_wallet(self):
|
|
||||||
|
|
||||||
msg = "recovering wallet..."
|
|
||||||
droid.dialogCreateSpinnerProgress("Electrum", msg)
|
|
||||||
droid.dialogShow()
|
|
||||||
|
|
||||||
wallet.restore(lambda x: None)
|
|
||||||
|
|
||||||
droid.dialogDismiss()
|
|
||||||
droid.vibrate()
|
|
||||||
|
|
||||||
if wallet.is_found():
|
|
||||||
wallet.fill_addressbook()
|
|
||||||
modal_dialog("recovery successful")
|
|
||||||
else:
|
|
||||||
if not modal_question("no transactions found for this seed","do you want to keep this wallet?"):
|
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
|
@ -1230,7 +1230,9 @@ class Deterministic_Wallet(Abstract_Wallet):
|
||||||
wait_for_wallet()
|
wait_for_wallet()
|
||||||
else:
|
else:
|
||||||
self.synchronize()
|
self.synchronize()
|
||||||
self.fill_addressbook()
|
|
||||||
|
# disable this because it crashes android
|
||||||
|
#self.fill_addressbook()
|
||||||
|
|
||||||
|
|
||||||
def is_beyond_limit(self, address, account, is_change):
|
def is_beyond_limit(self, address, account, is_change):
|
||||||
|
|
Loading…
Reference in New Issue