What changed, and why it matters
This commit is a simple internal code cleanup. It adds a new helper method called get_path() to the wallet storage class and updates various parts of the program to use that method instead of reading the storage path directly. There is no security fix or vulnerability here.
No security action required; treat as normal refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces WalletStorage.get_path() returning self.path and mechanically replaces direct accesses to wallet.storage.path and w.db.storage.path with calls to get_path() across commands, daemon, QML and Qt GUI code. No logic changes, no bounds checks, no input validation, no cryptographic changes.
Changed components
electrum/storage.pyelectrum/commands.pyelectrum/daemon.pyelectrum/gui/qml/qedaemon.pyelectrum/gui/qt/__init__.pyelectrum/gui/qt/main_window.pyelectrum/gui/qt/wallet_info_dialog.pyInspect captured patch +18 / −15
diff --git a/electrum/commands.py b/electrum/commands.py
index aa3321c..a3776ed 100644
--- a/electrum/commands.py
+++ b/electrum/commands.py
@@ -274,7 +274,7 @@ class Commands(Logger):
"""List wallets open in daemon"""
return [
{
- 'path': w.db.storage.path,
+ 'path': w.storage.get_path(),
'synchronized': w.is_up_to_date(),
'unlocked': not w.has_password() or (w.get_unlocked_password() is not None),
}
@@ -315,7 +315,7 @@ class Commands(Logger):
config=self.config)
return {
'seed': d['seed'],
- 'path': d['wallet'].storage.path,
+ 'path': d['wallet'].storage.get_path(),
'msg': d['msg'],
}
@@ -339,7 +339,7 @@ class Commands(Logger):
encrypt_file=encrypt_file,
config=self.config)
return {
- 'path': d['wallet'].storage.path,
+ 'path': d['wallet'].storage.get_path(),
'msg': d['msg'],
}
diff --git a/electrum/daemon.py b/electrum/daemon.py
index db080aa..0a52731 100644
--- a/electrum/daemon.py
+++ b/electrum/daemon.py
@@ -562,7 +562,7 @@ class Daemon(Logger):
@with_wallet_lock
def add_wallet(self, wallet: Abstract_Wallet) -> None:
- path = wallet.storage.path
+ path = wallet.storage.get_path()
wallet_key = self._wallet_key_from_path(path)
self._wallets[wallet_key] = wallet
run_hook('daemon_wallet_loaded', self, wallet)
@@ -612,8 +612,8 @@ class Daemon(Logger):
return False
await wallet.stop()
if self.config.get('wallet_path') is None:
- wallet_paths = [w.db.storage.path for w in self._wallets.values()
- if w.db.storage and w.db.storage.path]
+ wallet_paths = [w.storage.get_path() for w in self._wallets.values()
+ if w.storage and w.storage.get_path()]
if self.config.CURRENT_WALLET == path and wallet_paths:
self.config.CURRENT_WALLET = wallet_paths[0]
return True
diff --git a/electrum/gui/qml/qedaemon.py b/electrum/gui/qml/qedaemon.py
index b8509bd..28a6640 100644
--- a/electrum/gui/qml/qedaemon.py
+++ b/electrum/gui/qml/qedaemon.py
@@ -299,7 +299,7 @@ class QEDaemon(AuthMixin, QObject):
@auth_protect(message=_('Really delete this wallet?'))
def delete_wallet(self, wallet):
- path = standardize_path(wallet.wallet.storage.path)
+ path = standardize_path(wallet.wallet.storage.get_path())
self._logger.debug('deleting wallet with path %s' % path)
self._current_wallet = None
# TODO walletLoaded signal is confusing
@@ -344,7 +344,7 @@ class QEDaemon(AuthMixin, QObject):
def renameWallet(self, new_name: str):
wallet = self._current_wallet
assert wallet, "name change without wallet?"
- old_path = standardize_path(wallet.wallet.storage.path)
+ old_path = standardize_path(wallet.wallet.storage.get_path())
wallet_dir = os.path.dirname(old_path)
new_path = standardize_path(os.path.join(wallet_dir, new_name))
if old_path == new_path:
diff --git a/electrum/gui/qt/__init__.py b/electrum/gui/qt/__init__.py
index e28ebcd..32ac61d 100644
--- a/electrum/gui/qt/__init__.py
+++ b/electrum/gui/qt/__init__.py
@@ -347,7 +347,7 @@ class ElectrumGui(BaseElectrumGui, Logger):
def get_window_for_wallet(self, wallet):
for window in self.windows:
- if window.wallet.storage.path == wallet.storage.path:
+ if window.wallet.storage.get_path() == wallet.storage.get_path():
return window
@count_wizards_in_progress
@@ -460,7 +460,7 @@ class ElectrumGui(BaseElectrumGui, Logger):
if d['wallet_is_open']:
wallet_path = standardize_path(d['wallet_name'])
for window in self.windows:
- if window.wallet.storage.path == wallet_path:
+ if window.wallet.storage.get_path() == wallet_path:
return window.wallet
raise Exception('found by wizard but not here?!')
@@ -518,7 +518,7 @@ class ElectrumGui(BaseElectrumGui, Logger):
self.build_tray_menu()
run_hook('on_close_window', window)
if window.should_stop_wallet_on_close:
- self.daemon.stop_wallet(window.wallet.storage.path)
+ self.daemon.stop_wallet(window.wallet.storage.get_path())
def reload_window(self, window):
# bump counter so that we do not close the app
diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py
index 6e1c35d..e5a82b3 100644
--- a/electrum/gui/qt/main_window.py
+++ b/electrum/gui/qt/main_window.py
@@ -580,7 +580,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
def close_wallet(self):
if self.wallet:
- self.logger.info(f'close_wallet {self.wallet.storage.path}')
+ self.logger.info(f'close_wallet {self.wallet.storage.get_path()}')
run_hook('close_wallet', self.wallet)
@profiler
@@ -2046,13 +2046,13 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
def remove_wallet(self):
if self.question('\n'.join([
_('Delete wallet file?'),
- "%s"%self.wallet.storage.path,
+ "%s"%self.wallet.storage.get_path(),
_('If your wallet contains funds, make sure you have saved its seed.')])):
self._delete_wallet()
@protected
def _delete_wallet(self, password):
- wallet_path = self.wallet.storage.path
+ wallet_path = self.wallet.storage.get_path()
basename = os.path.basename(wallet_path)
r = self.gui_object.daemon.delete_wallet(wallet_path)
self.close()
diff --git a/electrum/gui/qt/wallet_info_dialog.py b/electrum/gui/qt/wallet_info_dialog.py
index 4c3912d..1f82697 100644
--- a/electrum/gui/qt/wallet_info_dialog.py
+++ b/electrum/gui/qt/wallet_info_dialog.py
@@ -48,7 +48,7 @@ class WalletInfoDialog(WindowModalDialog):
seed_available += f" ({wallet.get_seed_type()})"
keystore_types = [k.get_type_text() for k in wallet.get_keystores()]
grid = QGridLayout()
- basename = os.path.basename(wallet.storage.path)
+ basename = os.path.basename(wallet.storage.get_path())
cur_row = 0
grid.addWidget(WWLabel(_("Wallet name")+ ':'), cur_row, 0)
grid.addWidget(WWLabel(basename), cur_row, 1)
diff --git a/electrum/storage.py b/electrum/storage.py
index 7c79f2d..11ea8fe 100644
--- a/electrum/storage.py
+++ b/electrum/storage.py
@@ -93,6 +93,9 @@ class WalletStorage(Logger):
self.pos = 0
self.init_pos = 0
+ def get_path(self):
+ return self.path
+
def read(self):
return self.decrypted if self.is_encrypted() else self.raw
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.