Fixed unit tests (also for Python 3)
Removed old unit tests for non-implemented functions (SimpleSignTx, Ecies).pull/1/head
parent
eac9c99e32
commit
d5daf1d2f0
@ -1,134 +0,0 @@
|
|||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import unittest
|
|
||||||
import common
|
|
||||||
import binascii
|
|
||||||
import base64
|
|
||||||
|
|
||||||
from trezorlib.client import CallException
|
|
||||||
|
|
||||||
# as described here: http://memwallet.info/btcmssgs.html
|
|
||||||
|
|
||||||
def test_ecies_backforth(cls, test_string):
|
|
||||||
cls.setup_mnemonic_nopin_nopassphrase()
|
|
||||||
|
|
||||||
pubkey = binascii.unhexlify('0338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6')
|
|
||||||
|
|
||||||
# encrypt without signature
|
|
||||||
enc = cls.client.encrypt_message(pubkey, test_string, display_only=False, coin_name='Bitcoin', n=[])
|
|
||||||
print('base64:', base64.b64encode(enc.nonce + enc.message + enc.hmac))
|
|
||||||
dec = cls.client.decrypt_message([1], enc.nonce, enc.message, enc.hmac)
|
|
||||||
cls.assertEqual(dec.message, test_string)
|
|
||||||
cls.assertEqual(dec.address, '')
|
|
||||||
|
|
||||||
# encrypt with signature
|
|
||||||
enc = cls.client.encrypt_message(pubkey, test_string, display_only=False, coin_name='Bitcoin', n=[5])
|
|
||||||
print('base64:', base64.b64encode(enc.nonce + enc.message + enc.hmac))
|
|
||||||
dec = cls.client.decrypt_message([1], enc.nonce, enc.message, enc.hmac)
|
|
||||||
cls.assertEqual(dec.message, test_string)
|
|
||||||
cls.assertEqual(dec.address, '1Csf6LVPkv24FBs6bpj4ELPszE6mGf6jeV')
|
|
||||||
|
|
||||||
# encrypt without signature, show only on display
|
|
||||||
enc = cls.client.encrypt_message(pubkey, test_string, display_only=True, coin_name='Bitcoin', n=[])
|
|
||||||
dec = cls.client.decrypt_message([1], enc.nonce, enc.message, enc.hmac)
|
|
||||||
cls.assertEqual(dec.message, '')
|
|
||||||
cls.assertEqual(dec.address, '')
|
|
||||||
|
|
||||||
# encrypt with signature, show only on display
|
|
||||||
enc = cls.client.encrypt_message(pubkey, test_string, display_only=True, coin_name='Bitcoin', n=[5])
|
|
||||||
dec = cls.client.decrypt_message([1], enc.nonce, enc.message, enc.hmac)
|
|
||||||
cls.assertEqual(dec.message, '')
|
|
||||||
cls.assertEqual(dec.address, '')
|
|
||||||
|
|
||||||
class TestEcies(common.TrezorTest):
|
|
||||||
|
|
||||||
# index: m/1
|
|
||||||
# address: 1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb
|
|
||||||
# pubkey: 0338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6
|
|
||||||
# privkey: L5X3rf5hJfRt9ZjQzFopvSBGkpnSotn4jKGLL6ECJxcuT2JgGh65
|
|
||||||
|
|
||||||
# index: m/5
|
|
||||||
# address: 1Csf6LVPkv24FBs6bpj4ELPszE6mGf6jeV
|
|
||||||
# pubkey: 0234716c01c2dd03fa7ee302705e2b8fbd1311895d94b1dca15e62eedea9b0968f
|
|
||||||
# privkey: L4uKPRgaZqL9iGmge3UBSLGTQC7gDFrLRhC1vM4LmGyrzNUBb1Zs
|
|
||||||
|
|
||||||
def test_ecies_backforth_short(self):
|
|
||||||
test_ecies_backforth(self, 'testing message!')
|
|
||||||
|
|
||||||
def test_ecies_backforth_long(self):
|
|
||||||
test_ecies_backforth(self, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin elementum libero in tortor condimentum malesuada. Quisque gravida semper sapien, ut ultrices dolor pharetra nec. Nulla hendrerit metus imperdiet, feugiat sapien eu, fermentum mauris. Suspendisse nec bibendum urna. Vivamus augue libero, mollis vel augue at, venenatis vestibulum nunc. Curabitur condimentum quam non nibh volutpat, at congue libero rutrum. Morbi at sollicitudin lectus. Donec commodo rutrum sollicitudin. Vivamus condimentum massa id ligula iaculis, et aliquet orci condimentum. Nullam non ex sit amet nisi porta suscipit.')
|
|
||||||
|
|
||||||
def test_ecies_crosscheck(self):
|
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
|
||||||
|
|
||||||
# decrypt message without signature
|
|
||||||
payload = 'AhA1yCZStrmtuGSgliJ7K02eD8xWRoyRU1ryPu9kBloODFv9hATpqukL0YSzISfrQGygYVai5OirxU0='
|
|
||||||
payload = base64.b64decode(payload)
|
|
||||||
nonce, msg, hmac = payload[:33], payload[33:-8], payload[-8:]
|
|
||||||
dec = self.client.decrypt_message([1], nonce, msg, hmac)
|
|
||||||
self.assertEqual(dec.message, 'testing message!')
|
|
||||||
self.assertEqual(dec.address, '')
|
|
||||||
|
|
||||||
# decrypt message without signature (same message, different nonce)
|
|
||||||
payload = 'A9ragu6UTXisBWw6bTCcM/SeR7fmlQp6Qzg9mpJ5qKBv9BIgWX/v/u+OhdlKLZTx6C0Xooz5aIvWrqw='
|
|
||||||
payload = base64.b64decode(payload)
|
|
||||||
nonce, msg, hmac = payload[:33], payload[33:-8], payload[-8:]
|
|
||||||
dec = self.client.decrypt_message([1], nonce, msg, hmac)
|
|
||||||
self.assertEqual(dec.message, 'testing message!')
|
|
||||||
self.assertEqual(dec.address, '')
|
|
||||||
|
|
||||||
# decrypt message with signature
|
|
||||||
payload = 'A90Awe+vrQvmzFvm0hh8Ver7jcBbqiCxV4RGU9knKf6F3vvG1N45Q3kc+N1sd4inzXZnW/5KH74CXaCPGAKr/a0n4BUhADVfS2Ic9Luwcs6/cuYHSzJKKLSPUYC6N4hu1K0q1vR/02BJ+iZ0pfvChoGDmpOOO7NaIEoyiKAnZFNsHr6Ffplg3YVGJAAG7GgfSQ=='
|
|
||||||
payload = base64.b64decode(payload)
|
|
||||||
nonce, msg, hmac = payload[:33], payload[33:-8], payload[-8:]
|
|
||||||
dec = self.client.decrypt_message([1], nonce, msg, hmac)
|
|
||||||
self.assertEqual(dec.message, 'testing message!')
|
|
||||||
self.assertEqual(dec.address, '1Csf6LVPkv24FBs6bpj4ELPszE6mGf6jeV')
|
|
||||||
|
|
||||||
# decrypt message with signature (same message, different nonce)
|
|
||||||
payload = 'AyeglkkBSc3VLNrXETiNtiS+t2nIKeEVGMVfF7KlVM+plBuX3yc+2kf+Yo6L1NKoqEjSlRXn71OTOEWfB2zmtasIX9dQBfyGluEivbeUfqbwneepEzv9/i0XI3ywfSa2HSdic8B68nZ3D6Mms4qOpzk6AEPt/yI7fl8aUsN0lxT8nVBfMmmg10oydvH/86cWYA=='
|
|
||||||
payload = base64.b64decode(payload)
|
|
||||||
nonce, msg, hmac = payload[:33], payload[33:-8], payload[-8:]
|
|
||||||
dec = self.client.decrypt_message([1], nonce, msg, hmac)
|
|
||||||
self.assertEqual(dec.message, 'testing message!')
|
|
||||||
self.assertEqual(dec.address, '1Csf6LVPkv24FBs6bpj4ELPszE6mGf6jeV')
|
|
||||||
|
|
||||||
def test_ecies_crosscheck_long(self):
|
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
|
||||||
|
|
||||||
lipsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin elementum libero in tortor condimentum malesuada. Quisque gravida semper sapien, ut ultrices dolor pharetra nec. Nulla hendrerit metus imperdiet, feugiat sapien eu, fermentum mauris. Suspendisse nec bibendum urna. Vivamus augue libero, mollis vel augue at, venenatis vestibulum nunc. Curabitur condimentum quam non nibh volutpat, at congue libero rutrum. Morbi at sollicitudin lectus. Donec commodo rutrum sollicitudin. Vivamus condimentum massa id ligula iaculis, et aliquet orci condimentum. Nullam non ex sit amet nisi porta suscipit.'
|
|
||||||
|
|
||||||
# decrypt message without signature
|
|
||||||
payload = 'AhnOXSv+7mI3Tvw0ekCxvEoMvophrWOGAwLT2IpyxaCd+zgftijj2uQoGtSktFwch8oABstTqwBjokH4AllH7PaL/8dWwOELwEVIXlbktf8nktUITBkJ0Abih8Imq451Bwrt8ZMt0tzoDBWeRLtZGHPduHnykGjq1O3A8Qjd4k8W+PkPBum+rNKlPOUqoNpSvOcPD9L6APkMByPKMmTq5K9nSeLKyXjOtWcx4BLRqRe9qgvG+SWFHsJ/90O76XZIB6GXDqGnCNR5rV/8Ho4bfagRL/tQPbeQ4iYWAyqdRlKuwnUrrZSJCdrsQJt1Ye5LcltE0YhJBKRmxob2/P+ziyceZk6cU3hS9k4B1GKlEeGxipvMswfbrEIy/5NYiGXEDwC3dHwM3g1Opz5oXbEKZ3NG/eEh5UxJFjfyx1qumQeSaIo5XFOf81A4dhH1vAT8MMEQN7bXXwCb1fxDC9wblCP9iVR1aey5FUFMNE7wfXYdrMxwzxrgJfSa8/vQgMmZI205OCBxAsmBYOTIy6kqcRn7+Ad6WEYvp2DRwcGN//9XFJi2DuJzA0ymeoSxnZg4GDytpvVFVyQvIDkPHrmVfaZot02XCCqTq/ZDgZLnnutWfP9dB1ckSpzXOM/pEgMBj6DcC1HbgHZaKhoNjsk8ITTYMnP5kFBoZdtPbNJB5rZOYtLHHDxfvk2d3USTxtbPiIE9w6JbBll18lKFMN8gvQuKcHyKwVNQGOVuBGtXv4hCBFF/VNRJ5GE8BX1ajHwldFiuTII9dcdSrZhL+Ds8Ui0siZ5Ai+KHjKZi8FciNQ+8q3tXUOiN1hONCN6iy5XjFd2I7NAqg+o4TnkGKSPMQSE3z2vY'
|
|
||||||
payload = base64.b64decode(payload)
|
|
||||||
nonce, msg, hmac = payload[:33], payload[33:-8], payload[-8:]
|
|
||||||
dec = self.client.decrypt_message([1], nonce, msg, hmac)
|
|
||||||
self.assertEqual(dec.message, lipsum)
|
|
||||||
self.assertEqual(dec.address, '')
|
|
||||||
|
|
||||||
# decrypt message without signature (same message, different nonce)
|
|
||||||
payload = 'A2bVIKzpPVYJlPP6WMiwhpabJfJAHH927StDsUyRL2h3xc/aMPVN6rYA9GwcsPSDiZpPZdjCVYM4uDwFQ/kBNA1p5XlDs6IBGtGGgbR7P5wHgJaxcw1zWZ+TsWTIWVj3psy0CFg7zCfqeV2y0OzIvJc/p+ONdVb1f9TmTICPoVGJ9AVXdnfdqdIn+wLYScUklTp10ldfUCmt5iAsJJR1p+h+xa+wwUdyCxpvnxOZDxA0EFmxQskBhcDbLL2nmQkLm5RnLQgpefMCEJrdz5g9htC5y65eod2SFBV8oJrN1ryh4PdRn5+JyVcwWhQeCHTK3m6vOIwwht5lm2uCLpcEttDoxo5k3LcBPE4rlPVYCf8qja6sRKq/WYiLdwXnooX/qmmLQ7Lo2DBs4hB6VQGgPSSTH/3/rUb11bL2Ieyq73ZICeIbHCIvjFqhd/atkNvQTnCrNmFybyxdMqE/4Yrv7b//hJVkgI21AVGcSYF+Kp9pZ6XJVunDTS4XX7tjkXTFu7qbIv6q7mGgXV2/7udR9GF/lG/Us+wYsU1wmCEaUJ5Mx1yr4eLJ8cp6XPCMivEwKJ6CeHz2d/FYEeHE3YTy3VQT/+BJ5nS2+wDTD57wW9ZxUXn0cqPUhH0XveeRDOKEz1tgu6ChPrSyuu9E+pxDA2OA95NRt5j+UMdhZf6R0qgwfuDOcTs+0EuF9pQ5znPnmg4JqF6AkLlwE6txm1YTTjID8689yY4UsEc7CYJb1N3JvNxIHety5B5KWWAgnK1l9g9xnuKdGC4M7F+ajrbRqbw0qfTUvruD7GaYoqsyrdtDkEpEDXhZ0p56LALTUhL4+QVmeXvkH8cmBqdB6flZ48mlTgfy'
|
|
||||||
payload = base64.b64decode(payload)
|
|
||||||
nonce, msg, hmac = payload[:33], payload[33:-8], payload[-8:]
|
|
||||||
dec = self.client.decrypt_message([1], nonce, msg, hmac)
|
|
||||||
self.assertEqual(dec.message, lipsum)
|
|
||||||
self.assertEqual(dec.address, '')
|
|
||||||
|
|
||||||
# decrypt message with signature
|
|
||||||
payload = 'ArJoHqnmLY22QiCePXk9yNQSK6g8BMGLkKkj72p35hCW1gxVajIZyptgbBp4A0LV8Fshe6MKnHO5PGw2BPQ6yTES5Q+7c8ZjC4m8JCKOOU8l7et4AcftPElxBdKimEv5B5egQmzSYds6dfB73VsWi2k9J/1RpckB2WDvXSrF1915XA4tMTMefB/DhzdrG9gkVTBqaROTgxlXWJhqdFag4aghVcXS5Ru6CQH0cLoxmZWf8mx/pK4liXyH1Gm+7fl8cd9iDkNTJEapzn/Ohh7JYxJrV/i4p0xE9L5CONL+UIL8DtGB8SgAWtd5cHdpLhMywRFxjDvho20nE3VyGREhqiv9i3ywXRox/zd6OFBkxSA3kuWNRrkDRBx4Q+2j49V5iQquuu5horUuRRYN1HVvoOYjVkfEJV70yvVg3xR2MeJouUa1aP7WF9JPo8vor252/ZU6L15mveE0JZH1HtoierC1Q5YDSFCYJ4hWJbWZEMwXvRBQL+FoZ5x6CSkrfTOYoP+uD/VnsMepI+0NgsssacU9h2PdDVy3pYnB0m04YpOftVnAARaun+nE9ti1FUFfnwSmD2vB2TfWEkFGQ3S6W6sjpX/gN+It6GViiNQO6yT9e3HO/4+JiS5yldOI7ryAlzNM598RANDdpI3kBy9IWKD5dENy/82TD/DAWoeRAz/LvvZaQBtpxZNEkRqqgbpBT7aJzjZudVMzZHPduF67eC994WB0EJHbKncXElbBVKXKMyoPruw9wwFP7VfeAAp4SLAmcs6YFkJ8lOeYO0bnPhvlrYV9XAkSpsHxBtita3WuyeoBHugHYEPzbNOdCoLRUgCS+4esrVV9aE1irlBzTmU+t8cWX5BQGsqnEuBKqPri7XWLrg57Up4ILkPFojgw/fIIkUNVCY2iqgFQCQZPM8dbE0wKK5ujd5YQwp8i/OrsXccin/TRjKXLtIkiEVg/Gl7aCRuXzGR0pfc='
|
|
||||||
payload = base64.b64decode(payload)
|
|
||||||
nonce, msg, hmac = payload[:33], payload[33:-8], payload[-8:]
|
|
||||||
dec = self.client.decrypt_message([1], nonce, msg, hmac)
|
|
||||||
self.assertEqual(dec.message, lipsum)
|
|
||||||
self.assertEqual(dec.address, '1Csf6LVPkv24FBs6bpj4ELPszE6mGf6jeV')
|
|
||||||
|
|
||||||
# decrypt message with signature (same message, different nonce)
|
|
||||||
payload = 'AjFarEh66x2DZ9S3T/n8/xnYZQRwnuugxCDfIIEDPKkdfgwYPjGhtg3k/9ryj42MDgmey71ZvDhUdj+igcBKaPiKAS7p88kQxl6R6sFkL/wKwTdXPboA/n63BnHrtNNDIp12Dlgn2m0nSCLOchlh2maIBqB68qIqy21tT10ZrMpTfPd+4MI4NOzs42BQJAOLy19rMTKoCXGWIsgEERG0qCm38onYVUmj5UvtQIdDLIZ/ta4WD+FqM3Y9pJsU648qV72l/xM27BjIxVqUsw6MHLrAUNTmmd+D7dPAIjL66Gr5hEHCTcHP8oCIkeC+MK2JVcHN12F1Rx+8iwNf4nsixUcZJ/RX9JOTxJj3CdxuTH3b0lDNdFwQQddYhHd6cv4t1cZ3wOWAVh1g+gmB/igmvJD200EfhQudHp/w+9BIFFfxFwAmf4/tlidJ0knIaPjNx5kBSkklhxWdBfen5kgkGFtcQdBkguADcV/bfAxCRpqVa9lgN4ja2na0fUMZaAnVjR+sk4MWTbSObw5FBos3B7awAgRxQx6L8p3PUwGc2B9oVf1zcw3c0mlVUpaVEc7tXipVX6LAtKF9jx+EeMHvWlUic7s4vaGa7VxNuU8Of65Ba3RmxAX9zxwTKHMBAhm2efaqBIxGUSO8ncDSdp2nO6tJUkUoyNK0nasXWF2Ras22We0Ma0yGv0MQRVWeksYQn116I7ahv+lvAzaJnhiYGCM36Vg051VZEmBh23U5HdqrLRT7w8u1DJZyCxo0KmiZ5c3sOiJPxcC/8hpnQ0Zc7ipEdi97hZG2X2HOtmEIFivF2yI26rieEDyebbg95CnhUFx1LEuiEApU8fVAuYoyEQGVVwQPEQlBrqkF4oE/cItesBqxIdoZlsvoYBvxa1huT6jsc/Uci1WRpwKmPxeHUkxZrwLG8+kUNGFn13s8HrPTncaCQU3fnu3KOKkfLdnpVnF3JfYlrruMWV4='
|
|
||||||
payload = base64.b64decode(payload)
|
|
||||||
nonce, msg, hmac = payload[:33], payload[33:-8], payload[-8:]
|
|
||||||
dec = self.client.decrypt_message([1], nonce, msg, hmac)
|
|
||||||
self.assertEqual(dec.message, lipsum)
|
|
||||||
self.assertEqual(dec.address, '1Csf6LVPkv24FBs6bpj4ELPszE6mGf6jeV')
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
@ -1,360 +0,0 @@
|
|||||||
# tx 4a7b7e0403ae5607e473949cfa03f09f2cd8b0f404bf99ce10b7303d86280bf7
|
|
||||||
# 100 UTXO for spending for unittests
|
|
||||||
|
|
||||||
import unittest
|
|
||||||
import common
|
|
||||||
import binascii
|
|
||||||
|
|
||||||
import trezorlib.messages_pb2 as proto
|
|
||||||
import trezorlib.types_pb2 as proto_types
|
|
||||||
from trezorlib.client import CallException
|
|
||||||
from trezorlib.tx_api import TXAPITestnet
|
|
||||||
|
|
||||||
class TestMsgSimplesigntx(common.TrezorTest):
|
|
||||||
|
|
||||||
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.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED)])
|
|
||||||
serialized_tx = self.client.simple_sign_tx('Bitcoin', [inp1, ], [out1, ])
|
|
||||||
|
|
||||||
# Accepted by network: tx fd79435246dee76b2f159d2db08032d666c95adc544de64c8c49f474df4a7fee
|
|
||||||
self.assertEqual(binascii.hexlify(serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b4830450221009a0b7be0d4ed3146ee262b42202841834698bb3ee39c24e7437df208b8b7077102202b79ab1e7736219387dffe8d615bbdba87e11477104b867ef47afed1a5ede7810121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0160cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000')
|
|
||||||
|
|
||||||
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(TXAPITestnet())
|
|
||||||
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('Testnet', [inp1, ], [out1, out2])
|
|
||||||
|
|
||||||
self.assertEqual(binascii.hexlify(serialized_tx), '0100000001549d2977998f899a63c0a9da30dedb2841e33fef561097b05822eccbc7f3906f010000006b4830450221009c2d30385519fdb13dce13d5ac038be07d7b2dad0b0f7b2c1c339d7255bcf553022056a2f5bceab3cd0ffed4d388387e631f419d67ff9ce7798e3d7dfe6a6d6ec4bd0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0280ce341d000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac0065cd1d000000001976a9142db345c36563122e2fd0f5485fb7ea9bbf7cb5a288ac00000000')
|
|
||||||
|
|
||||||
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(TXAPITestnet())
|
|
||||||
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_FeeOverThreshold),
|
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED)])
|
|
||||||
serialized_tx = self.client.simple_sign_tx('Testnet', [inp1, ], [out1, out2])
|
|
||||||
|
|
||||||
self.assertEqual(binascii.hexlify(serialized_tx), '0100000001549d2977998f899a63c0a9da30dedb2841e33fef561097b05822eccbc7f3906f010000006a47304402205ea68e9d52d4be14420ccecf7f2e11489d49b86bedb79ee99b5e9b7188884150022056219cb3384a5df8048cca286a9533403dbda1571afd84b51379cdaee6a6dea80121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff020084d717000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac0065cd1d000000001976a9142db345c36563122e2fd0f5485fb7ea9bbf7cb5a288ac00000000')
|
|
||||||
|
|
||||||
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.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])
|
|
||||||
|
|
||||||
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_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_255_outputs(self):
|
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
|
||||||
|
|
||||||
# Tests if device implements serialization of len(outputs) correctly
|
|
||||||
|
|
||||||
# tx: c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb
|
|
||||||
# index 1: 0.0010 BTC
|
|
||||||
# tx: 39a29e954977662ab3879c66fb251ef753e0912223a83d1dcb009111d28265e5
|
|
||||||
# index 1: 0.0254 BTC
|
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(address_n=[3], # 1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5
|
|
||||||
# amount=100000,
|
|
||||||
prev_hash=binascii.unhexlify('c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb'),
|
|
||||||
prev_index=1,
|
|
||||||
)
|
|
||||||
|
|
||||||
inp2 = proto_types.TxInputType(address_n=[3], # 1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5
|
|
||||||
# amount=2540000,
|
|
||||||
prev_hash=binascii.unhexlify('39a29e954977662ab3879c66fb251ef753e0912223a83d1dcb009111d28265e5'),
|
|
||||||
prev_index=1,
|
|
||||||
)
|
|
||||||
|
|
||||||
outputs = []
|
|
||||||
for _ in range(255):
|
|
||||||
out = proto_types.TxOutputType(address='1NwN6UduuVkJi6sw3gSiKZaCY5rHgVXC2h',
|
|
||||||
amount=10200,
|
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
|
||||||
)
|
|
||||||
outputs.append(out)
|
|
||||||
|
|
||||||
with self.client:
|
|
||||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), ] * 255 + \
|
|
||||||
[proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED)])
|
|
||||||
serialized_tx = self.client.simple_sign_tx('Bitcoin', [inp1, inp2], outputs)
|
|
||||||
|
|
||||||
self.assertEqual(binascii.hexlify(serialized_tx), '0100000002fb792f470a58993e14964c9bd46cdf37cb4bbc3f61540cb651580c82ed243ec6010000006b483045022100969da46f94a81f34f3717b014e0c3e1826eda1b0022ec2f9ce39f3d750ab9235022026da269770993211a1503413566a339bbb4389a482fffcf8e1f76713fc3b94f5012103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a7902ffffffffe56582d2119100cb1d3da8232291e053f71e25fb669c87b32a667749959ea239010000006a473044022052e1419bb237b9db400ab5e3df16db6355619d545fde9030924a360763ae9ad40220704beab04d72ecaeb42eca7d98faca7a0941e65f2e1341f183be2b83e6b09e1c012103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a7902fffffffffdff00' + 'd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088ac' * 255 + '00000000')
|
|
||||||
|
|
||||||
'''
|
|
||||||
|
|
||||||
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.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.TXFINISHED)])
|
|
||||||
serialized_tx = self.client.simple_sign_tx('Bitcoin', [inp1, ], [out1, ])
|
|
||||||
|
|
||||||
self.assertEqual(binascii.hexlify(serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b483045022100a3b17b37de3bfecca47f0d49f7bb0d0f68d45df7defe45713d57e83731f5e3d902205404b14630cea6a88b23a5f7c3a1b88494757a8ca5e1c0b0b93cf3c38231c3bd0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff01e0220200000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000')
|
|
||||||
|
|
||||||
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.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
|
||||||
proto.Failure(code=proto_types.Failure_NotEnoughFunds)])
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.client.simple_sign_tx('Bitcoin', [inp1, ], [out1, ])
|
|
||||||
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.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED)])
|
|
||||||
serialized_tx = self.client.simple_sign_tx('Bitcoin', [inp1, ], [out1, ])
|
|
||||||
|
|
||||||
# Accepted by network: tx 8cc1f4adf7224ce855cf535a5104594a0004cb3b640d6714fdb00b9128832dd5
|
|
||||||
self.assertEqual(binascii.hexlify(serialized_tx), '0100000001a3fb2d38322c3b327e54005cebc0686d52fcdf536e53bb5ef481a7de8056aa54010000006b4830450221009e020b0390ccad533b73b552f8a99a9d827212c558e4f755503674d07c92ad4502202d606f7316990e0461c51d4add25054f19c697aa3e3c2ced4d568f0b2c57e62f0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0170f305000000000017a9147f844bdb0b8fd54b64e3d16c85dc1170f1ff97c18700000000')
|
|
||||||
|
|
||||||
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(TXAPITestnet())
|
|
||||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED)])
|
|
||||||
serialized_tx = self.client.simple_sign_tx('Testnet', [inp1, ], [out1, ])
|
|
||||||
|
|
||||||
# Accepted by network: tx
|
|
||||||
self.assertEqual(binascii.hexlify(serialized_tx), '010000000136825bfdb78c8ede226c7c4f25a018e99a2c061d63c7fb425fca7c7d6721dad6000000006a473044022047845c366eb24f40be315c7815a154513c444c7989eb80f7ce7ff6aeb703d26a022007c1f5efadf67c5889634fd7ac39a7ce78bffac291673e8772ecd8389c901d9f01210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff01c6100795000000001976a9143d2496e67f5f57a924353da42d4725b318e7a8ea88ac00000000')
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
Loading…
Reference in New Issue