A fix and cleanups for hardware wallets
This commit is contained in:
parent
8f91af28a5
commit
c298860e11
|
@ -1681,7 +1681,8 @@ class BIP32_HD_Wallet(BIP32_Wallet):
|
|||
|
||||
def create_main_account(self, password):
|
||||
# First check the password is valid (this raises if it isn't).
|
||||
self.check_password(password)
|
||||
if self.can_change_password():
|
||||
self.check_password(password)
|
||||
assert self.next_account_number() == 0
|
||||
self.create_next_account(password, _('Main account'))
|
||||
self.create_next_account(password)
|
||||
|
|
|
@ -84,9 +84,6 @@ class KeepKeyWallet(BIP32_HD_Wallet):
|
|||
account_id, (change, address_index) = self.get_address_index(address)
|
||||
return "44'/0'/%s'/%d/%d" % (account_id, change, address_index)
|
||||
|
||||
def create_main_account(self, password):
|
||||
self.create_account('Main account', None) #name, empty password
|
||||
|
||||
def mnemonic_to_seed(self, mnemonic, passphrase):
|
||||
# keepkey uses bip39
|
||||
import pbkdf2, hashlib, hmac
|
||||
|
@ -96,15 +93,9 @@ class KeepKeyWallet(BIP32_HD_Wallet):
|
|||
return pbkdf2.PBKDF2(mnemonic, 'mnemonic' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64)
|
||||
|
||||
def derive_xkeys(self, root, derivation, password):
|
||||
x = self.master_private_keys.get(root)
|
||||
if x:
|
||||
root_xprv = pw_decode(x, password)
|
||||
xprv, xpub = bip32_private_derivation(root_xprv, root, derivation)
|
||||
return xpub, xprv
|
||||
else:
|
||||
derivation = derivation.replace(self.root_name,"44'/0'/")
|
||||
xpub = self.get_public_key(derivation)
|
||||
return xpub, None
|
||||
derivation = derivation.replace(self.root_name,"44'/0'/")
|
||||
xpub = self.get_public_key(derivation)
|
||||
return xpub, None
|
||||
|
||||
def get_public_key(self, bip32_path):
|
||||
address_n = self.plugin.get_client().expand_path(bip32_path)
|
||||
|
@ -480,4 +471,3 @@ if KEEPKEY:
|
|||
raise
|
||||
|
||||
return resp
|
||||
|
||||
|
|
|
@ -65,11 +65,6 @@ class BTChipWallet(BIP32_HD_Wallet):
|
|||
def can_create_accounts(self):
|
||||
return False
|
||||
|
||||
def synchronize(self):
|
||||
# synchronize existing accounts
|
||||
BIP32_Wallet.synchronize(self)
|
||||
# no further accounts for the moment
|
||||
|
||||
def can_change_password(self):
|
||||
return False
|
||||
|
||||
|
@ -152,9 +147,6 @@ class BTChipWallet(BIP32_HD_Wallet):
|
|||
account_id, (change, address_index) = self.get_address_index(address)
|
||||
return "44'/0'/%s'/%d/%d" % (account_id, change, address_index)
|
||||
|
||||
def create_main_account(self, password):
|
||||
self.create_account('Main account', None) #name, empty password
|
||||
|
||||
def derive_xkeys(self, root, derivation, password):
|
||||
derivation = derivation.replace(self.root_name,"44'/0'/")
|
||||
xpub = self.get_public_key(derivation)
|
||||
|
@ -494,5 +486,3 @@ class LedgerPlugin(BasePlugin):
|
|||
self.wallet.sign_transaction(tx, None)
|
||||
except Exception as e:
|
||||
tx.error = str(e)
|
||||
|
||||
|
||||
|
|
|
@ -83,9 +83,6 @@ class TrezorWallet(BIP32_HD_Wallet):
|
|||
account_id, (change, address_index) = self.get_address_index(address)
|
||||
return "44'/0'/%s'/%d/%d" % (account_id, change, address_index)
|
||||
|
||||
def create_main_account(self, password):
|
||||
self.create_account('Main account', None) #name, empty password
|
||||
|
||||
def mnemonic_to_seed(self, mnemonic, passphrase):
|
||||
# trezor uses bip39
|
||||
import pbkdf2, hashlib, hmac
|
||||
|
@ -95,15 +92,9 @@ class TrezorWallet(BIP32_HD_Wallet):
|
|||
return pbkdf2.PBKDF2(mnemonic, 'mnemonic' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64)
|
||||
|
||||
def derive_xkeys(self, root, derivation, password):
|
||||
x = self.master_private_keys.get(root)
|
||||
if x:
|
||||
root_xprv = pw_decode(x, password)
|
||||
xprv, xpub = bip32_private_derivation(root_xprv, root, derivation)
|
||||
return xpub, xprv
|
||||
else:
|
||||
derivation = derivation.replace(self.root_name,"44'/0'/")
|
||||
xpub = self.get_public_key(derivation)
|
||||
return xpub, None
|
||||
derivation = derivation.replace(self.root_name,"44'/0'/")
|
||||
xpub = self.get_public_key(derivation)
|
||||
return xpub, None
|
||||
|
||||
def get_public_key(self, bip32_path):
|
||||
address_n = self.plugin.get_client().expand_path(bip32_path)
|
||||
|
|
Loading…
Reference in New Issue