# Path: keepkeylib/ckd_public.py
# PRIME_DERIVATION_FLAG = 0x80000000
#     I64 = hmac.HMAC(key=node.chain_code, msg=data, digestmod=hashlib.sha512).digest()
# def point_to_pubkey(point):
# def sec_to_public_pair(pubkey):
#     def public_pair_for_x(generator, x, is_even):
# def is_prime(n):
# def fingerprint(pubkey):
# def get_address(public_node, address_type):
# def public_ckd(public_node, n):
# def get_subnode(node, i):
# def serialize(node, version=0x0488B21E):
# def deserialize(xpub):
# 
# Path: keepkeylib/client.py
# class CallException(Exception):
#     def __init__(self, code, message):
#         super(CallException, self).__init__()
#         self.args = [code, message]
# 
# 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: keepkeylib/tx_api.py
# def pack_varint(n):
#     def __init__(self, network, url):
#     def fetch_json(self, url, resource, resourceid):
#     def get_tx(self, txhash):
#     def __init__(self, network, url, zcash=None):
#     def get_tx(self, txhash):
#     def get_raw_tx(self, txhash):
# class TxApi(object):
# class TxApiInsight(TxApi):


import common
import unittest
from binascii import hexlify, unhexlify
from keepkeylib import ckd_public as bip32
from common import KeepKeyTest
from keepkeylib import messages_pb2 as proto
from keepkeylib import types_pb2 as proto_types
from keepkeylib.client import CallException
from keepkeylib.tools import parse_path
from keepkeylib.tx_api import TxApiGroestlcoinTestnet
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.





# https://blockbook-test.groestlcoin.org/tx/9b5c4859a8a31e69788cb4402812bb28f14ad71cbd8c60b09903478bc56f79a3
class TestMsgSigntxNativeSegwitGRS(KeepKeyTest):

    def test_send_native(self):
        self.setup_mnemonic_allallall()
        self.client.set_tx_api(TxApiGroestlcoinTestnet)
        inp1 = proto_types.TxInputType(

# Path: keepkeylib/ckd_public.py
# PRIME_DERIVATION_FLAG = 0x80000000
#     I64 = hmac.HMAC(key=node.chain_code, msg=data, digestmod=hashlib.sha512).digest()
# def point_to_pubkey(point):
# def sec_to_public_pair(pubkey):
#     def public_pair_for_x(generator, x, is_even):
# def is_prime(n):
# def fingerprint(pubkey):
# def get_address(public_node, address_type):
# def public_ckd(public_node, n):
# def get_subnode(node, i):
# def serialize(node, version=0x0488B21E):
# def deserialize(xpub):
# 
# Path: keepkeylib/client.py
# class CallException(Exception):
#     def __init__(self, code, message):
#         super(CallException, self).__init__()
#         self.args = [code, message]
# 
# 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: keepkeylib/tx_api.py
# def pack_varint(n):
#     def __init__(self, network, url):
#     def fetch_json(self, url, resource, resourceid):
#     def get_tx(self, txhash):
#     def __init__(self, network, url, zcash=None):
#     def get_tx(self, txhash):
#     def get_raw_tx(self, txhash):
# class TxApi(object):
# class TxApiInsight(TxApi):


# Path: tests/test_msg_signtx_segwit_native_grs.py
import common
import unittest
from binascii import hexlify, unhexlify
from keepkeylib import ckd_public as bip32
from common import KeepKeyTest
from keepkeylib import messages_pb2 as proto
from keepkeylib import types_pb2 as proto_types
from keepkeylib.client import CallException
from keepkeylib.tools import parse_path
from keepkeylib.tx_api import TxApiGroestlcoinTestnet

# This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.





# https://blockbook-test.groestlcoin.org/tx/9b5c4859a8a31e69788cb4402812bb28f14ad71cbd8c60b09903478bc56f79a3
class TestMsgSigntxNativeSegwitGRS(KeepKeyTest):

    def test_send_native(self):
        self.setup_mnemonic_allallall()
        self.client.set_tx_api(TxApiGroestlcoinTestnet)
        inp1 = proto_types.TxInputType(

            address_n=parse_path("84'/1'/0'/0/0"), # tgrs1qkvwu9g3k2pdxewfqr7syz89r3gj557l3ued7ja