tfollow-up fixes to storage-db separation - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 111ef9ebb11380cf2ee49b327988a8e21e99934b DIR parent 5d8d8f743a6c8c4539235c2b5504720bb1b0c01b HTML Author: SomberNight <somber.night@protonmail.com> Date: Thu, 13 Feb 2020 20:00:12 +0100 follow-up fixes to storage-db separation e1ce3aace7e3143da24115890d9bae78a9f5bcaf Diffstat: M electrum/gui/kivy/uix/dialogs/tx_d… | 2 +- M electrum/gui/qt/history_list.py | 2 +- M electrum/gui/qt/main_window.py | 2 +- M electrum/gui/qt/transaction_dialog… | 2 +- M electrum/wallet_db.py | 10 +++++++--- 5 files changed, 11 insertions(+), 7 deletions(-) --- DIR diff --git a/electrum/gui/kivy/uix/dialogs/tx_dialog.py b/electrum/gui/kivy/uix/dialogs/tx_dialog.py t@@ -294,7 +294,7 @@ class TxDialog(Factory.Popup): if b: for tx in to_delete: self.wallet.remove_transaction(tx) - self.wallet.storage.write() + self.wallet.save_db() self.app._trigger_update_wallet() # FIXME private... self.dismiss() d = Question(question, on_prompt) DIR diff --git a/electrum/gui/qt/history_list.py b/electrum/gui/qt/history_list.py t@@ -666,7 +666,7 @@ class HistoryList(MyTreeView, AcceptFileDragDrop): return for tx in to_delete: self.wallet.remove_transaction(tx) - self.wallet.storage.write() + self.wallet.save_db() # need to update at least: history_list, utxo_list, address_list self.parent.need_update.set() DIR diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py t@@ -3006,7 +3006,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): win.show_error(e) return False else: - self.wallet.storage.write() + self.wallet.save_db() # need to update at least: history_list, utxo_list, address_list self.need_update.set() msg = (_("Transaction added to wallet history.") + '\n\n' + DIR diff --git a/electrum/gui/qt/transaction_dialog.py b/electrum/gui/qt/transaction_dialog.py t@@ -308,7 +308,7 @@ class BaseTxDialog(QDialog, MessageBoxMixin): name = 'signed_%s.txn' % (tx.txid()[0:8]) else: name = self.wallet.basename() + time.strftime('-%Y%m%d-%H%M.psbt') - fileName = self.main_window.getSaveFileName(_("Select where to save your signed transaction"), + fileName = self.main_window.getSaveFileName(_("Select where to save your transaction"), name, TRANSACTION_FILE_EXTENSION_FILTER) if not fileName: DIR diff --git a/electrum/wallet_db.py b/electrum/wallet_db.py t@@ -28,7 +28,7 @@ import json import copy import threading from collections import defaultdict -from typing import Dict, Optional, List, Tuple, Set, Iterable, NamedTuple, Sequence +from typing import Dict, Optional, List, Tuple, Set, Iterable, NamedTuple, Sequence, TYPE_CHECKING import binascii from . import util, bitcoin t@@ -41,6 +41,10 @@ from .lnutil import ChannelConstraints, Outpoint, ShachainElement from .json_db import StoredDict, JsonDB, locked, modifier from .plugin import run_hook, plugin_loaders +if TYPE_CHECKING: + from .storage import WalletStorage + + # seed_version is now used for the version of the wallet file OLD_SEED_VERSION = 4 # electrum versions < 2.0 t@@ -998,11 +1002,11 @@ class WalletDB(JsonDB): v = binascii.unhexlify(v) if v is not None else None return v - def write(self, storage): + def write(self, storage: 'WalletStorage'): with self.lock: self._write(storage) - def _write(self, storage): + def _write(self, storage: 'WalletStorage'): if threading.currentThread().isDaemon(): self.logger.warning('daemon thread cannot write db') return