Browse Source

force pubkey regeneration in some multisig wallets

283
ThomasV 8 years ago
parent
commit
96016a9ee8
  1. 24
      lib/storage.py
  2. 6
      lib/version.py

24
lib/storage.py

@ -37,7 +37,15 @@ from i18n import _
from util import NotEnoughFunds, PrintError, profiler from util import NotEnoughFunds, PrintError, profiler
from plugins import run_hook, plugin_loaders from plugins import run_hook, plugin_loaders
from keystore import bip44_derivation from keystore import bip44_derivation
from version import *
# seed_version is now used for the version of the wallet file
OLD_SEED_VERSION = 4 # electrum versions < 2.0
NEW_SEED_VERSION = 11 # electrum versions >= 2.0
FINAL_SEED_VERSION = 13 # electrum >= 2.7 will set this to prevent
# old versions from overwriting new format
def multisig_type(wallet_type): def multisig_type(wallet_type):
@ -213,8 +221,18 @@ class WalletStorage(PrintError):
self.convert_imported() self.convert_imported()
self.convert_wallet_type() self.convert_wallet_type()
self.convert_account() self.convert_account()
self.convert_pubkeys()
self.write() self.write()
def convert_pubkeys(self):
# version 12 had a bug in pubkey ordering
# it is fixed by forcing pubkey regeneration
if self.get_seed_version() != 12:
return
if self.get('wallet_type') in ['standard', 'imported']:
return
self.put('pubkeys', {})
def convert_wallet_type(self): def convert_wallet_type(self):
wallet_type = self.get('wallet_type') wallet_type = self.get('wallet_type')
if wallet_type == 'btchip': wallet_type = 'ledger' if wallet_type == 'btchip': wallet_type = 'ledger'
@ -334,7 +352,9 @@ class WalletStorage(PrintError):
seed_version = self.get('seed_version') seed_version = self.get('seed_version')
if not seed_version: if not seed_version:
seed_version = OLD_SEED_VERSION if len(self.get('master_public_key','')) == 128 else NEW_SEED_VERSION seed_version = OLD_SEED_VERSION if len(self.get('master_public_key','')) == 128 else NEW_SEED_VERSION
if seed_version not in [OLD_SEED_VERSION, NEW_SEED_VERSION, FINAL_SEED_VERSION]: if seed_version >=12:
return seed_version
if seed_version not in [OLD_SEED_VERSION, NEW_SEED_VERSION]:
msg = "Your wallet has an unsupported seed version." msg = "Your wallet has an unsupported seed version."
msg += '\n\nWallet file: %s' % os.path.abspath(self.path) msg += '\n\nWallet file: %s' % os.path.abspath(self.path)
if seed_version in [5, 7, 8, 9, 10]: if seed_version in [5, 7, 8, 9, 10]:

6
lib/version.py

@ -1,12 +1,6 @@
ELECTRUM_VERSION = '2.7.8' # version of the client package ELECTRUM_VERSION = '2.7.8' # version of the client package
PROTOCOL_VERSION = '0.10' # protocol version requested PROTOCOL_VERSION = '0.10' # protocol version requested
OLD_SEED_VERSION = 4 # electrum versions < 2.0
NEW_SEED_VERSION = 11 # electrum versions >= 2.0
FINAL_SEED_VERSION = 12 # electrum >= 2.7 will set this to prevent
# old versions from overwriting new format
# The hash of the mnemonic seed must begin with this # The hash of the mnemonic seed must begin with this
SEED_PREFIX = '01' # Electrum standard wallet SEED_PREFIX = '01' # Electrum standard wallet
SEED_PREFIX_2FA = '101' # extended seed for two-factor authentication SEED_PREFIX_2FA = '101' # extended seed for two-factor authentication

Loading…
Cancel
Save