# 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



DEFAULT_BIP32_PATH = "m/44h/118h/0h/0/0"

def make_send(from_address, to_address, amount):
    return {
        'type': 'cosmos-sdk/MsgSend',
        'value': {
            'from_address': from_address,
            'to_address': to_address,
            'amount': [{
                'denom': 'uatom',
                'amount': str(amount)
            }]
        }
    }

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(

# 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




DEFAULT_BIP32_PATH = "m/44h/118h/0h/0/0"

def make_send(from_address, to_address, amount):
    return {
        'type': 'cosmos-sdk/MsgSend',
        'value': {
            'from_address': from_address,
            'to_address': to_address,
            'amount': [{
                'denom': 'uatom',
                'amount': str(amount)
            }]
        }
    }

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),