bip32: refactor whole module. clean-up.
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import time
|
||||
from struct import pack
|
||||
|
||||
from electrum import ecc
|
||||
from electrum.i18n import _
|
||||
from electrum.util import PrintError, UserCancelled
|
||||
from electrum.keystore import bip39_normalize_passphrase
|
||||
from electrum.bip32 import serialize_xpub, convert_bip32_path_to_list_of_uint32
|
||||
from electrum.bip32 import BIP32Node, convert_bip32_path_to_list_of_uint32
|
||||
|
||||
|
||||
class GuiMixin(object):
|
||||
@@ -154,7 +155,12 @@ class KeepKeyClientBase(GuiMixin, PrintError):
|
||||
address_n = self.expand_path(bip32_path)
|
||||
creating = False
|
||||
node = self.get_public_node(address_n, creating).node
|
||||
return serialize_xpub(xtype, node.chain_code, node.public_key, node.depth, self.i4b(node.fingerprint), self.i4b(node.child_num))
|
||||
return BIP32Node(xtype=xtype,
|
||||
eckey=ecc.ECPubkey(node.public_key),
|
||||
chaincode=node.chain_code,
|
||||
depth=node.depth,
|
||||
fingerprint=self.i4b(node.fingerprint),
|
||||
child_number=self.i4b(node.child_num)).to_xpub()
|
||||
|
||||
def toggle_passphrase(self):
|
||||
if self.features.passphrase_protection:
|
||||
|
||||
@@ -4,7 +4,7 @@ import sys
|
||||
|
||||
from electrum.util import bfh, bh2u, UserCancelled, UserFacingException
|
||||
from electrum.bitcoin import TYPE_ADDRESS, TYPE_SCRIPT
|
||||
from electrum.bip32 import deserialize_xpub
|
||||
from electrum.bip32 import BIP32Node
|
||||
from electrum import constants
|
||||
from electrum.i18n import _
|
||||
from electrum.transaction import deserialize, Transaction
|
||||
@@ -227,13 +227,13 @@ class KeepKeyPlugin(HW_PluginBase):
|
||||
label, language)
|
||||
|
||||
def _make_node_path(self, xpub, address_n):
|
||||
_, depth, fingerprint, child_num, chain_code, key = deserialize_xpub(xpub)
|
||||
bip32node = BIP32Node.from_xkey(xpub)
|
||||
node = self.types.HDNodeType(
|
||||
depth=depth,
|
||||
fingerprint=int.from_bytes(fingerprint, 'big'),
|
||||
child_num=int.from_bytes(child_num, 'big'),
|
||||
chain_code=chain_code,
|
||||
public_key=key,
|
||||
depth=bip32node.depth,
|
||||
fingerprint=int.from_bytes(bip32node.fingerprint, 'big'),
|
||||
child_num=int.from_bytes(bip32node.child_number, 'big'),
|
||||
chain_code=bip32node.chaincode,
|
||||
public_key=bip32node.eckey.get_public_key_bytes(compressed=True),
|
||||
)
|
||||
return self.types.HDNodePathType(node=node, address_n=address_n)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user