qt wizard: fix offline 2fa wallet creation in some cases
fixes https://github.com/spesmilo/electrum/issues/9037
This commit is contained in:
@@ -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'],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user