# 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
            }]
        }
    }

class TestMsgCosmosSignTx(common.KeepKeyTest):
    def test_cosmos_sign_tx(self):
        self.requires_firmware("6.3.0")
        self.setup_mnemonic_nopin_nopassphrase()
        signature = self.client.cosmos_sign_tx(
            address_n=parse_path(DEFAULT_BIP32_PATH),
            account_number=19637,
            chain_id="cosmoshub-2",
            fee=5000,
            gas=200000,
            msgs=[make_send(
                "cosmos15cenya0tr7nm3tz2wn3h3zwkht2rxrq7q7h3dj",
                "cosmos18vhdczjut44gpsy804crfhnd5nq003nz0nf20v",
                100000
            )],
            memo="",
            sequence=3
        )
        self.assertEqual(hexlify(signature.signature), "4a200cc240df784ac19d1c51ee1ea47c8e257327dd3a3c4ff89d90cbba861b711d3a61929ce3c41e68c4722e63e6a60d553c46b82e9dac3b1f6ad9382b508ccf")
        self.assertEqual(hexlify(signature.public_key), "03bee3af30e53a73f38abc5a2fcdac426d7b04eb72a8ebd3b01992e2d206e24ad8")


    def test_cosmos_sign_tx_memo(self):
        self.requires_firmware("6.3.0")
        self.setup_mnemonic_nopin_nopassphrase()
        signature = self.client.cosmos_sign_tx(

# 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

            }]
        }
    }

class TestMsgCosmosSignTx(common.KeepKeyTest):
    def test_cosmos_sign_tx(self):
        self.requires_firmware("6.3.0")
        self.setup_mnemonic_nopin_nopassphrase()
        signature = self.client.cosmos_sign_tx(
            address_n=parse_path(DEFAULT_BIP32_PATH),
            account_number=19637,
            chain_id="cosmoshub-2",
            fee=5000,
            gas=200000,
            msgs=[make_send(
                "cosmos15cenya0tr7nm3tz2wn3h3zwkht2rxrq7q7h3dj",
                "cosmos18vhdczjut44gpsy804crfhnd5nq003nz0nf20v",
                100000
            )],
            memo="",
            sequence=3
        )
        self.assertEqual(hexlify(signature.signature), "4a200cc240df784ac19d1c51ee1ea47c8e257327dd3a3c4ff89d90cbba861b711d3a61929ce3c41e68c4722e63e6a60d553c46b82e9dac3b1f6ad9382b508ccf")
        self.assertEqual(hexlify(signature.public_key), "03bee3af30e53a73f38abc5a2fcdac426d7b04eb72a8ebd3b01992e2d206e24ad8")


    def test_cosmos_sign_tx_memo(self):
        self.requires_firmware("6.3.0")
        self.setup_mnemonic_nopin_nopassphrase()
        signature = self.client.cosmos_sign_tx(

            address_n=parse_path(DEFAULT_BIP32_PATH),