commit da968b60e474a39bcea99c498010a478a7d75748
parent 084a2f60aedd2d1c9de5b36105bad641b7549f3d
Author: ThomasV <thomasv@gitorious>
Date: Mon, 5 Jan 2015 00:33:10 +0100
drop support for multiple accounts (bip44) in standard wallets
Diffstat:
5 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/lib/bitcoin.py b/lib/bitcoin.py
@@ -749,9 +749,11 @@ def bip32_root(seed, testnet=False):
def bip32_private_derivation(xprv, branch, sequence, testnet=False):
+ assert sequence.startswith(branch)
+ if branch == sequence:
+ return xprv, xpub_from_xprv(xprv, testnet)
header_pub, header_priv = _get_headers(testnet)
depth, fingerprint, child_number, c, k = deserialize_xkey(xprv)
- assert sequence.startswith(branch)
sequence = sequence[len(branch):]
for n in sequence.split('/'):
if n == '': continue
diff --git a/lib/mnemonic.py b/lib/mnemonic.py
@@ -121,7 +121,7 @@ class Mnemonic(object):
def mnemonic_to_seed(self, mnemonic, passphrase):
PBKDF2_ROUNDS = 2048
mnemonic = prepare_seed(mnemonic)
- return pbkdf2.PBKDF2(mnemonic, 'mnemonic' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64)
+ return pbkdf2.PBKDF2(mnemonic, 'electrum' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64)
def mnemonic_encode(self, i):
n = len(self.wordlist)
diff --git a/lib/version.py b/lib/version.py
@@ -1,6 +1,6 @@
ELECTRUM_VERSION = "2.0" # version of the client package
PROTOCOL_VERSION = '0.9' # protocol version requested
-NEW_SEED_VERSION = 10 # electrum versions >= 2.0
+NEW_SEED_VERSION = 11 # electrum versions >= 2.0
OLD_SEED_VERSION = 4 # electrum versions < 2.0
diff --git a/lib/wallet.py b/lib/wallet.py
@@ -1329,7 +1329,7 @@ class BIP32_Wallet(Deterministic_Wallet):
self.add_master_public_key(name, xpub)
def mnemonic_to_seed(self, seed, password):
- return Mnemonic.mnemonic_to_seed(seed, password)
+ return Mnemonic.mnemonic_to_seed(seed, password)
def make_seed(self):
lang = self.storage.config.get('language')
@@ -1468,18 +1468,22 @@ class BIP32_HD_Wallet(BIP32_Wallet):
-class NewWallet(BIP32_HD_Wallet, Mnemonic):
- # bip 44
+class NewWallet(BIP32_Wallet, Mnemonic):
+ # Standard wallet
root_name = 'x/'
- root_derivation = "m/44'/0'"
+ root_derivation = "m/"
wallet_type = 'standard'
+ def create_main_account(self, password):
+ xpub = self.master_public_keys.get("x/")
+ account = BIP32_Account({'xpub':xpub})
+ self.add_account('0', account)
+
class Wallet_2of2(BIP32_Wallet, Mnemonic):
# Wallet with multisig addresses.
- # Cannot create accounts
root_name = "x1/"
- root_derivation = "m/44'/0'"
+ root_derivation = "m/"
wallet_type = '2of2'
def can_import(self):
@@ -1633,7 +1637,7 @@ class Wallet(object):
if seed_version not in [OLD_SEED_VERSION, NEW_SEED_VERSION]:
msg = "This wallet seed is not supported anymore."
- if seed_version in [5, 7, 8, 9]:
+ if seed_version in [5, 7, 8, 9, 10]:
msg += "\nTo open this wallet, try 'git checkout seed_v%d'"%seed_version
raise BaseException(msg)
diff --git a/plugins/trezor.py b/plugins/trezor.py
@@ -12,7 +12,7 @@ from electrum.bitcoin import EncodeBase58Check, public_key_to_bc_address, bc_add
from electrum.i18n import _
from electrum.plugins import BasePlugin, hook
from electrum.transaction import deserialize
-from electrum.wallet import NewWallet
+from electrum.wallet import BIP32_HD_Wallet
from electrum.util import print_error
from electrum_gui.qt.password_dialog import make_password_dialog, run_password_dialog
@@ -161,11 +161,12 @@ class Plugin(BasePlugin):
return False
-class TrezorWallet(NewWallet):
+class TrezorWallet(BIP32_HD_Wallet):
wallet_type = 'trezor'
+ root_derivation = "m/44'/0'"
def __init__(self, storage):
- NewWallet.__init__(self, storage)
+ BIP32_HD_Wallet.__init__(self, storage)
self.transport = None
self.client = None
self.mpk = None