commit 9bdac1aae06c4b33a4a04ca6fceb2fe4f97f9c2b
parent 1bd60d4c3a30f49d25cdc26ff567b42cfb95f8a5
Author: ThomasV <thomasv@electrum.org>
Date: Sat, 23 Sep 2017 09:39:12 +0200
detect txintype in keystore. fix #2912
Diffstat:
2 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/lib/keystore.py b/lib/keystore.py
@@ -180,6 +180,9 @@ class Imported_KeyStore(Software_KeyStore):
c = pw_encode(b, new_password)
self.keypairs[k] = c
+ def txin_type(self):
+ return 'standard'
+
class Deterministic_KeyStore(Software_KeyStore):
@@ -274,6 +277,17 @@ class Xpub:
return
return derivation
+ def txin_type(self):
+ xtype = deserialize_xpub(self.xpub)[0]
+ if xtype == 'standard':
+ return 'p2pkh'
+ elif xtype == 'segwit':
+ return 'p2wpkh'
+ elif xtype == 'segwit_p2sh':
+ return 'p2wpkh-p2sh'
+ else:
+ raise BaseException('unknown txin_type', xtype)
+
class BIP32_KeyStore(Deterministic_KeyStore, Xpub):
@@ -477,6 +491,9 @@ class Old_KeyStore(Deterministic_KeyStore):
decoded = pw_decode(self.seed, old_password)
self.seed = pw_encode(decoded, new_password)
+ def txin_type(self):
+ return 'standard'
+
class Hardware_KeyStore(KeyStore, Xpub):
# Derived classes must set:
diff --git a/lib/wallet.py b/lib/wallet.py
@@ -1544,15 +1544,7 @@ class Simple_Wallet(Abstract_Wallet):
def load_keystore(self):
self.keystore = load_keystore(self.storage, 'keystore')
- xtype = deserialize_xpub(self.keystore.xpub)[0]
- 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 = self.keystore.txin_type()
def get_pubkey(self, c, i):
return self.derive_pubkeys(c, i)
@@ -1696,13 +1688,7 @@ class Multisig_Wallet(Deterministic_Wallet):
name = 'x%d/'%(i+1)
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'
+ self.txin_type = self.keystore.txin_type()
def save_keystore(self):
for name, k in self.keystores.items():