stop using eval
[electrum-nvc.git] / electrum
index b0185ce..b082782 100755 (executable)
--- a/electrum
+++ b/electrum
@@ -100,7 +100,7 @@ def print_help_cb(self, opt, value, parser):
 
 def run_command(cmd, password = None, args = []):
     cmd_runner = Commands(wallet, network)
-    func = eval('cmd_runner.' + cmd)
+    func = getattr(cmd_runner, cmd)
     cmd_runner.password = password
     try:
         result = func(*args[1:])
@@ -126,7 +126,7 @@ if __name__ == '__main__':
     if is_android:
         config_options = {'portable':True, 'verbose':True, 'gui':'android', 'auto_cycle':True}
     else:
-        config_options = eval(str(options))
+        config_options = vars(options)
         for k, v in config_options.items():
             if v is None: config_options.pop(k)
 
@@ -215,7 +215,7 @@ if __name__ == '__main__':
             seed = getpass.getpass(prompt = "seed:", stream = None) if options.concealed else raw_input("seed:")
             try:
                 seed.decode('hex')
-            except:
+            except Exception:
                 print_error("Warning: Not hex, trying decode.")
                 seed = mnemonic_decode( seed.split(' ') )
             if not seed:
@@ -236,14 +236,12 @@ if __name__ == '__main__':
                 else:
                     print_msg("Warning: Found no history for this wallet")
             else:
-                wallet.create_accounts()
                 wallet.synchronize()
                 print_msg("Warning: This wallet was restored offline. It may contain more addresses than displayed.")
 
         else:
             wallet.init_seed(None)
             wallet.save_seed()
-            wallet.create_accounts()
             wallet.synchronize()
             print_msg("Your wallet generation seed is:\n\"%s\""% wallet.get_mnemonic(None))
             print_msg("Please keep it in a safe place; if you lose it, you will not be able to restore your wallet.")
@@ -274,7 +272,7 @@ if __name__ == '__main__':
             # check password
             try:
                 seed = wallet.get_seed(password)
-            except:
+            except Exception:
                 print_msg("Error: This password does not decode this wallet.")
                 exit(1)
         else: