# 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 keepkeylib.messages_pb2 as proto
import keepkeylib.types_pb2 as proto_types
from keepkeylib.client import CallException
from keepkeylib.tx_api import TxApiZcashTestnet
# along with this library.  If not, see <http://www.gnu.org/licenses/>.



class TestMsgSigntx(common.KeepKeyTest):

    def test_transparent_one_one(self):
        self.setup_mnemonic_allallall()

        # tx: 08a18fc5a768f8b08c4f5b53a502e2b182107b90b5b4e5f23294074670e57357
        # input 0: 9.99884999 TAZ
        inp1 = proto_types.TxInputType(address_n=[2147483692, 2147483649, 2147483648, 0, 0],  # t1YxYiYy8Hjq5HBN7sioDtTs98SX2SzW5q8
                             #amount=999884999,
                             prev_hash=binascii.unhexlify(b'08a18fc5a768f8b08c4f5b53a502e2b182107b90b5b4e5f23294074670e57357'),
                             prev_index=0,
                             )

        out1 = proto_types.TxOutputType(address='tmJ1xYxP8XNTtCoDgvdmQPSrxh5qZJgy65Z',
                              amount=999884999 - 1940,
                              script_type=proto_types.PAYTOADDRESS,
                              )

        with self.client:
            self.client.set_tx_api(TxApiZcashTestnet)
            self.client.set_expected_responses([
                proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
                proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=binascii.unhexlify(b"08a18fc5a768f8b08c4f5b53a502e2b182107b90b5b4e5f23294074670e57357"))),
                proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"08a18fc5a768f8b08c4f5b53a502e2b182107b90b5b4e5f23294074670e57357"))),
                proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"08a18fc5a768f8b08c4f5b53a502e2b182107b90b5b4e5f23294074670e57357"))),
                proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"08a18fc5a768f8b08c4f5b53a502e2b182107b90b5b4e5f23294074670e57357"))),

# 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_zcash.py
import unittest
import common
import binascii
import keepkeylib.messages_pb2 as proto
import keepkeylib.types_pb2 as proto_types
from keepkeylib.client import CallException
from keepkeylib.tx_api import TxApiZcashTestnet

# along with this library.  If not, see <http://www.gnu.org/licenses/>.



class TestMsgSigntx(common.KeepKeyTest):

    def test_transparent_one_one(self):
        self.setup_mnemonic_allallall()

        # tx: 08a18fc5a768f8b08c4f5b53a502e2b182107b90b5b4e5f23294074670e57357
        # input 0: 9.99884999 TAZ
        inp1 = proto_types.TxInputType(address_n=[2147483692, 2147483649, 2147483648, 0, 0],  # t1YxYiYy8Hjq5HBN7sioDtTs98SX2SzW5q8
                             #amount=999884999,
                             prev_hash=binascii.unhexlify(b'08a18fc5a768f8b08c4f5b53a502e2b182107b90b5b4e5f23294074670e57357'),
                             prev_index=0,
                             )

        out1 = proto_types.TxOutputType(address='tmJ1xYxP8XNTtCoDgvdmQPSrxh5qZJgy65Z',
                              amount=999884999 - 1940,
                              script_type=proto_types.PAYTOADDRESS,
                              )

        with self.client:
            self.client.set_tx_api(TxApiZcashTestnet)
            self.client.set_expected_responses([
                proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
                proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=binascii.unhexlify(b"08a18fc5a768f8b08c4f5b53a502e2b182107b90b5b4e5f23294074670e57357"))),
                proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"08a18fc5a768f8b08c4f5b53a502e2b182107b90b5b4e5f23294074670e57357"))),
                proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"08a18fc5a768f8b08c4f5b53a502e2b182107b90b5b4e5f23294074670e57357"))),
                proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"08a18fc5a768f8b08c4f5b53a502e2b182107b90b5b4e5f23294074670e57357"))),

                proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=2, tx_hash=binascii.unhexlify(b"08a18fc5a768f8b08c4f5b53a502e2b182107b90b5b4e5f23294074670e57357"))),