mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
storage: refuse to open newer version wallet files
This is mostly a manual copy of parts of multiple commits from the master branch.
This commit is contained in:
parent
64d998fae8
commit
d0f9e20cf7
2 changed files with 14 additions and 4 deletions
|
@ -168,7 +168,12 @@ class ElectrumGui:
|
||||||
w.bring_to_top()
|
w.bring_to_top()
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
wallet = self.daemon.load_wallet(path, None)
|
try:
|
||||||
|
wallet = self.daemon.load_wallet(path, None)
|
||||||
|
except BaseException as e:
|
||||||
|
d = QMessageBox(QMessageBox.Warning, _('Error'), 'Cannot load wallet:\n' + str(e))
|
||||||
|
d.exec_()
|
||||||
|
return
|
||||||
if not wallet:
|
if not wallet:
|
||||||
storage = WalletStorage(path)
|
storage = WalletStorage(path)
|
||||||
wizard = InstallWizard(self.config, self.app, self.plugins, storage)
|
wizard = InstallWizard(self.config, self.app, self.plugins, storage)
|
||||||
|
|
|
@ -75,6 +75,9 @@ class WalletStorage(PrintError):
|
||||||
self.raw = f.read()
|
self.raw = f.read()
|
||||||
if not self.is_encrypted():
|
if not self.is_encrypted():
|
||||||
self.load_data(self.raw)
|
self.load_data(self.raw)
|
||||||
|
else:
|
||||||
|
# avoid new wallets getting 'upgraded'
|
||||||
|
self.put('seed_version', FINAL_SEED_VERSION)
|
||||||
|
|
||||||
def load_data(self, s):
|
def load_data(self, s):
|
||||||
try:
|
try:
|
||||||
|
@ -161,8 +164,6 @@ class WalletStorage(PrintError):
|
||||||
|
|
||||||
@profiler
|
@profiler
|
||||||
def write(self):
|
def write(self):
|
||||||
# this ensures that previous versions of electrum won't open the wallet
|
|
||||||
self.put('seed_version', FINAL_SEED_VERSION)
|
|
||||||
with self.lock:
|
with self.lock:
|
||||||
self._write()
|
self._write()
|
||||||
|
|
||||||
|
@ -244,12 +245,14 @@ class WalletStorage(PrintError):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def requires_upgrade(self):
|
def requires_upgrade(self):
|
||||||
return self.file_exists() and self.get_seed_version() != FINAL_SEED_VERSION
|
return self.file_exists() and self.get_seed_version() < FINAL_SEED_VERSION
|
||||||
|
|
||||||
def upgrade(self):
|
def upgrade(self):
|
||||||
self.convert_imported()
|
self.convert_imported()
|
||||||
self.convert_wallet_type()
|
self.convert_wallet_type()
|
||||||
self.convert_account()
|
self.convert_account()
|
||||||
|
|
||||||
|
self.put('seed_version', FINAL_SEED_VERSION)
|
||||||
self.write()
|
self.write()
|
||||||
|
|
||||||
def convert_wallet_type(self):
|
def convert_wallet_type(self):
|
||||||
|
@ -379,6 +382,8 @@ class WalletStorage(PrintError):
|
||||||
seed_version = self.get('seed_version')
|
seed_version = self.get('seed_version')
|
||||||
if not seed_version:
|
if not seed_version:
|
||||||
seed_version = OLD_SEED_VERSION if len(self.get('master_public_key','')) == 128 else NEW_SEED_VERSION
|
seed_version = OLD_SEED_VERSION if len(self.get('master_public_key','')) == 128 else NEW_SEED_VERSION
|
||||||
|
if seed_version > FINAL_SEED_VERSION:
|
||||||
|
raise BaseException('This version of Electrum is too old to open this wallet')
|
||||||
if seed_version >=12:
|
if seed_version >=12:
|
||||||
return seed_version
|
return seed_version
|
||||||
if seed_version not in [OLD_SEED_VERSION, NEW_SEED_VERSION]:
|
if seed_version not in [OLD_SEED_VERSION, NEW_SEED_VERSION]:
|
||||||
|
|
Loading…
Add table
Reference in a new issue