1
0

Make storage a field of db

This comes from the jsonpatch_new branch.
I rather have in master now, because it touches a lot of filese.
This commit is contained in:
ThomasV
2023-06-23 17:36:34 +02:00
parent 0ebb6469ff
commit b96cc82333
18 changed files with 87 additions and 88 deletions

View File

@@ -673,13 +673,13 @@ class ElectrumWindow(App, Logger, EventListener):
else:
return ''
def on_wizard_success(self, storage, db, password):
def on_wizard_success(self, db, password):
self.password = password
if self.electrum_config.WALLET_USE_SINGLE_PASSWORD:
self._use_single_password = self.daemon.update_password_for_directory(
old_password=password, new_password=password)
self.logger.info(f'use single password: {self._use_single_password}')
wallet = Wallet(db, storage, config=self.electrum_config)
wallet = Wallet(db, config=self.electrum_config)
wallet.start_network(self.daemon.network)
self.daemon.add_wallet(wallet)
self.load_wallet(wallet)
@@ -714,7 +714,7 @@ class ElectrumWindow(App, Logger, EventListener):
wizard.run('new')
else:
assert storage.is_past_initial_decryption()
db = WalletDB(storage.read(), manual_upgrades=False)
db = WalletDB(storage.read(), storage=storage, manual_upgrades=False)
assert not db.requires_upgrade()
self.on_wizard_success(storage, db, password)

View File

@@ -359,8 +359,8 @@ class OpenWalletDialog(PasswordDialog):
else:
# it is a bit wasteful load the wallet here and load it again in main_window,
# but that is fine, because we are progressively enforcing storage encryption.
db = WalletDB(self.storage.read(), manual_upgrades=False)
wallet = Wallet(db, self.storage, config=self.app.electrum_config)
db = WalletDB(self.storage.read(), storage=self.storage, manual_upgrades=False)
wallet = Wallet(db, config=self.app.electrum_config)
self.require_password = wallet.has_password()
self.pw_check = wallet.check_password
self.message = self.enter_pw_message if self.require_password else _('Wallet not encrypted')

View File

@@ -162,8 +162,8 @@ class QEWalletDB(QObject):
else: # storage not encrypted; but it might still have a keystore pw
# FIXME hack... load both db and full wallet, just to tell if it has keystore pw.
# this also completely ignores db.requires_split(), db.get_action(), etc
db = WalletDB(self._storage.read(), manual_upgrades=False)
wallet = Wallet(db, self._storage, config=self._config)
db = WalletDB(self._storage.read(), storage=self._storage, manual_upgrades=False)
wallet = Wallet(db, config=self._config)
self.needsPassword = wallet.has_password()
if self.needsPassword:
try:
@@ -181,7 +181,7 @@ class QEWalletDB(QObject):
def _load_db(self):
"""can raise WalletFileException"""
# needs storage accessible
self._db = WalletDB(self._storage.read(), manual_upgrades=True)
self._db = WalletDB(self._storage.read(), storage=self._storage, manual_upgrades=True)
if self._db.requires_split():
self._logger.warning('wallet requires split')
self._requiresSplit = True
@@ -194,7 +194,7 @@ class QEWalletDB(QObject):
if self._db.requires_upgrade():
self._logger.warning('wallet requires upgrade, upgrading')
self._db.upgrade()
self._db.write(self._storage)
self._db.write()
self._ready = True
self.readyChanged.emit()

View File

@@ -407,7 +407,7 @@ class ElectrumGui(BaseElectrumGui, Logger):
wizard.run('new')
storage, db = wizard.create_storage(path)
else:
db = WalletDB(storage.read(), manual_upgrades=False)
db = WalletDB(storage.read(), storage=storage, manual_upgrades=False)
wizard.run_upgrades(storage, db)
except (UserCancelled, GoBack):
return
@@ -418,7 +418,7 @@ class ElectrumGui(BaseElectrumGui, Logger):
# return if wallet creation is not complete
if storage is None or db.get_action():
return
wallet = Wallet(db, storage, config=self.config)
wallet = Wallet(db, config=self.config)
wallet.start_network(self.daemon.network)
self.daemon.add_wallet(wallet)
return wallet

View File

@@ -33,7 +33,7 @@ class ElectrumGui(BaseElectrumGui, EventListener):
password = getpass.getpass('Password:', stream=None)
storage.decrypt(password)
db = WalletDB(storage.read(), manual_upgrades=False)
db = WalletDB(storage.read(), storage=storage, manual_upgrades=False)
self.done = 0
self.last_balance = ""
@@ -43,7 +43,7 @@ class ElectrumGui(BaseElectrumGui, EventListener):
self.str_amount = ""
self.str_fee = ""
self.wallet = Wallet(db, storage, config=config) # type: Optional[Abstract_Wallet]
self.wallet = Wallet(db, config=config) # type: Optional[Abstract_Wallet]
self.wallet.start_network(self.network)
self.contacts = self.wallet.contacts

View File

@@ -60,8 +60,8 @@ class ElectrumGui(BaseElectrumGui, EventListener):
if storage.is_encrypted():
password = getpass.getpass('Password:', stream=None)
storage.decrypt(password)
db = WalletDB(storage.read(), manual_upgrades=False)
self.wallet = Wallet(db, storage, config=config) # type: Optional[Abstract_Wallet]
db = WalletDB(storage.read(), storage=storage, manual_upgrades=False)
self.wallet = Wallet(db, config=config) # type: Optional[Abstract_Wallet]
self.wallet.start_network(self.network)
self.contacts = self.wallet.contacts