From eaac4be0fcda450142aa642d2b867e8bb55e0ed2 Mon Sep 17 00:00:00 2001 From: AdamISZ Date: Sat, 29 Dec 2018 20:55:36 +0100 Subject: [PATCH] Fix bug in wallet generate in Qt when cancelled Prior to this commit, if a user chose cancel while selecting a filename for a new wallet in Qt, the wallet name was set to the default `wallet.jmdat`, which could lead to a crash or overwrite. This fixes that by ensuring that the wallet generation code recognizes the cancel operation. --- jmclient/jmclient/wallet_utils.py | 4 ++++ scripts/joinmarket-qt.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/jmclient/jmclient/wallet_utils.py b/jmclient/jmclient/wallet_utils.py index 3d53f08..a070211 100644 --- a/jmclient/jmclient/wallet_utils.py +++ b/jmclient/jmclient/wallet_utils.py @@ -523,6 +523,10 @@ def wallet_generate_recover_bip39(method, walletspath, default_wallet_name, return False wallet_name = callbacks[3]() + if wallet_name == "cancelled": + # currently used only by Qt, because user has option + # to click cancel in dialog. + return False if not wallet_name: wallet_name = default_wallet_name wallet_path = os.path.join(walletspath, wallet_name) diff --git a/scripts/joinmarket-qt.py b/scripts/joinmarket-qt.py index eb27c45..8cf7e94 100644 --- a/scripts/joinmarket-qt.py +++ b/scripts/joinmarket-qt.py @@ -1482,7 +1482,9 @@ class JMMainWindow(QMainWindow): QLineEdit.Normal, "wallet.jmdat") if not ok: JMQtMessageBox(self, "Create wallet aborted", mbtype='warn') - return None + # cannot use None for a 'fail' condition, as this is used + # for the case where the default wallet name is to be used in non-Qt. + return "cancelled" self.walletname = str(walletname) return self.walletname