Initial novacoin support
[electrum-nvc.git] / gui / qt / installwizard.py
index b84cd84..f3b30a4 100644 (file)
@@ -2,10 +2,10 @@ from PyQt4.QtGui import *
 from PyQt4.QtCore import *
 import PyQt4.QtCore as QtCore
 
-from electrum.i18n import _
-from electrum import Wallet, Wallet_2of2, Wallet_2of3
-from electrum import bitcoin
-from electrum import util
+from electrum_nvc.i18n import _
+from electrum_nvc import Wallet, Wallet_2of2, Wallet_2of3
+from electrum_nvc import bitcoin
+from electrum_nvc import util
 
 import seed_dialog
 from network_dialog import NetworkDialog
@@ -14,10 +14,10 @@ from amountedit import AmountEdit
 
 import sys
 import threading
-from electrum.plugins import run_hook
+from electrum_nvc.plugins import run_hook
 
 
-MSG_ENTER_ANYTHING    = _("Please enter a wallet seed, a master public key, a list of Bitcoin addresses, or a list of private keys")
+MSG_ENTER_ANYTHING    = _("Please enter a wallet seed, a master public key, a list of Novacoin addresses, or a list of private keys")
 MSG_SHOW_MPK          = _("This is your master public key")
 MSG_ENTER_MPK         = _("Please enter your master public key")
 MSG_ENTER_COLD_MPK    = _("Please enter the master public key of your cosigner wallet")
@@ -493,6 +493,10 @@ class InstallWizard(QDialog):
                     return
                 text1, text2 = r
                 wallet = Wallet_2of2(self.storage)
+                if Wallet.is_seed(text1) or Wallet.is_seed(text2):
+                    password = self.password_dialog()
+                else:
+                    password = None
 
                 if Wallet.is_seed(text1):
                     wallet.add_seed(text1, password)
@@ -500,8 +504,8 @@ class InstallWizard(QDialog):
                         wallet.add_cold_seed(text2, password)
                     else:
                         wallet.add_master_public_key("cold/", text2)
-
-                elif Wallet.is_xpub(text1):
+                else:
+                    assert Wallet.is_xpub(text1)
                     if Wallet.is_seed(text2):
                         wallet.add_seed(text2, password)
                         wallet.add_master_public_key("cold/", text1)
@@ -509,11 +513,7 @@ class InstallWizard(QDialog):
                         wallet.add_master_public_key("m/", text1)
                         wallet.add_master_public_key("cold/", text2)
 
-                if wallet.is_watching_only():
-                    wallet.create_accounts(None)
-                else:
-                    password = self.password_dialog()
-                    wallet.create_accounts(password)
+                wallet.create_accounts(password)
 
 
             elif t in ['2of3']:
@@ -521,8 +521,11 @@ class InstallWizard(QDialog):
                 if not r: 
                     return
                 text1, text2, text3 = r
-                password = self.password_dialog()
                 wallet = Wallet_2of3(self.storage)
+                if Wallet.is_seed(text1) or Wallet.is_seed(text2) or Wallet.is_seed(text3):
+                    password = self.password_dialog()
+                else:
+                    password = None
 
                 if Wallet.is_seed(text1):
                     wallet.add_seed(text1, password)
@@ -542,8 +545,9 @@ class InstallWizard(QDialog):
                 wallet.create_accounts(password)
 
             else:
-                raise
-
+                wallet = run_hook('installwizard_restore', self, self.storage)
+                if not wallet:
+                    return
 
             # create first keys offline
             self.waiting_dialog(wallet.synchronize)