1
0

TrezorWallet: don't duplicate base class funcs

This commit is contained in:
Neil Booth
2015-12-28 22:11:11 +09:00
parent 791d3a2aa2
commit d843e41884

View File

@@ -4,7 +4,7 @@ from struct import pack
from electrum.account import BIP32_Account from electrum.account import BIP32_Account
from electrum.bitcoin import (bc_address_to_hash_160, xpub_from_pubkey, from electrum.bitcoin import (bc_address_to_hash_160, xpub_from_pubkey,
bip32_private_derivation, EncodeBase58Check) EncodeBase58Check)
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, is_extended_pubkey, from electrum.transaction import (deserialize, is_extended_pubkey,
@@ -21,7 +21,6 @@ class TrezorCompatibleWallet(BIP44_Wallet):
def __init__(self, storage): def __init__(self, storage):
BIP44_Wallet.__init__(self, storage) BIP44_Wallet.__init__(self, storage)
self.mpk = None
self.checked_device = False self.checked_device = False
self.proper_device = False self.proper_device = False
@@ -46,15 +45,13 @@ class TrezorCompatibleWallet(BIP44_Wallet):
return self.plugin.get_client() return self.plugin.get_client()
def derive_xkeys(self, root, derivation, password): def derive_xkeys(self, root, derivation, password):
x = self.master_private_keys.get(root) if self.master_public_keys.get(root):
if x: return BIP44_wallet.derive_xkeys(self, root, derivation, password)
root_xprv = pw_decode(x, password)
xprv, xpub = bip32_private_derivation(root_xprv, root, derivation) # Happens when creating a wallet
return xpub, xprv derivation = derivation.replace(self.root_name, self.prefix() + "/")
else: xpub = self.get_public_key(derivation)
derivation = derivation.replace(self.root_name, self.prefix()+"/") return xpub, None
xpub = self.get_public_key(derivation)
return xpub, None
def get_public_key(self, bip32_path): def get_public_key(self, bip32_path):
address_n = self.get_client().expand_path(bip32_path) address_n = self.get_client().expand_path(bip32_path)
@@ -64,11 +61,6 @@ class TrezorCompatibleWallet(BIP44_Wallet):
+ node.chain_code + node.public_key) + node.chain_code + node.public_key)
return EncodeBase58Check(xpub) return EncodeBase58Check(xpub)
def get_master_public_key(self):
if not self.mpk:
self.mpk = self.get_public_key(self.prefix())
return self.mpk
def i4b(self, x): def i4b(self, x):
return pack('>I', x) return pack('>I', x)