From 852f2a0d65de2b5d34083fa0cdd031fec257714e Mon Sep 17 00:00:00 2001 From: ThomasV Date: Sun, 9 Dec 2018 06:17:33 +0100 Subject: [PATCH] trustedcoin: do not require wallet file upgrade --- electrum/plugins/trustedcoin/trustedcoin.py | 10 +++++++--- electrum/storage.py | 10 +--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/electrum/plugins/trustedcoin/trustedcoin.py b/electrum/plugins/trustedcoin/trustedcoin.py index d93bf3541..1a989ca09 100644 --- a/electrum/plugins/trustedcoin/trustedcoin.py +++ b/electrum/plugins/trustedcoin/trustedcoin.py @@ -249,8 +249,11 @@ class Wallet_2fa(Multisig_Wallet): self.plugin = None # type: TrustedCoinPlugin def _load_billing_addresses(self): - billing_addresses = self.storage.get('trustedcoin_billing_addresses', {}) - self._billing_addresses = defaultdict(dict) # type: Dict[str, Dict[int, str]] # addr_type -> index -> addr + # type: Dict[str, Dict[int, str]] # addr_type -> index -> addr + self._billing_addresses = { + 'legacy': self.storage.get('trustedcoin_billing_addresses', {}), + 'segwit': self.storage.get('trustedcoin_billing_addresses_segwit', {}) + } self._billing_addresses_set = set() # set of addrs for addr_type, d in list(billing_addresses.items()): self._billing_addresses[addr_type] = {} @@ -349,7 +352,8 @@ class Wallet_2fa(Multisig_Wallet): billing_addresses_of_this_type[billing_index] = address self._billing_addresses_set.add(address) self._billing_addresses[addr_type] = billing_addresses_of_this_type - self.storage.put('trustedcoin_billing_addresses', self._billing_addresses) + self.storage.put('trustedcoin_billing_addresses', self._billing_addresses['legacy']) + self.storage.put('trustedcoin_billing_addresses_segwit', self._billing_addresses['segwit']) # FIXME this often runs in a daemon thread, where storage.write will fail self.storage.write() diff --git a/electrum/storage.py b/electrum/storage.py index b88e83136..7dcce567c 100644 --- a/electrum/storage.py +++ b/electrum/storage.py @@ -44,7 +44,7 @@ from .keystore import bip44_derivation OLD_SEED_VERSION = 4 # electrum versions < 2.0 NEW_SEED_VERSION = 11 # electrum versions >= 2.0 -FINAL_SEED_VERSION = 19 # electrum >= 2.7 will set this to prevent +FINAL_SEED_VERSION = 18 # electrum >= 2.7 will set this to prevent # old versions from overwriting new format @@ -354,7 +354,6 @@ class WalletStorage(JsonDB): self.convert_version_16() self.convert_version_17() self.convert_version_18() - self.convert_version_19() self.put('seed_version', FINAL_SEED_VERSION) # just to be sure self.write() @@ -576,13 +575,6 @@ class WalletStorage(JsonDB): self.put('verified_tx3', None) self.put('seed_version', 18) - def convert_version_19(self): - # delete trustedcoin_billing_addresses - if not self._is_upgrade_method_needed(18, 18): - return - self.put('trustedcoin_billing_addresses', None) - self.put('seed_version', 19) - def convert_imported(self): if not self._is_upgrade_method_needed(0, 13): return