1
0

Merge pull request #8417 from SomberNight/202305_db_version_52

wallet_db version 52: break non-homogeneous multisig wallets
This commit is contained in:
ThomasV
2023-05-11 16:35:42 +02:00
committed by GitHub
7 changed files with 111 additions and 34 deletions

View File

@@ -495,7 +495,7 @@ ApplicationWindow
}
function onWalletOpenError(error) {
console.log('wallet open error')
var dialog = app.messageDialog.createObject(app, {'text': error})
var dialog = app.messageDialog.createObject(app, { title: qsTr('Error'), 'text': error })
dialog.open()
}
function onAuthRequired(method, authMessage) {

View File

@@ -223,7 +223,7 @@ class QEDaemon(AuthMixin, QObject):
self._backendWalletLoaded.emit(local_password)
except WalletFileException as e:
self._logger.error(str(e))
self._logger.error(f"load_wallet_task errored opening wallet: {e!r}")
self.walletOpenError.emit(str(e))
finally:
self._loading = False

View File

@@ -8,7 +8,7 @@ from electrum.storage import WalletStorage, StorageEncryptionVersion
from electrum.wallet_db import WalletDB
from electrum.wallet import Wallet
from electrum.bip32 import normalize_bip32_derivation, xpub_type
from electrum.util import InvalidPassword, WalletFileException
from electrum.util import InvalidPassword, WalletFileException, send_exception_to_crash_reporter
from electrum import keystore
if TYPE_CHECKING:
@@ -120,9 +120,16 @@ class QEWalletDB(QObject):
@pyqtSlot()
def verify(self):
self.load_storage()
if self._storage:
self.load_db()
try:
self._load_storage()
if self._storage:
self._load_db()
except WalletFileException as e:
self._logger.error(f"verify errored: {repr(e)}")
self._storage = None
self.walletOpenProblem.emit(str(e))
if e.should_report_crash:
send_exception_to_crash_reporter(e)
@pyqtSlot()
def doSplit(self):
@@ -134,7 +141,8 @@ class QEWalletDB(QObject):
self.splitFinished.emit()
def load_storage(self):
def _load_storage(self):
"""can raise WalletFileException"""
self._storage = WalletStorage(self._path)
if not self._storage.file_exists():
self._logger.warning('file does not exist')
@@ -170,27 +178,23 @@ class QEWalletDB(QObject):
if not self._storage.is_past_initial_decryption():
self._storage = None
def load_db(self):
def _load_db(self):
"""can raise WalletFileException"""
# needs storage accessible
try:
self._db = WalletDB(self._storage.read(), manual_upgrades=True)
if self._db.requires_split():
self._logger.warning('wallet requires split')
self._requiresSplit = True
self.requiresSplitChanged.emit()
return
if self._db.get_action():
self._logger.warning('action pending. QML version doesn\'t support continuation of wizard')
return
self._db = WalletDB(self._storage.read(), manual_upgrades=True)
if self._db.requires_split():
self._logger.warning('wallet requires split')
self._requiresSplit = True
self.requiresSplitChanged.emit()
return
if self._db.get_action():
self._logger.warning('action pending. QML version doesn\'t support continuation of wizard')
return
if self._db.requires_upgrade():
self._logger.warning('wallet requires upgrade, upgrading')
self._db.upgrade()
self._db.write(self._storage)
if self._db.requires_upgrade():
self._logger.warning('wallet requires upgrade, upgrading')
self._db.upgrade()
self._db.write(self._storage)
self._ready = True
self.readyChanged.emit()
except WalletFileException as e:
self._logger.error(f'{repr(e)}')
self._storage = None
self.walletOpenProblem.emit(str(e))
self._ready = True
self.readyChanged.emit()

View File

@@ -342,10 +342,13 @@ class ElectrumGui(BaseElectrumGui, Logger):
wallet = self.daemon.load_wallet(path, None)
except Exception as e:
self.logger.exception('')
err_text = str(e) if isinstance(e, WalletFileException) else repr(e)
custom_message_box(icon=QMessageBox.Warning,
parent=None,
title=_('Error'),
text=_('Cannot load wallet') + ' (1):\n' + repr(e))
text=_('Cannot load wallet') + ' (1):\n' + err_text)
if isinstance(e, WalletFileException) and e.should_report_crash:
send_exception_to_crash_reporter(e)
# if app is starting, still let wizard appear
if not app_is_starting:
return
@@ -364,10 +367,13 @@ class ElectrumGui(BaseElectrumGui, Logger):
window = self._create_window_for_wallet(wallet)
except Exception as e:
self.logger.exception('')
err_text = str(e) if isinstance(e, WalletFileException) else repr(e)
custom_message_box(icon=QMessageBox.Warning,
parent=None,
title=_('Error'),
text=_('Cannot load wallet') + '(2) :\n' + repr(e))
text=_('Cannot load wallet') + '(2) :\n' + err_text)
if isinstance(e, WalletFileException) and e.should_report_crash:
send_exception_to_crash_reporter(e)
if app_is_starting:
# If we raise in this context, there are no more fallbacks, we will shut down.
# Worst case scenario, we might have gotten here without user interaction,