# Path: keepkeylib/tools.py
# def parse_path(nstr):
#     """
#     Convert BIP32 path string to list of uint32 integers with hardened flags.
#     Several conventions are supported to set the hardened flag: -1, 1', 1h
#     e.g.: "0/1h/1" -> [0, 0x80000001, 1]
#     :param nstr: path string
#     :return: list of integers
#     """
#     if not nstr:
#         return []
# 
#     n = nstr.split('/')
# 
#     # m/a/b/c => a/b/c
#     if n[0] == 'm':
#         n = n[1:]
# 
#     # coin_name/a/b/c => 44'/SLIP44_constant'/a/b/c
#     #if n[0] in slip44:
#     #    coin_id = slip44[n[0]]
#     #    n[0:1] = ['44h', '{}h'.format(coin_id)]
# 
#     def str_to_harden(x):
#         if x.startswith('-'):
#             return H_(abs(int(x)))
#         elif x.endswith(('h', "'")):
#             return H_(int(x[:-1]))
#         else:
#             return int(x)
# 
#     try:
#         return list(str_to_harden(x) for x in n)
#     except Exception:
#         raise ValueError('Invalid BIP32 path', nstr)


import unittest
import common
import keepkeylib.messages_pb2 as proto
import keepkeylib.types_pb2 as proto_types
import keepkeylib.exchange_pb2 as proto_exchange
from base64 import b64encode
from binascii import hexlify, unhexlify
from keepkeylib.tools import parse_path
                1000
            )],
            memo="KeepKey",
            sequence=2
        )

        self.assertEqual(hexlify(signature.signature), "ff04dbada6d95d2639d1a6a62b23f93e958d22423156f771248520b495c58a7a0aa1a877ce3819544d203e400c9f256b9fe49e1fcc1f723964c73e1df0a5e3c2")


    def test_onchain2(self):
        self.requires_firmware("6.3.0")
        self.client.load_device_by_mnemonic(
          mnemonic='hybrid anger habit story vibrant grit ill sense duck butter heavy frame',
          pin='',
          passphrase_protection=False,
          label='test',
          language='english'
        )

        # https://www.mintscan.io/txs/93c7f98bf0ab2f727832f08344d8bd8d0c14021c160a904c512b93082d2fb694
        signature = self.client.cosmos_sign_tx(
            address_n=parse_path(DEFAULT_BIP32_PATH),
            account_number=24250,
            chain_id="cosmoshub-2",
            fee=1000,
            gas=28000,
            msgs=[make_send(
                "cosmos1934nqs0ke73lm5ej8hs9uuawkl3ztesg9jp5c5",
                "cosmos14um3sf75lc0kpvgrpj9hspqtv0375epn05cpfa",
                47000

# Path: keepkeylib/tools.py
# def parse_path(nstr):
#     """
#     Convert BIP32 path string to list of uint32 integers with hardened flags.
#     Several conventions are supported to set the hardened flag: -1, 1', 1h
#     e.g.: "0/1h/1" -> [0, 0x80000001, 1]
#     :param nstr: path string
#     :return: list of integers
#     """
#     if not nstr:
#         return []
# 
#     n = nstr.split('/')
# 
#     # m/a/b/c => a/b/c
#     if n[0] == 'm':
#         n = n[1:]
# 
#     # coin_name/a/b/c => 44'/SLIP44_constant'/a/b/c
#     #if n[0] in slip44:
#     #    coin_id = slip44[n[0]]
#     #    n[0:1] = ['44h', '{}h'.format(coin_id)]
# 
#     def str_to_harden(x):
#         if x.startswith('-'):
#             return H_(abs(int(x)))
#         elif x.endswith(('h', "'")):
#             return H_(int(x[:-1]))
#         else:
#             return int(x)
# 
#     try:
#         return list(str_to_harden(x) for x in n)
#     except Exception:
#         raise ValueError('Invalid BIP32 path', nstr)


# Path: tests/test_msg_cosmos_signtx.py
import unittest
import common
import keepkeylib.messages_pb2 as proto
import keepkeylib.types_pb2 as proto_types
import keepkeylib.exchange_pb2 as proto_exchange
from base64 import b64encode
from binascii import hexlify, unhexlify
from keepkeylib.tools import parse_path

                1000
            )],
            memo="KeepKey",
            sequence=2
        )

        self.assertEqual(hexlify(signature.signature), "ff04dbada6d95d2639d1a6a62b23f93e958d22423156f771248520b495c58a7a0aa1a877ce3819544d203e400c9f256b9fe49e1fcc1f723964c73e1df0a5e3c2")


    def test_onchain2(self):
        self.requires_firmware("6.3.0")
        self.client.load_device_by_mnemonic(
          mnemonic='hybrid anger habit story vibrant grit ill sense duck butter heavy frame',
          pin='',
          passphrase_protection=False,
          label='test',
          language='english'
        )

        # https://www.mintscan.io/txs/93c7f98bf0ab2f727832f08344d8bd8d0c14021c160a904c512b93082d2fb694
        signature = self.client.cosmos_sign_tx(
            address_n=parse_path(DEFAULT_BIP32_PATH),
            account_number=24250,
            chain_id="cosmoshub-2",
            fee=1000,
            gas=28000,
            msgs=[make_send(
                "cosmos1934nqs0ke73lm5ej8hs9uuawkl3ztesg9jp5c5",
                "cosmos14um3sf75lc0kpvgrpj9hspqtv0375epn05cpfa",
                47000

            )],