mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
fix #2326: backward-compatibility of wallet files
This commit is contained in:
parent
2d8f43d50a
commit
8b2b7cbfb0
1 changed files with 21 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue