diff --git a/src/cutecoin/core/app.py b/src/cutecoin/core/app.py index e351f3ef84b0f9b10acd622ea6823503b55ec517..16aaab65e6cc82c88b6ffea0a61b2388d67158c1 100644 --- a/src/cutecoin/core/app.py +++ b/src/cutecoin/core/app.py @@ -9,9 +9,10 @@ import logging import json import tarfile -from cutecoin.core import config -from cutecoin.tools.exceptions import NameAlreadyExists, BadAccountFile -from cutecoin.core.account import Account +from . import config +from ..tools.exceptions import NameAlreadyExists, BadAccountFile +from .account import Account +from .. import __version__ class Application(object): @@ -90,7 +91,10 @@ class Application(object): if os.path.exists(wallet_path): with open(wallet_path, 'r') as json_data: data = json.load(json_data) - wallet.load_caches(data) + if 'version' in data and data['version'] == __version__: + wallet.load_caches(data) + else: + os.remove(wallet_path) for community in account.communities: wallet.refresh_cache(community) @@ -112,7 +116,9 @@ class Application(object): wallet_path = os.path.join(config.parameters['home'], account.name, '__cache__', wallet.pubkey) with open(wallet_path, 'w') as outfile: - json.dump(wallet.jsonify_caches(), outfile, indent=4, sort_keys=True) + data = wallet.jsonify_caches() + data['version'] = __version__ + json.dump(data, outfile, indent=4, sort_keys=True) def import_account(self, file, name): with tarfile.open(file, "r") as tar: diff --git a/src/cutecoin/core/wallet.py b/src/cutecoin/core/wallet.py index 785fa332d30db6f1e17efae6ef2e985d90bcbc69..87121814f28c0488d74996118a8eada4336da217 100644 --- a/src/cutecoin/core/wallet.py +++ b/src/cutecoin/core/wallet.py @@ -27,6 +27,7 @@ class Cache(): self.tx_received = [] self.tx_sent = [] self.awaiting_tx = [] + logging.debug(data) data_received = data['received'] for r in data_received: @@ -164,8 +165,9 @@ class Wallet(object): def load_caches(self, json_data): for currency in json_data: - self.caches[currency] = Cache(self) - self.caches[currency].load_from_json(json_data[currency]) + if currency != 'version': + self.caches[currency] = Cache(self) + self.caches[currency].load_from_json(json_data[currency]) def jsonify_caches(self): data = {} diff --git a/src/cutecoin/gui/currency_tab.py b/src/cutecoin/gui/currency_tab.py index d26eb081deefc14c478a2ba7803a11733872fe16..5fa02a661cac5b9d66c883944d1a9b6312723f52 100644 --- a/src/cutecoin/gui/currency_tab.py +++ b/src/cutecoin/gui/currency_tab.py @@ -208,7 +208,7 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget): copy_pubkey.triggered.connect(self.copy_pubkey_to_clipboard) copy_pubkey.setData(person) - menu.addAction(copy_pubkey) + menu.addAction(copy_pubkey) # Show the context menu. menu.exec_(self.table_history.mapToGlobal(point))