def test_not_enough_funds(self): self.setup_mnemonic_nopin_nopassphrase() # tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882 # input 0: 0.0039 BTC inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e # amount=390000, prev_hash=binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'), prev_index=0, ) out1 = proto_types.TxOutputType(address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1', amount=400000, script_type=proto_types.PAYTOADDRESS, ) with self.client: 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("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.Failure(code=proto_types.Failure_NotEnoughFunds) ]) try: self.client.sign_tx('Bitcoin', [inp1, ], [out1, ], None, True) except CallException as e: self.assertEqual(e.args[0], proto_types.Failure_NotEnoughFunds) else: self.assert_(False, "types.Failure_NotEnoughFunds expected")
def test_p2sh(self): self.setup_mnemonic_nopin_nopassphrase() inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e # amount=400000, prev_hash=binascii.unhexlify('54aa5680dea781f45ebb536e53dffc526d68c0eb5c00547e323b2c32382dfba3'), prev_index=1, ) out1 = proto_types.TxOutputType(address='3DKGE1pvPpBAgZj94MbCinwmksewUNNYVR', # p2sh amount=400000 - 10000, script_type=proto_types.PAYTOSCRIPTHASH, ) with self.client: 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("54aa5680dea781f45ebb536e53dffc526d68c0eb5c00547e323b2c32382dfba3"))), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("54aa5680dea781f45ebb536e53dffc526d68c0eb5c00547e323b2c32382dfba3"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("54aa5680dea781f45ebb536e53dffc526d68c0eb5c00547e323b2c32382dfba3"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify("54aa5680dea781f45ebb536e53dffc526d68c0eb5c00547e323b2c32382dfba3"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ]) # Accepted by network: tx 8cc1f4adf7224ce855cf535a5104594a0004cb3b640d6714fdb00b9128832dd5 self.assertEqual(binascii.hexlify(serialized_tx), '0100000001a3fb2d38322c3b327e54005cebc0686d52fcdf536e53bb5ef481a7de8056aa54010000006b4830450221009e020b0390ccad533b73b552f8a99a9d827212c558e4f755503674d07c92ad4502202d606f7316990e0461c51d4add25054f19c697aa3e3c2ced4d568f0b2c57e62f0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0170f305000000000017a9147f844bdb0b8fd54b64e3d16c85dc1170f1ff97c18700000000')
def test_signtx(self): self.setup_mnemonic_pin_passphrase() inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e prev_hash=binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'), prev_index=0, ) out1 = proto_types.TxOutputType(address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1', amount=390000 - 10000, script_type=proto_types.PAYTOADDRESS, ) tx_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("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXFINISHED), ] self.client.clear_session() with self.client: # Pin & Passphrase are needed after device is locked self.client.set_expected_responses([ proto.PinMatrixRequest(), proto.PassphraseRequest(), ] + tx_responses) self.client.sign_tx('Bitcoin', [inp1, ], [out1, ]) with self.client: # Pin & Passphrase not needed, since they're cached, and the device is unlocked self.client.set_expected_responses([ ] + tx_responses) self.client.sign_tx('Bitcoin', [inp1, ], [out1, ]) self.client.clear_session() with self.client: # Pin & Passphrase needed again after session is cleared, and the device is locked self.client.set_expected_responses([ proto.PinMatrixRequest(), proto.PassphraseRequest(), ] + tx_responses) self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
def test_send_p2sh_change(self): self.setup_mnemonic_allallall() self.client.set_tx_api(TxApiTestnet) inp1 = proto_types.TxInputType( address_n=parse_path("49'/1'/0'/1/0"), # 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX amount=123456789, prev_hash=unhexlify( '20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337' ), prev_index=0, script_type=proto_types.SPENDP2SHWITNESS, ) out1 = proto_types.TxOutputType( address='mhRx1CeVfaayqRwq5zgRQmD7W5aWBfD5mC', amount=12300000, script_type=proto_types.PAYTOADDRESS, ) out2 = proto_types.TxOutputType( address_n=parse_path("49'/1'/0'/1/0"), script_type=proto_types.PAYTOP2SHWITNESS, amount=123456789 - 11000 - 12300000, ) with self.client: 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.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest( code=proto_types.ButtonRequest_ConfirmOutput), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2]) self.assertEquals( hexlify(serialized_tx), b'0100000000010137c361fb8f2d9056ba8c98c5611930fcb48cacfdd0fe2e0449d83eea982f91200000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff02e0aebb00000000001976a91414fdede0ddc3be652a0ce1afbc1b509a55b6b94888ac3df39f060000000017a91458b53ea7f832e8f096e896b8713a8c6df0e892ca8702483045022100ccd253bfdf8a5593cd7b6701370c531199f0f05a418cd547dfc7da3f21515f0f02203fa08a0753688871c220648f9edadbdb98af42e5d8269364a326572cf703895b012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000' )
def test_spend_coinbase(self): # 25 TEST generated to m/1 (mfiGQVPcRcaEvQPYDErR34DcCovtxYvUUV) # tx: d6da21677d7cca5f42fbc7631d062c9ae918a0254f7c6c22de8e8cb7fd5b8236 # input 0: 25.0027823 BTC self.setup_mnemonic_nopin_nopassphrase() inp1 = proto_types.TxInputType(address_n=[1], # mfiGQVPcRcaEvQPYDErR34DcCovtxYvUUV # amount=390000, prev_hash=binascii.unhexlify('d6da21677d7cca5f42fbc7631d062c9ae918a0254f7c6c22de8e8cb7fd5b8236'), prev_index=0, ) out1 = proto_types.TxOutputType(address='mm6FM31rM5Vc3sw5D7kztiBg3jHUzyqF1g', amount=2500278230 - 10000, script_type=proto_types.PAYTOADDRESS, ) with self.client: self.client.set_tx_api(tx_api.TxApiTestnet) 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("d6da21677d7cca5f42fbc7631d062c9ae918a0254f7c6c22de8e8cb7fd5b8236"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, ], [out1, ], None, True) # Accepted by network: tx self.assertEqual(binascii.hexlify(serialized_tx), '010000000136825bfdb78c8ede226c7c4f25a018e99a2c061d63c7fb425fca7c7d6721dad6000000006a473044022047845c366eb24f40be315c7815a154513c444c7989eb80f7ce7ff6aeb703d26a022007c1f5efadf67c5889634fd7ac39a7ce78bffac291673e8772ecd8389c901d9f01210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff01c6100795000000001976a9143d2496e67f5f57a924353da42d4725b318e7a8ea88ac00000000')
def test_fee_too_high(self): self.setup_mnemonic_nopin_nopassphrase() # tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882 # input 0: 0.0039 BTC inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e # amount=390000, prev_hash=binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'), prev_index=0, ) out1 = proto_types.TxOutputType(address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1', amount=390000 - 250000, script_type=proto_types.PAYTOADDRESS, ) with self.client: 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("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest(code=proto_types.ButtonRequest_FeeOverThreshold), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ], None, True) self.assertEqual(binascii.hexlify(serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b483045022100a3b17b37de3bfecca47f0d49f7bb0d0f68d45df7defe45713d57e83731f5e3d902205404b14630cea6a88b23a5f7c3a1b88494757a8ca5e1c0b0b93cf3c38231c3bd0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff01e0220200000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000')
def test_one_one_fee(self): self.setup_mnemonic_nopin_nopassphrase() # tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882 # input 0: 0.0039 BTC inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e # amount=390000, prev_hash=binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'), prev_index=0, ) out1 = proto_types.TxOutputType(address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1', amount=390000 - 10000, script_type=proto_types.PAYTOADDRESS, ) with self.client: 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("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ], None, True) # Accepted by network: tx fd79435246dee76b2f159d2db08032d666c95adc544de64c8c49f474df4a7fee self.assertEqual(binascii.hexlify(serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b4830450221009a0b7be0d4ed3146ee262b42202841834698bb3ee39c24e7437df208b8b7077102202b79ab1e7736219387dffe8d615bbdba87e11477104b867ef47afed1a5ede7810121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0160cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000')
def test_two_two(self): self.setup_mnemonic_nopin_nopassphrase() # tx: c6be22d34946593bcad1d2b013e12f74159e69574ffea21581dad115572e031c # input 1: 0.0010 BTC # tx: 58497a7757224d1ff1941488d23087071103e5bf855f4c1c44e5c8d9d82ca46e # input 1: 0.0011 BTC inp1 = proto_types.TxInputType( address_n=[1], # 1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb # amount=100000, prev_hash=binascii.unhexlify( 'c6be22d34946593bcad1d2b013e12f74159e69574ffea21581dad115572e031c' ), prev_index=1, ) inp2 = proto_types.TxInputType( address_n=[2], # 15AeAhtNJNKyowK8qPHwgpXkhsokzLtUpG # amount=110000, prev_hash=binascii.unhexlify( '58497a7757224d1ff1941488d23087071103e5bf855f4c1c44e5c8d9d82ca46e' ), prev_index=1, ) out1 = proto_types.TxOutputType( address='15Jvu3nZNP7u2ipw2533Q9VVgEu2Lu9F2B', amount=210000 - 100000 - 10000, script_type=proto_types.PAYTOADDRESS, ) out2 = proto_types.TxOutputType( address_n=[3], # 1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5 amount=100000, script_type=proto_types.PAYTOADDRESS, ) with self.client: self.client.set_expected_responses([ proto.ButtonRequest( code=proto_types.ButtonRequest_ConfirmOutput), # proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), # don't confirm change proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXFINISHED) ]) serialized_tx = self.client.simple_sign_tx('Bitcoin', [inp1, inp2], [out1, out2]) # Accepted by network: tx c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb self.assertEqual( binascii.hexlify(serialized_tx), '01000000021c032e5715d1da8115a2fe4f57699e15742fe113b0d2d1ca3b594649d322bec6010000006b483045022100f773c403b2f85a5c1d6c9c4ad69c43de66930fff4b1bc818eb257af98305546a0220443bde4be439f276a6ce793664b463580e210ec6c9255d68354449ac0443c76501210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff6ea42cd8d9c8e5441c4c5f85bfe50311078730d2881494f11f4d2257777a4958010000006b48304502210090cff1c1911e771605358a8cddd5ae94c7b60cc96e50275908d9bf9d6367c79f02202bfa72e10260a146abd59d0526e1335bacfbb2b4401780e9e3a7441b0480c8da0121038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e3ffffffff02a0860100000000001976a9142f4490d5263906e4887ca2996b9e207af3e7824088aca0860100000000001976a914812c13d97f9159e54e326b481b8f88a73df8507a88ac00000000' )
def test_testnet_fee_too_high(self): self.setup_mnemonic_nopin_nopassphrase() # tx: 6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54 # input 1: 10.00000000 BTC inp1 = proto_types.TxInputType(address_n=[0], # mirio8q3gtv7fhdnmb3TpZ4EuafdzSs7zL # amount=1000000000, prev_hash=binascii.unhexlify('6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54'), prev_index=1, ) out1 = proto_types.TxOutputType(address='mfiGQVPcRcaEvQPYDErR34DcCovtxYvUUV', amount=1000000000 - 500000000 - 100000000, script_type=proto_types.PAYTOADDRESS, ) out2 = proto_types.TxOutputType(address_n=[2], amount=500000000, script_type=proto_types.PAYTOADDRESS, ) with self.client: self.client.set_tx_api(tx_api.TxApiTestnet) 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("6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.ButtonRequest(code=proto_types.ButtonRequest_FeeOverThreshold), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, ], [out1, out2], None, True) self.assertEqual(binascii.hexlify(serialized_tx), '0100000001549d2977998f899a63c0a9da30dedb2841e33fef561097b05822eccbc7f3906f010000006a47304402205ea68e9d52d4be14420ccecf7f2e11489d49b86bedb79ee99b5e9b7188884150022056219cb3384a5df8048cca286a9533403dbda1571afd84b51379cdaee6a6dea80121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff020084d717000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac0065cd1d000000001976a9142db345c36563122e2fd0f5485fb7ea9bbf7cb5a288ac00000000')
def test_nonzero_opreturn(self): self.setup_mnemonic_nopin_nopassphrase() # tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882 # input 0: 0.0039 BTC inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e # amount=390000, prev_hash=binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'), prev_index=0, ) out1 = proto_types.TxOutputType(address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1', amount=390000 - 10000 - 10000, script_type=proto_types.PAYTOADDRESS, ) out1 = proto_types.TxOutputType(op_return_data=b'test of the op_return data', amount=10000, script_type=proto_types.PAYTOOPRETURN, ) with self.client: 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("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.Failure() ]) self.assertRaises(CallException, self.client.sign_tx, 'Bitcoin', [inp1, ], [out1, ])
def test_testnet_one_two_fee(self): self.setup_mnemonic_nopin_nopassphrase() # tx: 6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54 # input 1: 10.00000000 BTC inp1 = proto_types.TxInputType(address_n=[0], # mirio8q3gtv7fhdnmb3TpZ4EuafdzSs7zL # amount=1000000000, prev_hash=binascii.unhexlify('6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54'), prev_index=1, ) out1 = proto_types.TxOutputType(address='mfiGQVPcRcaEvQPYDErR34DcCovtxYvUUV', amount=1000000000 - 500000000 - 10000000, script_type=proto_types.PAYTOADDRESS, ) out2 = proto_types.TxOutputType(address_n=[2], amount=500000000, script_type=proto_types.PAYTOADDRESS, ) with self.client: self.client.set_tx_api(tx_api.TxApiTestnet) 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("6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, ], [out1, out2], None, True) self.assertEqual(binascii.hexlify(serialized_tx), '0100000001549d2977998f899a63c0a9da30dedb2841e33fef561097b05822eccbc7f3906f010000006b4830450221009c2d30385519fdb13dce13d5ac038be07d7b2dad0b0f7b2c1c339d7255bcf553022056a2f5bceab3cd0ffed4d388387e631f419d67ff9ce7798e3d7dfe6a6d6ec4bd0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0280ce341d000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac0065cd1d000000001976a9142db345c36563122e2fd0f5485fb7ea9bbf7cb5a288ac00000000')
def test_one_two_fee(self): self.setup_mnemonic_nopin_nopassphrase() # tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882 # input 0: 0.0039 BTC inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e # amount=390000, prev_hash=binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'), prev_index=0, ) out1 = proto_types.TxOutputType(address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1', amount=390000 - 80000 - 10000, script_type=proto_types.PAYTOADDRESS, ) out2 = proto_types.TxOutputType(address_n=[1], amount=80000, script_type=proto_types.PAYTOADDRESS, ) with self.client: 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("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2], None, True) self.assertEqual(binascii.hexlify(serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b483045022100c1400d8485d3bdcae7413e123148f35ece84806fc387ab88c66b469df89aef1702201d481d04216b319dc549ffe2333143629ba18828a4e2d1783ab719a6aa263eb70121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff02e0930400000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac80380100000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac00000000')
def test_one_three_fee(self): self.setup_mnemonic_nopin_nopassphrase() # tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882 # input 0: 0.0039 BTC inp1 = proto_types.TxInputType( address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e # amount=390000, prev_hash=binascii.unhexlify( 'd5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882' ), prev_index=0, ) out1 = proto_types.TxOutputType( address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1', amount=390000 - 80000 - 12000 - 10000, script_type=proto_types.PAYTOADDRESS, ) out2 = proto_types.TxOutputType( address='13uaUYn6XAooo88QvAqAVsiVvr2mAXutqP', amount=12000, script_type=proto_types.PAYTOADDRESS, ) out3 = proto_types.TxOutputType( address_n=[1], amount=80000, script_type=proto_types.PAYTOADDRESS, ) with self.client: self.client.set_expected_responses([ proto.ButtonRequest( code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest( code=proto_types.ButtonRequest_ConfirmOutput), # proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), # don't confirm change proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXFINISHED) ]) serialized_tx = self.client.simple_sign_tx('Bitcoin', [ inp1, ], [out1, out2, out3]) self.assertEqual( binascii.hexlify(serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b483045022100e695e2c530c7c0fc32e6b79b7cff56a7f70a8c9da787534f46b4204070f914fc02207b0879a81408a11e23b11d4c7965c62b5fc6d5c2d92340f5ee2da7b40e99314a0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0300650400000000001976a914de9b2a8da088824e8fe51debea566617d851537888ace02e0000000000001976a9141fe1d337fb81afca42818051e12fd18245d1b17288ac80380100000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac00000000' )
def test_fee_too_high(self): self.setup_mnemonic_nopin_nopassphrase() # tx: 1570416eb4302cf52979afd5e6909e37d8fdd874301f7cc87e547e509cb1caa6 # input 0: 1.0 BTC inp1 = proto_types.TxInputType(address_n=[0], # 1HWDaLTpTCTtRWyWqZkzWx1wex5NKyncLW # amount=100000000, prev_hash=TXHASH_157041, prev_index=0, ) out1 = proto_types.TxOutputType(address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1', amount=100000000 - 510000, script_type=proto_types.PAYTOADDRESS, ) with self.client: 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=TXHASH_157041)), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_157041)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_157041)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_157041)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest(code=proto_types.ButtonRequest_FeeOverThreshold), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ]) self.assertEqual(binascii.hexlify(serialized_tx), b'0100000001a6cab19c507e547ec87c1f3074d8fdd8379e90e6d5af7929f52c30b46e417015000000006b483045022100dc3531da7feb261575f03b5b9bbb35edc7f73bb081c92538827105de4102737002200161e34395f6a8ee93979200cb974fa75ccef6d7c14021511cf468eece90d6450121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff01d018ee05000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000')
def test_send_mixedmode_change(self): self.setup_mnemonic_allallall() self.client.set_tx_api(TxApiTestnet) inp1 = proto_types.TxInputType( address_n=parse_path("49'/1'/0'/1/0"), # 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX amount=123456789, prev_hash=unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'), prev_index=0, script_type=proto_types.SPENDP2SHWITNESS, ) out1 = proto_types.TxOutputType( address='mhRx1CeVfaayqRwq5zgRQmD7W5aWBfD5mC', amount=12300000, script_type=proto_types.PAYTOADDRESS, ) out2 = proto_types.TxOutputType( address_n=parse_path("49'/1'/0'/1/0"), script_type=proto_types.PAYTOADDRESS, amount=123456789 - 11000 - 12300000, ) with self.client: 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.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmTransferToAccount), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2]) self.assertEqual(hexlify(serialized_tx), b'0100000000010137c361fb8f2d9056ba8c98c5611930fcb48cacfdd0fe2e0449d83eea982f91200000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff02e0aebb00000000001976a91414fdede0ddc3be652a0ce1afbc1b509a55b6b94888ac3df39f06000000001976a914d16b8c0680c61fc6ed2e407455715055e41052f588ac024730440220256d513a7c3a265a673d68028f6d6ba816db58e9337c90ad320b39074ce8ea0202203beca720ee6ea268a29576adcaab2bc41b6622bc79f722e74e081a238564169f012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000')
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 amount=12300000, prev_hash=unhexlify('4f2f857f39ed1afe05542d058fb0be865a387446e32fc876d086203f483f61d1'), prev_index=0, sequence=0xfffffffe, script_type=proto_types.SPENDWITNESS, ) out1 = proto_types.TxOutputType( address='2N4Q5FhU2497BryFfUgbqkAJE87aKDv3V3e', amount=5000000, script_type=proto_types.PAYTOADDRESS, ) out2 = proto_types.TxOutputType( address='tgrs1qejqxwzfld7zr6mf7ygqy5s5se5xq7vmt9lkd57', script_type=proto_types.PAYTOADDRESS, amount=12300000 - 11000 - 5000000, ) with self.client: 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.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('GRS Testnet', [inp1], [out1, out2], lock_time=650713) self.assertEquals(hexlify(serialized_tx), b'01000000000101d1613f483f2086d076c82fe34674385a86beb08f052d5405fe1aed397f852f4f0000000000feffffff02404b4c000000000017a9147a55d61848e77ca266e79a39bfc85c580a6426c987a8386f0000000000160014cc8067093f6f843d6d3e22004a4290cd0c0f336b02483045022100ea8780bc1e60e14e945a80654a41748bbf1aa7d6f2e40a88d91dfc2de1f34bd10220181a474a3420444bd188501d8d270736e1e9fe379da9970de992ff445b0972e3012103adc58245cf28406af0ef5cc24b8afba7f1be6c72f279b642d85c48798685f862d9ed0900')
def test_send_p2sh(self): self.setup_mnemonic_allallall() self.client.set_tx_api(TxApiGroestlcoinTestnet) inp1 = proto_types.TxInputType( address_n=parse_path("49'/1'/0'/1/0"), # 2N1LGaGg836mqSQqiuUBLfcyGBhyZYBtBZ7 amount=123456789, prev_hash=unhexlify('09a48bce2f9d5c6e4f0cb9ea1b32d0891855e8acfe5334f9ebd72b9ad2de60cf'), prev_index=0, sequence=0xfffffffe, script_type=proto_types.SPENDP2SHWITNESS, ) out1 = proto_types.TxOutputType( address='mvbu1Gdy8SUjTenqerxUaZyYjmvedc787y', amount=12300000, script_type=proto_types.PAYTOADDRESS, ) out2 = proto_types.TxOutputType( address='2N1LGaGg836mqSQqiuUBLfcyGBhyZYBtBZ7', script_type=proto_types.PAYTOADDRESS, amount=123456789 - 11000 - 12300000, ) with self.client: 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.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('GRS Testnet', [inp1], [out1, out2], lock_time=650756) self.assertEquals(hexlify(serialized_tx), b'01000000000101cf60ded29a2bd7ebf93453feace8551889d0321beab90c4f6e5c9d2fce8ba4090000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5feffffff02e0aebb00000000001976a914a579388225827d9f2fe9014add644487808c695d88ac3df39f060000000017a91458b53ea7f832e8f096e896b8713a8c6df0e892ca8702483045022100b7ce2972bcbc3a661fe320ba901e680913b2753fcb47055c9c6ba632fc4acf81022001c3cfd6c2fe92eb60f5176ce0f43707114dd7223da19c56f2df89c13c2fef80012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7904ee0900')
def test_btc_address_type_error_2(self): self.setup_mnemonic_nopin_nopassphrase() # tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882 # input 0: 0.0039 BTC inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e # amount=390000, prev_hash=binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'), prev_index=0, ) # Spend Output address out1 = proto_types.TxOutputType(address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1', amount=390000 - 80000 - 12000 - 10000, script_type=proto_types.PAYTOADDRESS, address_type=0, ) # Transfer Output address out2 = proto_types.TxOutputType(address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz2', amount=390000 - 10000, script_type=proto_types.PAYTOADDRESS, address_type=2, ) with self.client: 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("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), ]) try: self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2]) except CallException as e: self.assertEqual(e.args[0], proto_types.Failure_Other) else: self.assert_(False, "types.Invalid Address Type expected")
def test_xfer_change_fee(self): self.setup_mnemonic_nopin_nopassphrase() # tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882 # input 0: 0.0039 BTC inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e # amount=390000, prev_hash=binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'), prev_index=0, ) # Transfer Output address out1 = proto_types.TxOutputType(address_n=[0x8000002c, 0x80000000, 0x80000000, 0, 0 ], amount=390000 - 10000, script_type=proto_types.PAYTOADDRESS, address_type=1, ) # Change Output address out2 = proto_types.TxOutputType(address_n=[0x8000002c, 0x80000000, 0x80000000, 1, 1 ], amount=8000, script_type=proto_types.PAYTOADDRESS, address_type=2, ) with self.client: 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("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmTransferToAccount), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2]) self.assertEqual(binascii.hexlify(serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006a473044022029270ff6991d953cb89135dc43723a64f5be00a69db42efeb845f2918dec50c302201f6589bb44c9c4b6c8152966d5de9b56c2a6ca61172d0f63c6c62e48ad8975130121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0260cc0500000000001976a9149c9d21f47382762df3ad81391ee0964b28dd951788ac401f0000000000001976a914db302d9f1dd36faa220d8dfd7ff18ff5e308a53688ac00000000')
def test_opreturn_nonascii(self): self.setup_mnemonic_nopin_nopassphrase() # tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882 # input 0: 0.0039 BTC inp1 = proto_types.TxInputType( address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e # amount=390000, prev_hash=binascii.unhexlify( 'd5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882' ), prev_index=0, ) out1 = proto_types.TxOutputType( address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1', amount=390000 - 10000, script_type=proto_types.PAYTOADDRESS, ) out2 = proto_types.TxOutputType( op_return_data='\x00\x01\x02\x03\x04I Declare A Thumb War', amount=0, script_type=proto_types.PAYTOOPRETURN, ) with self.client: 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( "d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882" ))), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType( request_index=0, tx_hash=binascii.unhexlify( "d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882" ))), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType( request_index=1, tx_hash=binascii.unhexlify( "d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=0, tx_hash=binascii.unhexlify( "d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest( code=proto_types.ButtonRequest_ConfirmOutput), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.ButtonRequest( code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [ inp1, ], [out1, out2]) self.assertEqual( binascii.hexlify(serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006a47304402200814759f6406ca6106a110f1b453834164f729297ecf03602703c87d9fd2350102203c6917d586928a930ba7a7a9925453bc8bd195d8446348ba09e8f496300304a50121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0260cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000000000001c6a1a000102030449204465636c6172652041205468756d622057617200000000' )
def test_opreturn(self): self.setup_mnemonic_nopin_nopassphrase() # tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882 # input 0: 0.0039 BTC inp1 = proto_types.TxInputType( address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e # amount=390000, prev_hash=binascii.unhexlify( 'd5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882' ), prev_index=0, ) out1 = proto_types.TxOutputType( address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1', amount=390000 - 10000, script_type=proto_types.PAYTOADDRESS, ) out2 = proto_types.TxOutputType( op_return_data='test of the op_return data', amount=0, script_type=proto_types.PAYTOOPRETURN, ) with self.client: 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( "d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882" ))), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType( request_index=0, tx_hash=binascii.unhexlify( "d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882" ))), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType( request_index=1, tx_hash=binascii.unhexlify( "d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=0, tx_hash=binascii.unhexlify( "d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest( code=proto_types.ButtonRequest_ConfirmOutput), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.ButtonRequest( code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [ inp1, ], [out1, out2]) self.assertEqual( binascii.hexlify(serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006a4730440220187b7b9c340a32fc8445418ad11fb3827d2e8bac7d730e1c9ad800353e7ba62f02206c0c5820ba8882c82923a39aee8d36d6d32e13daed73f7a3d6199de5f8e7ddfd0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0260cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000000000001c6a1a74657374206f6620746865206f705f72657475726e206461746100000000' )
def test_xfer_multi_account(self): self.setup_mnemonic_nopin_nopassphrase() # tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882 # input 0: 0.0039 BTC inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e # amount=390000, prev_hash=binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'), prev_index=0, ) # Transfer Output address1 out1 = proto_types.TxOutputType(address_n=[0x8000002c, 0x80000000, 0x80000001, 0, 0 ], amount= 10000, script_type=proto_types.PAYTOADDRESS, address_type=1, ) # Transfer Output address2 out2 = proto_types.TxOutputType(address_n=[0x8000002c, 0x80000000, 0x80000002, 0, 0 ], amount= 10000, script_type=proto_types.PAYTOADDRESS, address_type=1, ) # Transfer Output address3 out3 = proto_types.TxOutputType(address_n=[0x8000002c, 0x80000000, 0x80000003, 0, 0 ], amount= 390000 - 20000 - 90000, #280000 script_type=proto_types.PAYTOADDRESS, address_type=1, ) # Change Output address out4 = proto_types.TxOutputType(address_n=[0x8000002c, 0x80000000, 0x80000000, 1, 1 ], amount=80000, script_type=proto_types.PAYTOADDRESS, address_type=2, ) with self.client: 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("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmTransferToAccount), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmTransferToAccount), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=2)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmTransferToAccount), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=3)), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=2)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=3)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=2)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=3)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2, out3, out4]) self.assertEqual(binascii.hexlify(serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006a473044022001e609489d66ab9a96e26b23125e372e68990fe995a4026bbb0a2ee53dcf008b0220545ddfec0b6fd186623d793158437cdfcead11b6464507db533ca6a3f9c64a340121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0410270000000000001976a914c5c94a31b13d1223520fa92f1e0a127dbfd82ed188ac10270000000000001976a9140d9d0435f01563c6f01b7c9a404590c21f4e2d0188acc0450400000000001976a914e68990fa670c2910e8eaec96c2db2568ec132c2288ac80380100000000001976a914db302d9f1dd36faa220d8dfd7ff18ff5e308a53688ac00000000')
def test_btc_to_ltc_exchange(self): self.setup_mnemonic_nopin_nopassphrase() self.client.apply_policy('ShapeShift', 1) # tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882 # input 0: 0.0039 BTC inp1 = proto_types.TxInputType( address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e # amount=390000, prev_hash=binascii.unhexlify( 'd5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882' ), prev_index=0, ) signed_exchange_out1 = proto_exchange.SignedExchangeResponse( responseV2=proto_exchange.ExchangeResponseV2( withdrawal_amount=binascii.unhexlify('03cfd863'), withdrawal_address=proto_exchange.ExchangeAddress( coin_type='ltc', address='LhvxkkwMCjDAwyprNHhYW8PE9oNf6wSd2V'), deposit_amount=binascii.unhexlify('0493e0'), #300000 deposit_address=proto_exchange.ExchangeAddress( coin_type='btc', address='1EtCKS5SxoPeNnzrAjFpuNruBmq8EHvqdt'), return_address=proto_exchange.ExchangeAddress( coin_type='btc', address='15jYdch7oghoPFDBQz8XDerbL382aT4U9e'), expiration=1480964590181, quoted_rate=binascii.unhexlify('04f89e60b8'), api_key=binascii.unhexlify( '6ad5831b778484bb849da45180ac35047848e5cac0fa666454f4ff78b8c7399fea6a8ce2c7ee6287bcd78db6610ca3f538d6b3e90ca80c8e6368b6021445950b' ), miner_fee=binascii.unhexlify('0186a0'), #100000 order_id=binascii.unhexlify( 'b026bddb3e74470bbab9146c4db58019'), ), signature=binascii.unhexlify( '1fd1f3bdb3ebd7b82956d5422352fa1a10d27b361f65b2293436a5c5059c3c9f1e4eb30632cce2511d0c892cdbe0cb28347a5d8d800eba1248fc71aa5b6379da5a' )) exchange_type_out1 = proto_types.ExchangeType( signed_exchange_response=signed_exchange_out1, withdrawal_coin_name='Litecoin', withdrawal_address_n=[2147483692, 2147483650, 2147483649, 0, 1], return_address_n=[2147483692, 2147483648, 2147483648, 0, 4]) # Exhange Output address out1 = proto_types.TxOutputType( amount=300000, address='1EtCKS5SxoPeNnzrAjFpuNruBmq8EHvqdt', script_type=proto_types.PAYTOADDRESS, address_type=3, exchange_type=exchange_type_out1, ) with self.client: self.client.set_tx_api(tx_api.TxApiBitcoin) 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( "d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882" ))), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType( request_index=0, tx_hash=binascii.unhexlify( "d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882" ))), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType( request_index=1, tx_hash=binascii.unhexlify( "d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=0, tx_hash=binascii.unhexlify( "d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest( code=proto_types.ButtonRequest_SignExchange), proto.ButtonRequest( code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest( code=proto_types.ButtonRequest_FeeOverThreshold), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) self.client.sign_tx('Bitcoin', [ inp1, ], [ out1, ]) #reset policy ("ShapeShift") self.client.apply_policy('ShapeShift', 0)
def test_ltc_to_eth_exchange(self): self.setup_mnemonic_nopin_nopassphrase() self.client.apply_policy('ShapeShift', 1) # tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882 # input 0: 0.0039 BTC inp1 = proto_types.TxInputType( address_n=[0], # 175AmUerJ2wxKmyMTWdTbeoFh3o4a5dmDJ # amount=2276970000000, ($22769.70) prev_hash=binascii.unhexlify( '4a405a771b1c16af9059e01aa1de19ae1e143da6a5a8d130d1591875a93f9e0c' ), prev_index=0, ) signed_exchange_out1 = proto_exchange.SignedExchangeResponse( responseV2=proto_exchange.ExchangeResponseV2( withdrawal_amount=binascii.unhexlify('01d23650d8380800'), withdrawal_address=proto_exchange.ExchangeAddress( coin_type='eth', address='0x3f2329c9adfbccd9a84f52c906e936a42da18cb8'), deposit_amount=binascii.unhexlify('01ccec55'), deposit_address=proto_exchange.ExchangeAddress( coin_type='ltc', address='LfbEZX7Q88zDxXJ8meuc8YKJTDCFeW51F3'), return_address=proto_exchange.ExchangeAddress( coin_type='ltc', address='LQgMuyB7VMKB4NrEv5YwcBfbbwXgwH2uFD'), expiration=1481074750525, quoted_rate=binascii.unhexlify('067d0007d7b2f400'), api_key=binascii.unhexlify( '6ad5831b778484bb849da45180ac35047848e5cac0fa666454f4ff78b8c7399fea6a8ce2c7ee6287bcd78db6610ca3f538d6b3e90ca80c8e6368b6021445950b' ), miner_fee=binascii.unhexlify('2386f26fc10000'), order_id=binascii.unhexlify( 'b168e4ff7d634e35b2bba38ed2ba3098'), ), signature=binascii.unhexlify( '20b6a7c44f261906eba11ffae4a160f8ff98a8806ff9b2e233734aaa8f673ca0e401103c60660a57cf778a9078fa8b8cd586af5a94cd8284ffd9e285507b8e6bb9' )) exchange_type_out1 = proto_types.ExchangeType( signed_exchange_response=signed_exchange_out1, withdrawal_coin_name='Ethereum', withdrawal_address_n=[2147483692, 2147483708, 2147483648, 0, 0], return_address_n=[2147483692, 2147483650, 2147483649, 0, 2]) # Exhange Output address out1 = proto_types.TxOutputType( amount=30207061, address='LfbEZX7Q88zDxXJ8meuc8YKJTDCFeW51F3', script_type=proto_types.PAYTOADDRESS, address_type=3, exchange_type=exchange_type_out1, ) with self.client: self.client.set_tx_api(tx_api.TxApiBitcoin) 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( "4a405a771b1c16af9059e01aa1de19ae1e143da6a5a8d130d1591875a93f9e0c" ))), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType( request_index=0, tx_hash=binascii.unhexlify( "4a405a771b1c16af9059e01aa1de19ae1e143da6a5a8d130d1591875a93f9e0c" ))), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType( request_index=1, tx_hash=binascii.unhexlify( "4a405a771b1c16af9059e01aa1de19ae1e143da6a5a8d130d1591875a93f9e0c" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=0, tx_hash=binascii.unhexlify( "4a405a771b1c16af9059e01aa1de19ae1e143da6a5a8d130d1591875a93f9e0c" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=1, tx_hash=binascii.unhexlify( "4a405a771b1c16af9059e01aa1de19ae1e143da6a5a8d130d1591875a93f9e0c" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=2, tx_hash=binascii.unhexlify( "4a405a771b1c16af9059e01aa1de19ae1e143da6a5a8d130d1591875a93f9e0c" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=3, tx_hash=binascii.unhexlify( "4a405a771b1c16af9059e01aa1de19ae1e143da6a5a8d130d1591875a93f9e0c" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=4, tx_hash=binascii.unhexlify( "4a405a771b1c16af9059e01aa1de19ae1e143da6a5a8d130d1591875a93f9e0c" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=5, tx_hash=binascii.unhexlify( "4a405a771b1c16af9059e01aa1de19ae1e143da6a5a8d130d1591875a93f9e0c" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=6, tx_hash=binascii.unhexlify( "4a405a771b1c16af9059e01aa1de19ae1e143da6a5a8d130d1591875a93f9e0c" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=7, tx_hash=binascii.unhexlify( "4a405a771b1c16af9059e01aa1de19ae1e143da6a5a8d130d1591875a93f9e0c" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=8, tx_hash=binascii.unhexlify( "4a405a771b1c16af9059e01aa1de19ae1e143da6a5a8d130d1591875a93f9e0c" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest( code=proto_types.ButtonRequest_SignExchange), proto.ButtonRequest( code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest( code=proto_types.ButtonRequest_FeeOverThreshold), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) self.client.sign_tx('Litecoin', [ inp1, ], [ out1, ]) #reset policy ("ShapeShift") self.client.apply_policy('ShapeShift', 0)
def test_shieldedIn_one_one_fee_2(self): self.setup_mnemonic_allallall() # tx: c6eddfbedd5821baea352b79fbd0d793a55257111c46a79002844b86a1c872e1 # input 0: 19.9973 TAZ inp1 = proto_types.TxInputType( address_n=[2147483692, 2147483649, 2147483648, 0, 0], # t1YxYiYy8Hjq5HBN7sioDtTs98SX2SzW5q8 #amount=1999730000 TAZ prev_hash=binascii.unhexlify( b'c6eddfbedd5821baea352b79fbd0d793a55257111c46a79002844b86a1c872e1' ), prev_index=0, ) out1 = proto_types.TxOutputType( address='tmJ1xYxP8XNTtCoDgvdmQPSrxh5qZJgy65Z', amount=1997300000 - 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"c6eddfbedd5821baea352b79fbd0d793a55257111c46a79002844b86a1c872e1" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=0, tx_hash=binascii.unhexlify( b"c6eddfbedd5821baea352b79fbd0d793a55257111c46a79002844b86a1c872e1" ))), proto.TxRequest( request_type=proto_types.TXEXTRADATA, details=proto_types. TxRequestDetailsType(tx_hash=binascii.unhexlify( b"c6eddfbedd5821baea352b79fbd0d793a55257111c46a79002844b86a1c872e1" ), extra_data_offset=0, extra_data_len=1024)), proto.TxRequest( request_type=proto_types.TXEXTRADATA, details=proto_types. TxRequestDetailsType(tx_hash=binascii.unhexlify( b"c6eddfbedd5821baea352b79fbd0d793a55257111c46a79002844b86a1c872e1" ), extra_data_offset=1024, extra_data_len=875)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest( code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Zcash Testnet', [ inp1, ], [ out1, ]) self.assertEqual( binascii.hexlify(serialized_tx), b'0100000001e172c8a1864b840290a7461c115752a593d7d0fb792b35eaba2158ddbedfedc6000000006a473044022077f249005ac0d72936bf927d8b6b2a78b83749c31f35b7f86b6cd95852065a0c022027613dc308bc6230730f0f786071f93ab3080f10041f191f379baa47b14e42bf0121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0ffffffff018c590c77000000001976a9145b157a678a10021243307e4bb58f36375aa80e1088ac00000000' )
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" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest( code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Zcash Testnet', [ inp1, ], [ out1, ]) self.assertEqual( binascii.hexlify(serialized_tx), b'01000000015773e57046079432f2e5b4b5907b1082b1e202a5535b4f8cb0f868a7c58fa108000000006b483045022100cb92f4253705272142f8684489249cfdbb66d84a47872fca66597eb835474484022049916cb566bd431372be959e4239c80f72181922b0c5443c89d21aec27342c4a0121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0ffffffff013301993b000000001976a9145b157a678a10021243307e4bb58f36375aa80e1088ac00000000' )
def test_shieldedIn_one_one_fee_1(self): self.setup_mnemonic_allallall() # tx: 43d133a5bb5d1764368726707584c4eb1faf2a696a832325a7608d6b5e72aeca # input 0: 19.99740373 TAZ inp1 = proto_types.TxInputType( address_n=[2147483692, 2147483649, 2147483648, 0, 0], # tmJ1xYxP8XNTtCoDgvdmQPSrxh5qZJgy65Z # amount=1999740373, prev_hash=binascii.unhexlify( b'43d133a5bb5d1764368726707584c4eb1faf2a696a832325a7608d6b5e72aeca' ), prev_index=0, ) out1 = proto_types.TxOutputType( address='tmJ1xYxP8XNTtCoDgvdmQPSrxh5qZJgy65Z', amount=1999740373 - 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"43d133a5bb5d1764368726707584c4eb1faf2a696a832325a7608d6b5e72aeca" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=0, tx_hash=binascii.unhexlify( b"43d133a5bb5d1764368726707584c4eb1faf2a696a832325a7608d6b5e72aeca" ))), proto.TxRequest( request_type=proto_types.TXEXTRADATA, details=proto_types. TxRequestDetailsType(tx_hash=binascii.unhexlify( b"43d133a5bb5d1764368726707584c4eb1faf2a696a832325a7608d6b5e72aeca" ), extra_data_offset=0, extra_data_len=1024)), proto.TxRequest( request_type=proto_types.TXEXTRADATA, details=proto_types. TxRequestDetailsType(tx_hash=binascii.unhexlify( b"43d133a5bb5d1764368726707584c4eb1faf2a696a832325a7608d6b5e72aeca" ), extra_data_offset=1024, extra_data_len=875)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest( code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Zcash Testnet', [ inp1, ], [ out1, ]) self.assertEqual( binascii.hexlify(serialized_tx), b'0100000001caae725e6b8d60a72523836a692aaf1febc484757026873664175dbba533d143000000006b483045022100e3118845371537bcdcbe9071327769aea86704b0574adcd808673d53bdd1a18f022070903ffa067b3ae02613f4652d2a8101a946c2c87157ff08272ae50e25d91cbe0121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0ffffffff0141963177000000001976a9145b157a678a10021243307e4bb58f36375aa80e1088ac00000000' )
def test_transparent_one_one_fee_too_high(self): self.setup_mnemonic_allallall() # tx: c8ff96d72e80c01792146d8f0970cbc970882fb315ab1ae043342b4d455e6b56 # input 0: 10.0 TAZ inp1 = proto_types.TxInputType( address_n=[2147483692, 2147483649, 2147483648, 0, 0], # t1YxYiYy8Hjq5HBN7sioDtTs98SX2SzW5q8 # amount=1000000000, prev_hash=binascii.unhexlify( b'c8ff96d72e80c01792146d8f0970cbc970882fb315ab1ae043342b4d455e6b56' ), prev_index=0, ) out1 = proto_types.TxOutputType( address='tmJ1xYxP8XNTtCoDgvdmQPSrxh5qZJgy65Z', amount=100000000 - 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"c8ff96d72e80c01792146d8f0970cbc970882fb315ab1ae043342b4d455e6b56" ))), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType( request_index=0, tx_hash=binascii.unhexlify( b"c8ff96d72e80c01792146d8f0970cbc970882fb315ab1ae043342b4d455e6b56" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=0, tx_hash=binascii.unhexlify( b"c8ff96d72e80c01792146d8f0970cbc970882fb315ab1ae043342b4d455e6b56" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=1, tx_hash=binascii.unhexlify( b"c8ff96d72e80c01792146d8f0970cbc970882fb315ab1ae043342b4d455e6b56" ))), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest( code=proto_types.ButtonRequest_ConfirmOutput), proto.ButtonRequest( code=proto_types.ButtonRequest_FeeOverThreshold), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Zcash Testnet', [ inp1, ], [ out1, ]) self.assertEqual( binascii.hexlify(serialized_tx), b'0100000001566b5e454d2b3443e01aab15b32f8870c9cb70098f6d149217c0802ed796ffc8000000006a4730440220226750799c61f8914df7cf8a7623bbcde3197e0eb83dac9905c2ff5f4a29c41a02203215a36c14ddbf82d57dc69476f7a08b6a4f2349960ae01a5a489b974f262a110121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0ffffffff016cd9f505000000001976a9145b157a678a10021243307e4bb58f36375aa80e1088ac00000000' )
def _responses(self, inp1, inp2, change=0): resp = [ 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=inp1.prev_hash)), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType( request_index=0, tx_hash=inp1.prev_hash)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=0, tx_hash=inp1.prev_hash)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=1, tx_hash=inp1.prev_hash)), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType( tx_hash=inp2.prev_hash)), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType( request_index=0, tx_hash=inp2.prev_hash)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=0, tx_hash=inp2.prev_hash)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType( request_index=1, tx_hash=inp2.prev_hash)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), ] if change != 1: resp.append( proto.ButtonRequest( code=proto_types.ButtonRequest_ConfirmOutput)) resp.append( proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1))) if change != 2: resp.append( proto.ButtonRequest( code=proto_types.ButtonRequest_ConfirmOutput)) resp += [ proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest( request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXFINISHED), ] return resp
def test_one_three_fee(self): self.setup_mnemonic_nopin_nopassphrase() # tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882 # input 0: 0.0039 BTC inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e # amount=390000, prev_hash=binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'), prev_index=0, ) # Spend Output address out1 = proto_types.TxOutputType(address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1', amount=390000 - 80000 - 12000 - 10000, script_type=proto_types.PAYTOADDRESS, address_type=0, ) # Transfer Output address out2 = proto_types.TxOutputType(address_n=[0x8000002c, 0x80000000, 0x80000000, 0, 0 ], amount=10000, script_type=proto_types.PAYTOADDRESS, address_type=1, ) # Change Output address out3 = proto_types.TxOutputType(address_n=[0x8000002c, 0x80000000, 0x80000000, 1, 1 ], amount=80000, script_type=proto_types.PAYTOADDRESS, address_type=2, ) with self.client: 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("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmTransferToAccount), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=2)), proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx), proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=2)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=2)), proto.TxRequest(request_type=proto_types.TXFINISHED), ]) (signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2, out3]) self.assertEqual(binascii.hexlify(serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b483045022100c3ceed2bd2365ccdb978d605e9ae6347790b978e2747bbbec623364270be723c022017680d050c2bf0dae4bd249d83b43bc93a33661c1a0b18c7e8a05eb47815f9aa0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0300650400000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac10270000000000001976a9149c9d21f47382762df3ad81391ee0964b28dd951788ac80380100000000001976a914db302d9f1dd36faa220d8dfd7ff18ff5e308a53688ac00000000')