electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 85f2f667c3172230a970a181f29a31291c76c0e5
parent aa090007e9ecd1ef149919af565fa90a50513dcf
Author: ThomasV <thomasv@electrum.org>
Date:   Thu, 23 Mar 2017 09:20:32 +0100

fix #2326: backward-compatibility of wallet files

Diffstat:
Mlib/storage.py | 22+++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/lib/storage.py b/lib/storage.py @@ -80,7 +80,27 @@ class WalletStorage(PrintError): try: self.data = json.loads(s) except: - raise IOError("Cannot read wallet file '%s'" % self.path) + try: + d = ast.literal_eval(s) + labels = d.get('labels', {}) + except Exception as e: + raise IOError("Cannot read wallet file '%s'" % self.path) + self.data = {} + # In old versions of Electrum labels were latin1 encoded, this fixes breakage. + for i, label in labels.items(): + try: + unicode(label) + except UnicodeDecodeError: + d['labels'][i] = unicode(label.decode('latin1')) + for key, value in d.items(): + try: + json.dumps(key) + json.dumps(value) + except: + self.print_error('Failed to convert label to json format', key) + continue + self.data[key] = value + # check here if I need to load a plugin t = self.get('wallet_type') l = plugin_loaders.get(t)