fix: merge len bip32 with path function
This commit is contained in:
@@ -6,7 +6,7 @@ from typing import List, Tuple, Union, Iterator, cast
|
|||||||
|
|
||||||
from ethereum_client.transaction import EIP712, PersonalTransaction, Transaction
|
from ethereum_client.transaction import EIP712, PersonalTransaction, Transaction
|
||||||
from ethereum_client.plugin import ERC20Information, Plugin
|
from ethereum_client.plugin import ERC20Information, Plugin
|
||||||
from ethereum_client.utils import bip32_path_from_string
|
from ethereum_client.utils import packed_bip32_path_from_string
|
||||||
|
|
||||||
MAX_APDU_LEN: int = 255
|
MAX_APDU_LEN: int = 255
|
||||||
|
|
||||||
@@ -156,13 +156,8 @@ class EthereumCommandBuilder:
|
|||||||
APDU command for GET_PUBLIC_KEY.
|
APDU command for GET_PUBLIC_KEY.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
bip32_paths: List[bytes] = bip32_path_from_string(bip32_path)
|
cdata = packed_bip32_path_from_string(bip32_path)
|
||||||
|
|
||||||
cdata: bytes = b"".join([
|
|
||||||
len(bip32_paths).to_bytes(1, byteorder="big"),
|
|
||||||
*bip32_paths
|
|
||||||
])
|
|
||||||
|
|
||||||
return self.serialize(cla=self.CLA,
|
return self.serialize(cla=self.CLA,
|
||||||
ins=InsType.INS_GET_PUBLIC_KEY,
|
ins=InsType.INS_GET_PUBLIC_KEY,
|
||||||
p1=0x01 if display else 0x00,
|
p1=0x01 if display else 0x00,
|
||||||
@@ -180,12 +175,7 @@ class EthereumCommandBuilder:
|
|||||||
Optionnal if returning the shared secret
|
Optionnal if returning the shared secret
|
||||||
|
|
||||||
"""
|
"""
|
||||||
bip32_paths: List[bytes] = bip32_path_from_string(bip32_path)
|
cdata = packed_bip32_path_from_string(bip32_path)
|
||||||
|
|
||||||
cdata: bytes = b"".join([
|
|
||||||
len(bip32_paths).to_bytes(1, byteorder="big"),
|
|
||||||
*bip32_paths
|
|
||||||
])
|
|
||||||
|
|
||||||
return self.serialize(cla=self.CLA,
|
return self.serialize(cla=self.CLA,
|
||||||
ins=InsType.INS_PERFORM_PRIVACY_OPERATION,
|
ins=InsType.INS_PERFORM_PRIVACY_OPERATION,
|
||||||
@@ -210,13 +200,7 @@ class EthereumCommandBuilder:
|
|||||||
APDU command chunk for INS_SIGN_TX.
|
APDU command chunk for INS_SIGN_TX.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
bip32_paths: List[bytes] = bip32_path_from_string(bip32_path)
|
cdata = packed_bip32_path_from_string(bip32_path)
|
||||||
|
|
||||||
cdata: bytes = b"".join([
|
|
||||||
len(bip32_paths).to_bytes(1, byteorder="big"),
|
|
||||||
*bip32_paths
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
tx: bytes = transaction.serialize()
|
tx: bytes = transaction.serialize()
|
||||||
|
|
||||||
@@ -245,12 +229,7 @@ class EthereumCommandBuilder:
|
|||||||
APDU command chunk for INS_SIGN_EIP712.
|
APDU command chunk for INS_SIGN_EIP712.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
bip32_paths: List[bytes] = bip32_path_from_string(bip32_path)
|
cdata = packed_bip32_path_from_string(bip32_path)
|
||||||
|
|
||||||
cdata: bytes = b"".join([
|
|
||||||
len(bip32_paths).to_bytes(1, byteorder="big"),
|
|
||||||
*bip32_paths
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
tx: bytes = transaction.serialize()
|
tx: bytes = transaction.serialize()
|
||||||
@@ -280,13 +259,7 @@ class EthereumCommandBuilder:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
bip32_paths: List[bytes] = bip32_path_from_string(bip32_path)
|
cdata = packed_bip32_path_from_string(bip32_path)
|
||||||
|
|
||||||
cdata: bytes = b"".join([
|
|
||||||
len(bip32_paths).to_bytes(1, byteorder="big"),
|
|
||||||
*bip32_paths
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
tx: bytes = transaction.serialize()
|
tx: bytes = transaction.serialize()
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,15 @@ def bip32_path_from_string(path: str) -> List[bytes]:
|
|||||||
for p in splitted_path]
|
for p in splitted_path]
|
||||||
|
|
||||||
|
|
||||||
|
def packed_bip32_path_from_string(path: str) -> bytes:
|
||||||
|
bip32_paths = bip32_path_from_string(path)
|
||||||
|
|
||||||
|
return b"".join([
|
||||||
|
len(bip32_paths).to_bytes(1, byteorder="big"),
|
||||||
|
*bip32_paths
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
def write_varint(n: int) -> bytes:
|
def write_varint(n: int) -> bytes:
|
||||||
if n < 0xFC:
|
if n < 0xFC:
|
||||||
return n.to_bytes(1, byteorder="little")
|
return n.to_bytes(1, byteorder="little")
|
||||||
|
|||||||
Reference in New Issue
Block a user