Browse Source

qt wizard: fix offline 2fa wallet creation in some cases

fixes https://github.com/spesmilo/electrum/issues/9037
master
SomberNight 2 years ago
parent
commit
7827be17d1
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 2
      electrum/gui/qt/__init__.py
  2. 2
      electrum/gui/qt/wizard/wallet.py
  3. 2
      electrum/plugins/trustedcoin/qt.py
  4. 2
      electrum/storage.py

2
electrum/gui/qt/__init__.py

@ -455,7 +455,7 @@ class ElectrumGui(BaseElectrumGui, Logger):
else: else:
xprv = db.get('x1')['xprv'] xprv = db.get('x1')['xprv']
_wiz_data_updates = { _wiz_data_updates = {
'wallet_name': os.path.basename(wallet_file), 'wallet_name': wallet_file,
'xprv1': xprv, 'xprv1': xprv,
'xpub1': db.get('x1')['xpub'], 'xpub1': db.get('x1')['xpub'],
'xpub2': db.get('x2')['xpub'], 'xpub2': db.get('x2')['xpub'],

2
electrum/gui/qt/wizard/wallet.py

@ -182,6 +182,7 @@ class QENewWalletWizard(NewWalletWizard, QEAbstractWizard, MessageBoxMixin):
wallet_file = wizard_data['wallet_name'] wallet_file = wizard_data['wallet_name']
storage = WalletStorage(wallet_file) 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(): if not storage.is_encrypted_with_user_pw() and not storage.is_encrypted_with_hw_device():
return True return True
@ -398,6 +399,7 @@ class WCWalletName(WalletWizardComponent, Logger):
wallet_folder = self.wizard.config.get_datadir_wallet_path() wallet_folder = self.wizard.config.get_datadir_wallet_path()
self.wizard_data['wallet_name'] = os.path.join(wallet_folder, self.name_e.text()) self.wizard_data['wallet_name'] = os.path.join(wallet_folder, self.name_e.text())
else: 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_name'] = self.name_e.text()
self.wizard_data['wallet_exists'] = self.wallet_exists self.wizard_data['wallet_exists'] = self.wallet_exists
self.wizard_data['wallet_is_open'] = self.wallet_is_open self.wizard_data['wallet_is_open'] = self.wallet_is_open

2
electrum/plugins/trustedcoin/qt.py

@ -489,7 +489,7 @@ class WCShowConfirmOTP(WizardComponent):
if self.wizard.trustedcoin_qhelper.otpSecret: if self.wizard.trustedcoin_qhelper.otpSecret:
self.secretlabel.setText(self.wizard.trustedcoin_qhelper.otpSecret) self.secretlabel.setText(self.wizard.trustedcoin_qhelper.otpSecret)
uri = 'otpauth://totp/Electrum 2FA %s?secret=%s&digits=6' % ( 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) self.qr.setData(uri)
def on_busy_changed(self): def on_busy_changed(self):

2
electrum/storage.py

@ -60,6 +60,8 @@ class StorageOnDiskUnexpectedlyChanged(Exception): pass
# TODO: Rename to Storage # TODO: Rename to Storage
class WalletStorage(Logger): 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): def __init__(self, path):
Logger.__init__(self) Logger.__init__(self)
self.path = standardize_path(path) self.path = standardize_path(path)

Loading…
Cancel
Save