Have BTChipWallet derive from BIP44_Wallet
Narrowing the gap with the Trezor code a bit
This commit is contained in:
parent
2c29cd3bba
commit
9946feb352
|
@ -1746,6 +1746,7 @@ class BIP32_HD_Wallet(BIP32_Wallet):
|
|||
class BIP44_Wallet(BIP32_HD_Wallet):
|
||||
root_derivation = "m/44'/0'"
|
||||
wallet_type = 'bip44'
|
||||
restore_wallet_class = BIP44_Wallet
|
||||
|
||||
def can_sign_xpubkey(self, x_pubkey):
|
||||
xpub, sequence = BIP32_Account.parse_xpubkey(x_pubkey)
|
||||
|
|
|
@ -30,17 +30,14 @@ except ImportError:
|
|||
BTCHIP = False
|
||||
|
||||
|
||||
class BTChipWallet(BIP32_HD_Wallet):
|
||||
class BTChipWallet(BIP44_Wallet):
|
||||
wallet_type = 'btchip'
|
||||
device = 'Ledger'
|
||||
root_derivation = "m/44'/0'"
|
||||
restore_wallet_class = BIP44_Wallet
|
||||
|
||||
def __init__(self, storage):
|
||||
BIP32_HD_Wallet.__init__(self, storage)
|
||||
BIP44_Wallet.__init__(self, storage)
|
||||
self.transport = None
|
||||
self.client = None
|
||||
self.mpk = None
|
||||
self.device_checked = False
|
||||
self.signing = False
|
||||
self.force_watching_only = False
|
||||
|
@ -56,10 +53,6 @@ class BTChipWallet(BIP32_HD_Wallet):
|
|||
self.device_checked = False
|
||||
raise Exception(message)
|
||||
|
||||
def can_sign_xpubkey(self, x_pubkey):
|
||||
xpub, sequence = BIP32_Account.parse_xpubkey(x_pubkey)
|
||||
return xpub in self.master_public_keys.values()
|
||||
|
||||
def can_create_accounts(self):
|
||||
return False
|
||||
|
||||
|
@ -142,18 +135,11 @@ class BTChipWallet(BIP32_HD_Wallet):
|
|||
self.proper_device = False
|
||||
return self.client
|
||||
|
||||
def address_id(self, address):
|
||||
account_id, (change, address_index) = self.get_address_index(address)
|
||||
return "44'/0'/%s'/%d/%d" % (account_id, change, address_index)
|
||||
|
||||
def derive_xkeys(self, root, derivation, password):
|
||||
derivation = derivation.replace(self.root_name,"44'/0'/")
|
||||
xpub = self.get_public_key(derivation)
|
||||
return xpub, None
|
||||
|
||||
def get_private_key(self, address, password):
|
||||
return []
|
||||
|
||||
def get_public_key(self, bip32_path):
|
||||
# S-L-O-W - we don't handle the fingerprint directly, so compute it manually from the previous node
|
||||
# This only happens once so it's bearable
|
||||
|
@ -185,21 +171,9 @@ class BTChipWallet(BIP32_HD_Wallet):
|
|||
|
||||
return EncodeBase58Check(xpub)
|
||||
|
||||
def get_master_public_key(self):
|
||||
try:
|
||||
if not self.mpk:
|
||||
self.mpk = self.get_public_key("44'/0'")
|
||||
return self.mpk
|
||||
except Exception, e:
|
||||
self.give_error(e, True)
|
||||
|
||||
def i4b(self, x):
|
||||
return pack('>I', x)
|
||||
|
||||
def add_keypairs(self, tx, keypairs, password):
|
||||
#do nothing - no priv keys available
|
||||
pass
|
||||
|
||||
def decrypt_message(self, pubkey, message, password):
|
||||
self.give_error("Not supported")
|
||||
|
||||
|
|
|
@ -32,8 +32,6 @@ class TrezorCompatibleWallet(BIP44_Wallet):
|
|||
# - DEVICE_IDS
|
||||
# - wallet_type
|
||||
|
||||
restore_wallet_class = BIP44_Wallet
|
||||
|
||||
def __init__(self, storage):
|
||||
BIP44_Wallet.__init__(self, storage)
|
||||
# After timeout seconds we clear the device session
|
||||
|
|
Loading…
Reference in New Issue