Browse Source

python3: fix password decode

seed_v14
ThomasV 7 years ago
parent
commit
108d7d39f0
  1. 2
      lib/bitcoin.py
  2. 12
      lib/keystore.py

2
lib/bitcoin.py

@ -150,7 +150,7 @@ def DecodeAES(secret, e):
def pw_encode(s, password):
if password:
secret = Hash(password)
return EncodeAES(secret, to_bytes(s, "utf8"))
return EncodeAES(secret, to_bytes(s, "utf8")).decode('utf8')
else:
return s

12
lib/keystore.py

@ -149,7 +149,7 @@ class Imported_KeyStore(Software_KeyStore):
except Exception:
raise BaseException('Invalid private key')
# allow overwrite
self.keypairs[pubkey] = pw_encode(sec, password).decode('ascii')
self.keypairs[pubkey] = pw_encode(sec, password)
return pubkey
def delete_imported_key(self, key):
@ -179,7 +179,7 @@ class Imported_KeyStore(Software_KeyStore):
new_password = None
for k, v in self.keypairs.items():
b = pw_decode(v, old_password)
c = pw_encode(b, new_password).decode('ascii')
c = pw_encode(b, new_password)
self.keypairs[k] = c
@ -309,13 +309,13 @@ class BIP32_KeyStore(Deterministic_KeyStore, Xpub):
new_password = None
if self.has_seed():
decoded = self.get_seed(old_password)
self.seed = pw_encode(decoded, new_password).decode('ascii')
self.seed = pw_encode(decoded, new_password)
if self.passphrase:
decoded = self.get_passphrase(old_password)
self.passphrase = pw_encode(decoded, new_password).decode('ascii')
self.passphrase = pw_encode(decoded, new_password)
if self.xprv is not None:
b = pw_decode(self.xprv, old_password)
self.xprv = pw_encode(b, new_password).decode('ascii')
self.xprv = pw_encode(b, new_password)
def is_watching_only(self):
return self.xprv is None
@ -478,7 +478,7 @@ class Old_KeyStore(Deterministic_KeyStore):
new_password = None
if self.has_seed():
decoded = self.get_hex_seed(old_password)
self.seed = pw_encode(decoded, new_password).decode('ascii')
self.seed = pw_encode(decoded, new_password)
class Hardware_KeyStore(KeyStore, Xpub):

Loading…
Cancel
Save