diff --git a/electrum/gui/qt/__init__.py b/electrum/gui/qt/__init__.py index 0aae432ef..88e00bf55 100644 --- a/electrum/gui/qt/__init__.py +++ b/electrum/gui/qt/__init__.py @@ -455,7 +455,7 @@ class ElectrumGui(BaseElectrumGui, Logger): else: xprv = db.get('x1')['xprv'] _wiz_data_updates = { - 'wallet_name': os.path.basename(wallet_file), + 'wallet_name': wallet_file, 'xprv1': xprv, 'xpub1': db.get('x1')['xpub'], 'xpub2': db.get('x2')['xpub'], diff --git a/electrum/gui/qt/wizard/wallet.py b/electrum/gui/qt/wizard/wallet.py index 8b5b6e084..9259ecfd4 100644 --- a/electrum/gui/qt/wizard/wallet.py +++ b/electrum/gui/qt/wizard/wallet.py @@ -182,6 +182,7 @@ class QENewWalletWizard(NewWalletWizard, QEAbstractWizard, MessageBoxMixin): wallet_file = wizard_data['wallet_name'] storage = WalletStorage(wallet_file) + assert storage.file_exists(), f"file {wallet_file!r} does not exist" if not storage.is_encrypted_with_user_pw() and not storage.is_encrypted_with_hw_device(): return True @@ -398,6 +399,7 @@ class WCWalletName(WalletWizardComponent, Logger): wallet_folder = self.wizard.config.get_datadir_wallet_path() self.wizard_data['wallet_name'] = os.path.join(wallet_folder, self.name_e.text()) else: + # FIXME: wizard_data['wallet_name'] is sometimes a full path, sometimes a basename self.wizard_data['wallet_name'] = self.name_e.text() self.wizard_data['wallet_exists'] = self.wallet_exists self.wizard_data['wallet_is_open'] = self.wallet_is_open diff --git a/electrum/plugins/trustedcoin/qt.py b/electrum/plugins/trustedcoin/qt.py index 5233ea386..7a223b241 100644 --- a/electrum/plugins/trustedcoin/qt.py +++ b/electrum/plugins/trustedcoin/qt.py @@ -489,7 +489,7 @@ class WCShowConfirmOTP(WizardComponent): if self.wizard.trustedcoin_qhelper.otpSecret: self.secretlabel.setText(self.wizard.trustedcoin_qhelper.otpSecret) uri = 'otpauth://totp/Electrum 2FA %s?secret=%s&digits=6' % ( - self.wizard_data['wallet_name'], self.wizard.trustedcoin_qhelper.otpSecret) + os.path.basename(self.wizard_data['wallet_name']), self.wizard.trustedcoin_qhelper.otpSecret) self.qr.setData(uri) def on_busy_changed(self): diff --git a/electrum/storage.py b/electrum/storage.py index f9f9cff44..6c8551571 100644 --- a/electrum/storage.py +++ b/electrum/storage.py @@ -60,6 +60,8 @@ class StorageOnDiskUnexpectedlyChanged(Exception): pass # TODO: Rename to Storage class WalletStorage(Logger): + # TODO maybe split this into separate create() and open() classmethods, to prevent some bugs. + # Until then, the onus is on the caller to check file_exists(). def __init__(self, path): Logger.__init__(self) self.path = standardize_path(path)