URI: 
       tfixes for android: restore from seed - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 14b5a3afd8b51e7a1133c7c1180bcc73c720ae4a
   DIR parent d2af935fc7d0f5cc81aaa88259050c904c4b8e45
  HTML Author: ThomasV <thomasv@gitorious>
       Date:   Tue,  8 Oct 2013 14:12:56 +0200
       
       fixes for android: restore from seed
       
       Diffstat:
         M gui/android.py                      |      47 +++++++++++++++++++++++--------
         M lib/wallet.py                       |       2 +-
       
       2 files changed, 36 insertions(+), 13 deletions(-)
       ---
   DIR diff --git a/gui/android.py b/gui/android.py
       t@@ -705,7 +705,7 @@ def server_dialog(servers):
                return response
        
        
       -def seed_dialog():
       +def show_seed():
            if wallet.use_encryption:
                password  = droid.dialogGetPassword('Seed').result
                if not password: return
       t@@ -817,7 +817,7 @@ def settings_loop():
                            set_listview()
        
                    elif pos == "5":
       -                seed_dialog()
       +                show_seed()
        
                    if network_changed:
                        proxy = None
       t@@ -892,11 +892,37 @@ class ElectrumGui:
                
                storage = WalletStorage(config)
                if not storage.file_exists:
       -            print "Wallet not found. try 'electrum create'"
       -            exit()
       +            action = self.restore_or_create()
       +            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)
       -        wallet.start_threads(network)
       +            if action == 'restore':
       +                if not self.restore_wallet():
       +                    exit()
       +
       +            self.password_dialog(wallet)
       +
       +        else:
       +            wallet = Wallet(storage)
       +            wallet.start_threads(network)
        
        
            def main(self, url):
       t@@ -946,7 +972,7 @@ class ElectrumGui:
        
        
            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()
                    r = code.result
                    if r:
       t@@ -961,9 +987,7 @@ class ElectrumGui:
                        modal_dialog('error: could not decode this seed')
                        return
        
       -        gap = 5   # default
       -
       -        return str(seed), gap
       +        return str(seed)
        
        
            def network_dialog(self):
       t@@ -988,7 +1012,7 @@ class ElectrumGui:
                droid.dialogCreateSpinnerProgress("Electrum", msg)
                droid.dialogShow()
        
       -        wallet.update()
       +        wallet.restore(lambda x: None)
        
                droid.dialogDismiss()
                droid.vibrate()
       t@@ -1000,6 +1024,5 @@ class ElectrumGui:
                    if not modal_question("no transactions found for this seed","do you want to keep this wallet?"):
                        return False
        
       -        wallet.save()
                return True
        
   DIR diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -126,7 +126,7 @@ class WalletStorage:
                f = open(self.path,"w")
                f.write( s )
                f.close()
       -        if self.get('gui') != 'android':
       +        if 'ANDROID_DATA' not in os.environ:
                    import stat
                    os.chmod(self.path,stat.S_IREAD | stat.S_IWRITE)