diff --git a/lib/base_wizard.py b/lib/base_wizard.py
index 38343c198..fb7f711a2 100644
--- a/lib/base_wizard.py
+++ b/lib/base_wizard.py
@@ -299,7 +299,7 @@ class BaseWizard(object):
         self.derivation_dialog(f)
 
     def create_keystore(self, seed, passphrase):
-        k = keystore.from_seed(seed, passphrase)
+        k = keystore.from_seed(seed, passphrase, self.wallet_type == 'multisig')
         self.on_keystore(k)
 
     def on_bip43(self, seed, passphrase, derivation):
diff --git a/lib/bitcoin.py b/lib/bitcoin.py
index 5c3437fba..ac9b6f4dd 100644
--- a/lib/bitcoin.py
+++ b/lib/bitcoin.py
@@ -47,19 +47,25 @@ def read_json_dict(filename):
     return r
 
 
+
+
 # Version numbers for BIP32 extended keys
 # standard: xprv, xpub
 # segwit in p2sh: yprv, ypub
 # native segwit: zprv, zpub
 XPRV_HEADERS = {
     'standard': 0x0488ade4,
-    'segwit_p2sh': 0x049d7878,
-    'segwit': 0x4b2430c
+    'p2wpkh-p2sh': 0x049d7878,
+    'p2wsh-p2sh': 0x295b004,
+    'p2wpkh': 0x4b2430c,
+    'p2wsh': 0x2aa7a99
 }
 XPUB_HEADERS = {
     'standard': 0x0488b21e,
-    'segwit_p2sh': 0x049d7cb2,
-    'segwit': 0x4b24746
+    'p2wpkh-p2sh': 0x049d7cb2,
+    'p2wsh-p2sh': 0x295b43e,
+    'p2wpkh': 0x4b24746,
+    'p2wsh': 0x2aa7ed3
 }
 
 
diff --git a/lib/keystore.py b/lib/keystore.py
index a77d58c79..d2b68e095 100644
--- a/lib/keystore.py
+++ b/lib/keystore.py
@@ -681,7 +681,7 @@ def bip44_derivation(account_id, segwit=False):
     coin = 1 if bitcoin.TESTNET else 0
     return "m/%d'/%d'/%d'" % (bip, coin, int(account_id))
 
-def from_seed(seed, passphrase):
+def from_seed(seed, passphrase, is_p2sh):
     t = seed_type(seed)
     if t == 'old':
         keystore = Old_KeyStore({})
@@ -691,7 +691,13 @@ def from_seed(seed, passphrase):
         keystore.add_seed(seed)
         keystore.passphrase = passphrase
         bip32_seed = Mnemonic.mnemonic_to_seed(seed, passphrase)
-        keystore.add_xprv_from_seed(bip32_seed, t, "m/")
+        if t == 'standard':
+            der = "m/"
+            xtype = 'standard'
+        else:
+            der = "m/1'/" if is_p2sh else "m/0'/"
+            xtype = 'p2wsh' if is_p2sh else 'p2wpkh'
+        keystore.add_xprv_from_seed(bip32_seed, xtype, der)
     else:
         raise BaseException(t)
     return keystore
diff --git a/lib/wallet.py b/lib/wallet.py
index 26e7f763b..57a92512a 100644
--- a/lib/wallet.py
+++ b/lib/wallet.py
@@ -1662,14 +1662,7 @@ class Simple_Deterministic_Wallet(Simple_Wallet, Deterministic_Wallet):
             xtype = deserialize_xpub(self.keystore.xpub)[0]
         except:
             xtype = 'standard'
-        if xtype == 'standard':
-            self.txin_type = 'p2pkh'
-        elif xtype == 'segwit':
-            self.txin_type = 'p2wpkh'
-        elif xtype == 'segwit_p2sh':
-            self.txin_type = 'p2wpkh-p2sh'
-        else:
-            raise BaseException('unknown txin_type', xtype)
+        self.txin_type = 'p2pkh' if xtype == 'standard' else xtype
 
     def get_pubkey(self, c, i):
         return self.derive_pubkeys(c, i)
@@ -1731,14 +1724,7 @@ class Multisig_Wallet(Deterministic_Wallet):
             self.keystores[name] = load_keystore(self.storage, name)
         self.keystore = self.keystores['x1/']
         xtype = deserialize_xpub(self.keystore.xpub)[0]
-        if xtype == 'standard':
-            self.txin_type = 'p2sh'
-        elif xtype == 'segwit':
-            self.txin_type = 'p2wsh'
-        elif xtype == 'segwit_p2sh':
-            self.txin_type = 'p2wsh-p2sh'
-        else:
-            raise BaseException('unknown txin_type', xtype)
+        self.txin_type = 'p2sh' if xtype == 'standard' else 'xtype'
 
     def save_keystore(self):
         for name, k in self.keystores.items():