From 003e6c3e7966d1e22346a2b115bcaa6171ebfd08 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Tue, 14 May 2019 15:32:57 +0200 Subject: [PATCH] fix 2fa wallet creation via qt gui closes #5334 --- electrum/base_wizard.py | 4 +++- electrum/plugins/trustedcoin/qt.py | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/electrum/base_wizard.py b/electrum/base_wizard.py index 6114ce7f7..2165019dd 100644 --- a/electrum/base_wizard.py +++ b/electrum/base_wizard.py @@ -560,11 +560,13 @@ class BaseWizard(Logger): self.terminate() def create_storage(self, path): + if os.path.exists(path): + raise Exception('file already exists at path') if not self.pw_args: return password, encrypt_storage, storage_enc_version = self.pw_args storage = WalletStorage(path) - storage.set_keystore_encryption(bool(password)) # and encrypt_keystore) + storage.set_keystore_encryption(bool(password)) if encrypt_storage: storage.set_password(password, enc_version=storage_enc_version) for key, value in self.data.items(): diff --git a/electrum/plugins/trustedcoin/qt.py b/electrum/plugins/trustedcoin/qt.py index 92fe69055..b11de233e 100644 --- a/electrum/plugins/trustedcoin/qt.py +++ b/electrum/plugins/trustedcoin/qt.py @@ -43,6 +43,7 @@ from electrum.i18n import _ from electrum.plugin import hook from electrum.util import is_valid_email from electrum.logging import Logger +from electrum.base_wizard import GoBack from .trustedcoin import TrustedCoinPlugin, server @@ -221,9 +222,13 @@ class Plugin(TrustedCoinPlugin): _('If you are online, click on "{}" to continue.').format(_('Next')) ] msg = '\n\n'.join(msg) - wizard.create_storage(wizard.path) wizard.reset_stack() - wizard.confirm_dialog(title='', message=msg, run_next = lambda x: wizard.run('accept_terms_of_use')) + try: + wizard.confirm_dialog(title='', message=msg, run_next = lambda x: wizard.run('accept_terms_of_use')) + except GoBack: + # user clicked 'Cancel' and decided to move wallet file manually + wizard.create_storage(wizard.path) + raise def accept_terms_of_use(self, window): vbox = QVBoxLayout()