diff --git a/gui/qt/__init__.py b/gui/qt/__init__.py index 6a066f932..be2f70f05 100644 --- a/gui/qt/__init__.py +++ b/gui/qt/__init__.py @@ -168,7 +168,12 @@ class ElectrumGui: w.bring_to_top() break 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: storage = WalletStorage(path) wizard = InstallWizard(self.config, self.app, self.plugins, storage) diff --git a/lib/storage.py b/lib/storage.py index 7f3a083e0..5d663514d 100644 --- a/lib/storage.py +++ b/lib/storage.py @@ -75,6 +75,9 @@ class WalletStorage(PrintError): self.raw = f.read() if not self.is_encrypted(): self.load_data(self.raw) + else: + # avoid new wallets getting 'upgraded' + self.put('seed_version', FINAL_SEED_VERSION) def load_data(self, s): try: @@ -161,8 +164,6 @@ class WalletStorage(PrintError): @profiler 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: self._write() @@ -244,12 +245,14 @@ class WalletStorage(PrintError): return result 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): self.convert_imported() self.convert_wallet_type() self.convert_account() + + self.put('seed_version', FINAL_SEED_VERSION) self.write() def convert_wallet_type(self): @@ -379,6 +382,8 @@ class WalletStorage(PrintError): seed_version = self.get('seed_version') if not 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: return seed_version if seed_version not in [OLD_SEED_VERSION, NEW_SEED_VERSION]: