Move to_account_path() to utils

pull/1153/head
gabrielkerekes 4 years ago committed by Pavol Rusnak
parent e92baf5b02
commit a25444efd1

@ -1,5 +1,3 @@
from micropython import const
from trezor import wire from trezor import wire
from trezor.crypto import base58, hashlib from trezor.crypto import base58, hashlib
from trezor.messages import CardanoAddressParametersType, CardanoAddressType from trezor.messages import CardanoAddressParametersType, CardanoAddressType
@ -331,8 +329,3 @@ def _derive_reward_address(
staking_key_hash = get_public_key_hash(keychain, path) staking_key_hash = get_public_key_hash(keychain, path)
return header + staking_key_hash return header + staking_key_hash
def to_account_path(path: List[int]) -> List[int]:
ACCOUNT_PATH_LENGTH = const(3)
return path[:ACCOUNT_PATH_LENGTH]

@ -5,8 +5,9 @@ from apps.common import paths
from apps.common.layout import address_n_to_str, show_qr from apps.common.layout import address_n_to_str, show_qr
from . import CURVE, seed from . import CURVE, seed
from .address import derive_human_readable_address, to_account_path, validate_full_path from .address import derive_human_readable_address, validate_full_path
from .helpers import protocol_magics, staking_use_cases from .helpers import protocol_magics, staking_use_cases
from .helpers.utils import to_account_path
from .layout import ( from .layout import (
show_address, show_address,
show_warning_address_foreign_staking_key, show_warning_address_foreign_staking_key,

@ -1,7 +1,8 @@
from trezor.messages import CardanoAddressType from trezor.messages import CardanoAddressType
from ..address import get_public_key_hash, to_account_path, validate_full_path from ..address import get_public_key_hash, validate_full_path
from ..seed import is_shelley_path from ..seed import is_shelley_path
from .utils import to_account_path
if False: if False:
from typing import List from typing import List

@ -1,3 +1,6 @@
from micropython import const
def variable_length_encode(number: int) -> bytes: def variable_length_encode(number: int) -> bytes:
""" """
Used for pointer encoding in pointer address. Used for pointer encoding in pointer address.
@ -18,3 +21,8 @@ def variable_length_encode(number: int) -> bytes:
encoded.insert(0, (number & 127) + 128) encoded.insert(0, (number & 127) + 128)
return bytes(encoded) return bytes(encoded)
def to_account_path(path: List[int]) -> List[int]:
ACCOUNT_PATH_LENGTH = const(3)
return path[:ACCOUNT_PATH_LENGTH]

@ -15,12 +15,12 @@ from .address import (
derive_address_bytes, derive_address_bytes,
derive_human_readable_address, derive_human_readable_address,
get_address_bytes_unsafe, get_address_bytes_unsafe,
to_account_path,
validate_full_path, validate_full_path,
validate_output_address, validate_output_address,
) )
from .byron_address import get_address_attributes from .byron_address import get_address_attributes
from .helpers import network_ids, protocol_magics, staking_use_cases from .helpers import network_ids, protocol_magics, staking_use_cases
from .helpers.utils import to_account_path
from .layout import ( from .layout import (
confirm_sending, confirm_sending,
confirm_transaction, confirm_transaction,

Loading…
Cancel
Save