drop support for multiple accounts (bip44) in standard wallets
This commit is contained in:
parent
084a2f60ae
commit
da968b60e4
|
@ -749,9 +749,11 @@ def bip32_root(seed, testnet=False):
|
||||||
|
|
||||||
|
|
||||||
def bip32_private_derivation(xprv, branch, sequence, 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)
|
header_pub, header_priv = _get_headers(testnet)
|
||||||
depth, fingerprint, child_number, c, k = deserialize_xkey(xprv)
|
depth, fingerprint, child_number, c, k = deserialize_xkey(xprv)
|
||||||
assert sequence.startswith(branch)
|
|
||||||
sequence = sequence[len(branch):]
|
sequence = sequence[len(branch):]
|
||||||
for n in sequence.split('/'):
|
for n in sequence.split('/'):
|
||||||
if n == '': continue
|
if n == '': continue
|
||||||
|
|
|
@ -121,7 +121,7 @@ class Mnemonic(object):
|
||||||
def mnemonic_to_seed(self, mnemonic, passphrase):
|
def mnemonic_to_seed(self, mnemonic, passphrase):
|
||||||
PBKDF2_ROUNDS = 2048
|
PBKDF2_ROUNDS = 2048
|
||||||
mnemonic = prepare_seed(mnemonic)
|
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):
|
def mnemonic_encode(self, i):
|
||||||
n = len(self.wordlist)
|
n = len(self.wordlist)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
ELECTRUM_VERSION = "2.0" # version of the client package
|
ELECTRUM_VERSION = "2.0" # version of the client package
|
||||||
PROTOCOL_VERSION = '0.9' # protocol version requested
|
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
|
OLD_SEED_VERSION = 4 # electrum versions < 2.0
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1468,18 +1468,22 @@ class BIP32_HD_Wallet(BIP32_Wallet):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class NewWallet(BIP32_HD_Wallet, Mnemonic):
|
class NewWallet(BIP32_Wallet, Mnemonic):
|
||||||
# bip 44
|
# Standard wallet
|
||||||
root_name = 'x/'
|
root_name = 'x/'
|
||||||
root_derivation = "m/44'/0'"
|
root_derivation = "m/"
|
||||||
wallet_type = 'standard'
|
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):
|
class Wallet_2of2(BIP32_Wallet, Mnemonic):
|
||||||
# Wallet with multisig addresses.
|
# Wallet with multisig addresses.
|
||||||
# Cannot create accounts
|
|
||||||
root_name = "x1/"
|
root_name = "x1/"
|
||||||
root_derivation = "m/44'/0'"
|
root_derivation = "m/"
|
||||||
wallet_type = '2of2'
|
wallet_type = '2of2'
|
||||||
|
|
||||||
def can_import(self):
|
def can_import(self):
|
||||||
|
@ -1633,7 +1637,7 @@ class Wallet(object):
|
||||||
|
|
||||||
if seed_version not in [OLD_SEED_VERSION, NEW_SEED_VERSION]:
|
if seed_version not in [OLD_SEED_VERSION, NEW_SEED_VERSION]:
|
||||||
msg = "This wallet seed is not supported anymore."
|
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
|
msg += "\nTo open this wallet, try 'git checkout seed_v%d'"%seed_version
|
||||||
raise BaseException(msg)
|
raise BaseException(msg)
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ from electrum.bitcoin import EncodeBase58Check, public_key_to_bc_address, bc_add
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
from electrum.plugins import BasePlugin, hook
|
from electrum.plugins import BasePlugin, hook
|
||||||
from electrum.transaction import deserialize
|
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.util import print_error
|
||||||
|
|
||||||
from electrum_gui.qt.password_dialog import make_password_dialog, run_password_dialog
|
from electrum_gui.qt.password_dialog import make_password_dialog, run_password_dialog
|
||||||
|
@ -161,11 +161,12 @@ class Plugin(BasePlugin):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class TrezorWallet(NewWallet):
|
class TrezorWallet(BIP32_HD_Wallet):
|
||||||
wallet_type = 'trezor'
|
wallet_type = 'trezor'
|
||||||
|
root_derivation = "m/44'/0'"
|
||||||
|
|
||||||
def __init__(self, storage):
|
def __init__(self, storage):
|
||||||
NewWallet.__init__(self, storage)
|
BIP32_HD_Wallet.__init__(self, storage)
|
||||||
self.transport = None
|
self.transport = None
|
||||||
self.client = None
|
self.client = None
|
||||||
self.mpk = None
|
self.mpk = None
|
||||||
|
|
Loading…
Reference in New Issue