# 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
        self.requires_firmware("7.0.2")
        self.setup_mnemonic_nopin_nopassphrase()
        sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
                        n=[2147483692,2147483708,2147483648,0,0],
            nonce=0x0,
            gas_price=0x5FB9ACA00,
            gas_limit=0x186A0,
            value=0x00,
            to=unhexlify('41e5560054824ea6b0732e656e3ad64e20e94e45'),
            address_type=0,
            chain_id=1,
            data=unhexlify('1fece7b4' +
            '0000000000000000000000000000000000000000000000000000000000000000' + 
            '0000000000000000000000000000000000000000000000000000000000000000' +
            '0000000000000000000000000000000000000000000000000000000000000000' +
            '0000000000000000000000000000000000000000000000000000000000000080' +  # offset of memo string from 4
            '000000000000000000000000000000000000000000000000000000000000003b' +  # length of memo string in bytes
            # ADD:ETH.ETH:0xc5b2608927ea95ed43f842f553e3a27b09c050e8:420
            '4144443a4554482e4554483a3078633562323630383932376561393565643433' +
            '663834326635353365336132376230396330353065383a343230000000000000')

        )
        self.assertEqual(sig_v, 37)
        self.assertEqual(hexlify(sig_r), '638f9f42c099d0d47f7fc70d248249d2db24ecabc2fdee5bf2f5ad73b5bbfd30')
        self.assertEqual(hexlify(sig_s), '3dae036aabbe0ec55f7b9e4eef54e2b5335f62544d8c2ed041797a9397f185c7')

    def test_thorchain_remove_liquidity(self):
        self.requires_firmware("7.1.1")
        self.setup_mnemonic_nopin_nopassphrase()
        signature = self.client.thorchain_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_thorchain_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

        self.requires_firmware("7.0.2")
        self.setup_mnemonic_nopin_nopassphrase()
        sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
                        n=[2147483692,2147483708,2147483648,0,0],
            nonce=0x0,
            gas_price=0x5FB9ACA00,
            gas_limit=0x186A0,
            value=0x00,
            to=unhexlify('41e5560054824ea6b0732e656e3ad64e20e94e45'),
            address_type=0,
            chain_id=1,
            data=unhexlify('1fece7b4' +
            '0000000000000000000000000000000000000000000000000000000000000000' + 
            '0000000000000000000000000000000000000000000000000000000000000000' +
            '0000000000000000000000000000000000000000000000000000000000000000' +
            '0000000000000000000000000000000000000000000000000000000000000080' +  # offset of memo string from 4
            '000000000000000000000000000000000000000000000000000000000000003b' +  # length of memo string in bytes
            # ADD:ETH.ETH:0xc5b2608927ea95ed43f842f553e3a27b09c050e8:420
            '4144443a4554482e4554483a3078633562323630383932376561393565643433' +
            '663834326635353365336132376230396330353065383a343230000000000000')

        )
        self.assertEqual(sig_v, 37)
        self.assertEqual(hexlify(sig_r), '638f9f42c099d0d47f7fc70d248249d2db24ecabc2fdee5bf2f5ad73b5bbfd30')
        self.assertEqual(hexlify(sig_s), '3dae036aabbe0ec55f7b9e4eef54e2b5335f62544d8c2ed041797a9397f185c7')

    def test_thorchain_remove_liquidity(self):
        self.requires_firmware("7.1.1")
        self.setup_mnemonic_nopin_nopassphrase()
        signature = self.client.thorchain_sign_tx(

            address_n=parse_path(DEFAULT_BIP32_PATH),