# Path: keepkeylib/client.py
# class CallException(Exception):
#     def __init__(self, code, message):
#         super(CallException, self).__init__()
#         self.args = [code, message]
# 
# 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 unittest
import common
import binascii
import itertools
import keepkeylib.messages_pb2 as proto
import keepkeylib.types_pb2 as proto_types
from keepkeylib.client import CallException
from keepkeylib import tx_api
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library.  If not, see <http://www.gnu.org/licenses/>.
#
# The script has been modified for KeepKey Device.



class TestMsgSigntxGRS(common.KeepKeyTest):
    def test_one_one_fee(self):
        # http://blockbook.groestlcoin.org/tx/f56521b17b828897f72b30dd21b0192fd942342e89acbb06abf1d446282c30f5
        # ptx1: http://blockbook.groestlcoin.org/tx/cb74c8478c5814742c87cffdb4a21231869888f8042fb07a90e015a9db1f9d4a

        self.setup_mnemonic_allallall()

        ptx1hash='cb74c8478c5814742c87cffdb4a21231869888f8042fb07a90e015a9db1f9d4a'

        inp1 = proto_types.TxInputType(address_n=[44 | 0x80000000, 17 | 0x80000000, 0 | 0x80000000, 0, 2],  #  FXHDsC5ZqWQHkDmShzgRVZ1MatpWhwxTAA
                prev_hash=binascii.unhexlify(ptx1hash),
                prev_index=0,
                )

        out1 = proto_types.TxOutputType(address='FtM4zAn9aVYgHgxmamWBgWPyZsb6RhvkA9',
                amount=210016 - 192,
                script_type=proto_types.PAYTOADDRESS,
                )

        with self.client:
            self.client.set_tx_api(tx_api.TxApiGroestlcoin)

# Path: keepkeylib/client.py
# class CallException(Exception):
#     def __init__(self, code, message):
#         super(CallException, self).__init__()
#         self.args = [code, message]
# 
# 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_grs.py
import unittest
import common
import binascii
import itertools
import keepkeylib.messages_pb2 as proto
import keepkeylib.types_pb2 as proto_types
from keepkeylib.client import CallException
from keepkeylib import tx_api

# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library.  If not, see <http://www.gnu.org/licenses/>.
#
# The script has been modified for KeepKey Device.



class TestMsgSigntxGRS(common.KeepKeyTest):
    def test_one_one_fee(self):
        # http://blockbook.groestlcoin.org/tx/f56521b17b828897f72b30dd21b0192fd942342e89acbb06abf1d446282c30f5
        # ptx1: http://blockbook.groestlcoin.org/tx/cb74c8478c5814742c87cffdb4a21231869888f8042fb07a90e015a9db1f9d4a

        self.setup_mnemonic_allallall()

        ptx1hash='cb74c8478c5814742c87cffdb4a21231869888f8042fb07a90e015a9db1f9d4a'

        inp1 = proto_types.TxInputType(address_n=[44 | 0x80000000, 17 | 0x80000000, 0 | 0x80000000, 0, 2],  #  FXHDsC5ZqWQHkDmShzgRVZ1MatpWhwxTAA
                prev_hash=binascii.unhexlify(ptx1hash),
                prev_index=0,
                )

        out1 = proto_types.TxOutputType(address='FtM4zAn9aVYgHgxmamWBgWPyZsb6RhvkA9',
                amount=210016 - 192,
                script_type=proto_types.PAYTOADDRESS,
                )

        with self.client:
            self.client.set_tx_api(tx_api.TxApiGroestlcoin)

            self.client.set_expected_responses([