From 786979ec5021be542f47cd54f6d9ebd228c82d17 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Fri, 13 Oct 2023 13:10:56 +0200 Subject: [PATCH] config: keep wallets directory stable, regardless of wallet opens in other directories --- electrum/gui/qt/main_window.py | 2 +- electrum/simple_config.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index 524401b98..ebf7b7509 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -669,7 +669,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener): self.recently_visited_menu.setEnabled(bool(len(recent))) def get_wallet_folder(self): - return os.path.dirname(os.path.abspath(self.wallet.storage.path)) + return os.path.abspath(self.config.get_datadir_wallet_path()) def new_wallet(self): try: diff --git a/electrum/simple_config.py b/electrum/simple_config.py index 5f9d462bd..c803f0de2 100644 --- a/electrum/simple_config.py +++ b/electrum/simple_config.py @@ -445,6 +445,7 @@ class SimpleConfig(Logger): new_path = self.get_fallback_wallet_path() + # TODO: this can be removed by now # default path in pre 1.9 versions old_path = os.path.join(self.path, "electrum.dat") if os.path.exists(old_path) and not os.path.exists(new_path): @@ -452,12 +453,14 @@ class SimpleConfig(Logger): return new_path - def get_fallback_wallet_path(self): + def get_datadir_wallet_path(self): util.assert_datadir_available(self.path) dirpath = os.path.join(self.path, "wallets") make_dir(dirpath, allow_symlink=False) - path = os.path.join(self.path, "wallets", "default_wallet") - return path + return dirpath + + def get_fallback_wallet_path(self): + return os.path.join(self.get_datadir_wallet_path(), "default_wallet") def remove_from_recently_open(self, filename): recent = self.RECENTLY_OPEN_WALLET_FILES or []