From a1f1b393687fbb3800de2f29aee083b394c1a94e Mon Sep 17 00:00:00 2001 From: f321x Date: Fri, 20 Feb 2026 16:06:42 +0100 Subject: [PATCH] wallet_db: assert WalletDBUpgrader.storage is dict Assert `WalletDBUpgrader.data` is a regular in-memory dict and not some StoredDict, so if an exception would happen during a wallet db upgrade the partial changes don't get commited to disk. --- electrum/wallet_db.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/electrum/wallet_db.py b/electrum/wallet_db.py index 90f44e37f..36df85498 100644 --- a/electrum/wallet_db.py +++ b/electrum/wallet_db.py @@ -117,9 +117,12 @@ for key in ['locked_in', 'fails', 'settles']: class WalletDBUpgrader(Logger): - def __init__(self, data): + def __init__(self, data: dict): Logger.__init__(self) self.data = data + # self.data must be in-memory dict (not a StoredDict or similar), + # so a failed, partial upgrade won't get commited to disk + assert type(self.data) == dict, type(self.data) def get(self, key, default=None): return self.data.get(key, default)