wallet_db: add comment to explain db upgrades should be self-contained
What changed, and why it matters
This commit only adds a documentation comment inside the Electrum wallet database upgrade code. It explains that future database migrations should be self-contained so that later code changes do not accidentally break old upgrade paths. No code behavior is changed, and there is no security fix or vulnerability introduced.
No action required. This is a non-functional documentation-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff inserts a docstring into the WalletDBUpgrader class in electrum/wallet_db.py. The comment is purely advisory, recommending that each convert_version_* migration avoid depending on external module state (e.g., global translation dictionaries) and instead inline any values it needs. No functions, logic, or data handling are modified.
Changed components
electrum/wallet_db.pyInspect captured patch +10 / −0
### electrum/wallet_db.py
@@ -132,6 +132,16 @@ class WalletFileExceptionVersion51(WalletFileException): pass
class WalletDBUpgrader(Logger):
+ """
+ note: each DB upgrade (migration) should be as self-contained as practical.
+ The more a given convert_version_* depends on from outside the module,
+ the more likely future code changes break that specific DB upgrade.
+ - example:
+ invoices.py might have a global dict pr_expiration_values = {10*60: _('10 minutes'), 60*60: _('1 hour'), ...}.
+ Such a dict could change in future code, so if a given DB upgrade needs to reference it,
+ it is more robust to inline and duplicate it inside the migration code.
+ """
+
def __init__(self, data: dict):
Logger.__init__(self)
self.data = dataWhy 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.