Browse Source

fixes for android: restore from seed

283
ThomasV 11 years ago
parent
commit
14b5a3afd8
  1. 47
      gui/android.py
  2. 2
      lib/wallet.py

47
gui/android.py

@ -705,7 +705,7 @@ def server_dialog(servers):
return response return response
def seed_dialog(): def show_seed():
if wallet.use_encryption: if wallet.use_encryption:
password = droid.dialogGetPassword('Seed').result password = droid.dialogGetPassword('Seed').result
if not password: return if not password: return
@ -817,7 +817,7 @@ def settings_loop():
set_listview() set_listview()
elif pos == "5": elif pos == "5":
seed_dialog() show_seed()
if network_changed: if network_changed:
proxy = None proxy = None
@ -892,11 +892,37 @@ class ElectrumGui:
storage = WalletStorage(config) storage = WalletStorage(config)
if not storage.file_exists: if not storage.file_exists:
print "Wallet not found. try 'electrum create'" action = self.restore_or_create()
exit() if not action: exit()
wallet = Wallet(storage)
if action == 'create':
wallet.init_seed(None)
self.show_seed()
wallet.save_seed()
wallet.create_accounts()
wallet.synchronize() # generate first addresses offline
elif action == 'restore':
seed = self.seed_dialog()
if not seed:
exit()
wallet.init_seed(str(seed))
wallet.save_seed()
else:
exit()
wallet.start_threads(network)
wallet = Wallet(storage) if action == 'restore':
wallet.start_threads(network) if not self.restore_wallet():
exit()
self.password_dialog(wallet)
else:
wallet = Wallet(storage)
wallet.start_threads(network)
def main(self, url): def main(self, url):
@ -946,7 +972,7 @@ class ElectrumGui:
def seed_dialog(self): def seed_dialog(self):
if modal_question("Input method",None,'QR Code', 'mnemonic'): if modal_question("Enter your seed","Input method",'QR Code', 'mnemonic'):
code = droid.scanBarcode() code = droid.scanBarcode()
r = code.result r = code.result
if r: if r:
@ -961,9 +987,7 @@ class ElectrumGui:
modal_dialog('error: could not decode this seed') modal_dialog('error: could not decode this seed')
return return
gap = 5 # default return str(seed)
return str(seed), gap
def network_dialog(self): def network_dialog(self):
@ -988,7 +1012,7 @@ class ElectrumGui:
droid.dialogCreateSpinnerProgress("Electrum", msg) droid.dialogCreateSpinnerProgress("Electrum", msg)
droid.dialogShow() droid.dialogShow()
wallet.update() wallet.restore(lambda x: None)
droid.dialogDismiss() droid.dialogDismiss()
droid.vibrate() droid.vibrate()
@ -1000,6 +1024,5 @@ class ElectrumGui:
if not modal_question("no transactions found for this seed","do you want to keep this wallet?"): if not modal_question("no transactions found for this seed","do you want to keep this wallet?"):
return False return False
wallet.save()
return True return True

2
lib/wallet.py

@ -126,7 +126,7 @@ class WalletStorage:
f = open(self.path,"w") f = open(self.path,"w")
f.write( s ) f.write( s )
f.close() f.close()
if self.get('gui') != 'android': if 'ANDROID_DATA' not in os.environ:
import stat import stat
os.chmod(self.path,stat.S_IREAD | stat.S_IWRITE) os.chmod(self.path,stat.S_IREAD | stat.S_IWRITE)

Loading…
Cancel
Save