From cdde41e162fbdceb23f4580610d84466de47ee2b Mon Sep 17 00:00:00 2001 From: Kristaps Kaupe Date: Sun, 30 Dec 2018 02:26:43 +0200 Subject: [PATCH] Handle already existing wallet file on generate Before this change with wallet-tool.py you would get "ValueError: invalid padding byte" and "jmclient.storage.StoragePasswordError: Wrong password." exceptions, joinmarket-qt would fail silently. --- jmclient/jmclient/storage.py | 2 ++ scripts/joinmarket-qt.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/jmclient/jmclient/storage.py b/jmclient/jmclient/storage.py index ebc6124..2528290 100644 --- a/jmclient/jmclient/storage.py +++ b/jmclient/jmclient/storage.py @@ -94,6 +94,8 @@ class Storage(object): self.newly_created = True else: raise StorageError("File not found.") + elif create: + raise StorageError("File already exists.") else: self._load_file(password) diff --git a/scripts/joinmarket-qt.py b/scripts/joinmarket-qt.py index 506fdf9..ac4b724 100644 --- a/scripts/joinmarket-qt.py +++ b/scripts/joinmarket-qt.py @@ -1530,7 +1530,8 @@ class JMMainWindow(QMainWindow): Initializes by syncing. ''' if not seed: - success = wallet_generate_recover_bip39("generate", + try: + success = wallet_generate_recover_bip39("generate", "wallets", "wallet.jmdat", callbacks=(self.displayWords, @@ -1538,10 +1539,14 @@ class JMMainWindow(QMainWindow): self.getPassword, self.getWalletFileName, self.promptMnemonicExtension)) - if not success: - JMQtMessageBox(self, "Failed to create new wallet file.", - title="Error", mbtype="warn") + if not success: + JMQtMessageBox(self, "Failed to create new wallet file.", + title="Error", mbtype="warn") + return + except Exception as e: + JMQtMessageBox(self, e.args[0], title="Error", mbtype="warn") return + JMQtMessageBox(self, 'Wallet saved to ' + self.walletname, title="Wallet created") self.loadWalletFromBlockchain(self.walletname, pwd=self.textpassword,