diff --git a/electrum/json_db.py b/electrum/json_db.py index ef7742b16..56f635ba3 100644 --- a/electrum/json_db.py +++ b/electrum/json_db.py @@ -421,9 +421,11 @@ class JsonDB(Logger): @locked def write(self): - if (not self.storage.file_exists() - or self.storage.is_encrypted() - or self.storage.needs_consolidation()): + if ( + not self.storage.file_exists() + or self.storage.is_encrypted() + or self.storage.needs_consolidation() + ): self.write_and_force_consolidation() else: self._append_pending_changes() diff --git a/electrum/plugins/watchtower/watchtower.py b/electrum/plugins/watchtower/watchtower.py index 99a48c28d..dd39ebd49 100644 --- a/electrum/plugins/watchtower/watchtower.py +++ b/electrum/plugins/watchtower/watchtower.py @@ -66,15 +66,16 @@ class WatchTower(Logger, EventListener): def __init__(self, network: 'Network'): Logger.__init__(self) - self.adb = AddressSynchronizer(WalletDB('', storage=None, upgrade=True), network.config, name=self.diagnostic_name()) - self.adb.start_network(network) self.config = network.config + wallet_db = WalletDB('', storage=None, upgrade=True) + self.adb = AddressSynchronizer(wallet_db, self.config, name=self.diagnostic_name()) + self.adb.start_network(network) self.callbacks = {} # address -> lambda function self.register_callbacks() # status gets populated when we run self.channel_status = {} self.network = network - self.sweepstore = SweepStore(os.path.join(self.network.config.path, "watchtower_db"), network) + self.sweepstore = SweepStore(os.path.join(self.config.path, "watchtower_db"), network) def remove_callback(self, address): self.callbacks.pop(address, None) diff --git a/electrum/scripts/bruteforce_pw.py b/electrum/scripts/bruteforce_pw.py index 7c6880728..621e0e8f6 100755 --- a/electrum/scripts/bruteforce_pw.py +++ b/electrum/scripts/bruteforce_pw.py @@ -84,8 +84,8 @@ if __name__ == '__main__': test_password = partial(test_password_for_storage_encryption, storage) print(f"wallet found: with storage encryption.") else: - db = WalletDB(storage.read(), manual_upgrades=True) - wallet = Wallet(db, storage, config=config) + db = WalletDB(storage.read(), storage=storage, upgrade=False) + wallet = Wallet(db, config=config) if not wallet.has_password(): print("wallet found but it is not encrypted.") sys.exit(0) diff --git a/electrum/wallet.py b/electrum/wallet.py index 6743f47cf..0a4608eec 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -4163,7 +4163,7 @@ class Wallet(object): This class is actually a factory that will return a wallet of the correct type when passed a WalletStorage instance.""" - def __new__(cls, db: 'WalletDB', *, config: SimpleConfig): + def __new__(cls, db: 'WalletDB', *, config: SimpleConfig) -> Abstract_Wallet: wallet_type = db.get('wallet_type') WalletClass = Wallet.wallet_class(wallet_type) wallet = WalletClass(db, config=config) diff --git a/run_electrum b/run_electrum index 31fbc8369..7510f590b 100755 --- a/run_electrum +++ b/run_electrum @@ -227,7 +227,7 @@ def get_password_for_hw_device_encrypted_storage(plugins: 'Plugins') -> str: sys.exit(0) -async def run_offline_command(config, config_options, wallet_path, plugins: 'Plugins'): +async def run_offline_command(config: 'SimpleConfig', config_options: dict, wallet_path: str, plugins: 'Plugins'): cmdname = config.get('cmd') cmd = known_commands[cmdname] password = config_options.get('password')