tpython3: update storage - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 0fdf661845e28a58093b1222988008b2993147d3 DIR parent bb0174a8de6f90d665924034824412d65114134e HTML Author: ThomasV <thomasv@electrum.org> Date: Wed, 9 Aug 2017 11:06:17 +0200 python3: update storage Diffstat: M lib/storage.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- DIR diff --git a/lib/storage.py b/lib/storage.py t@@ -101,7 +101,7 @@ class WalletStorage(PrintError): def is_encrypted(self): try: - return base64.b64decode(self.raw).startswith('BIE1') + return base64.b64decode(self.raw)[0:4] == b'BIE1' except: return False t@@ -117,6 +117,7 @@ class WalletStorage(PrintError): ec_key = self.get_key(password) s = zlib.decompress(ec_key.decrypt_message(self.raw)) if self.raw else None self.pubkey = ec_key.get_public_key() + s = s.decode('utf8') self.load_data(s) def set_password(self, password, encrypt): t@@ -167,7 +168,10 @@ class WalletStorage(PrintError): return s = json.dumps(self.data, indent=4, sort_keys=True) if self.pubkey: - s = bitcoin.encrypt_message(zlib.compress(s), self.pubkey) + s = bytes(s, 'utf8') + c = zlib.compress(s) + s = bitcoin.encrypt_message(c, self.pubkey) + s = s.decode('utf8') temp_path = "%s.tmp.%s" % (self.path, os.getpid()) with open(temp_path, "w") as f: