mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 22:38:08 +00:00
Fixed unit tests (also for Python 3)
Removed old unit tests for non-implemented functions (SimpleSignTx, Ecies).
This commit is contained in:
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()
|
@ -65,7 +65,7 @@ class TestMsgApplysettings(common.TrezorTest):
|
||||
def test_apply_homescreen(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
|
||||
img = '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"\x00\x00\x00\x00\x04\x80\x00\x00\x00\x00\x00\x00\x00\x00\x04\x88\x02\x00\x00\x00\x02\x91\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x90@\x00\x11@\x00\x00\x00\x00\x00\x00\x08\x00\x10\x92\x12\x04\x00\x00\x05\x12D\x00\x00\x00\x00\x00 \x00\x00\x08\x00Q\x00\x00\x02\xc0\x00\x00\x00\x00\x00\x00\x00\x10\x02 \x01\x04J\x00)$\x00\x00\x00\x00\x80\x00\x00\x00\x00\x08\x10\xa1\x00\x00\x02\x81 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\tP\x00\x00\x00\x00\x00\x00 \x00\x00\xa0\x00\xa0R \x12\x84\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x08\x00\tP\x00\x00\x00\x00 \x00\x04 \x00\x80\x02\x00@\x02T\xc2 \x00\x00\x00\x00\x00\x00\x00\x10@\x00)\t@\n\xa0\x80\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x80@\x14\xa9H\x04\x00\x00\x88@\x00\x00\x00\x00\x00\x02\x02$\x00\x15B@\x00\nP\x00\x00\x00\x00\x00\x80\x00\x00\x91\x01UP\x00\x00 \x02\x00\x00\x00\x00\x00\x00\x02\x08@ Z\xa5 \x00\x00\x80\x00\x00\x00\x00\x00\x00\x08\xa1%\x14*\xa0\x00\x00\x02\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xaa\x91 \x00\x05E\x80\x00\x00\x00\x00\x00\x02*T\x05-D\x00\x00\x05 @\x00\x00\x00\x00\x00%@\x80\x11V\xa0\x88\x00\x05@\xb0\x00\x00\x00\x00\x00\x818$\x04\xabD \x00\x06\xa1T\x00\x00\x00\x00\x02\x03\xb8\x01R\xd5\x01\x00\x00\x05AP\x00\x00\x00\x00\x08\xadT\x00\x05j\xa4@\x00\x87ah\x00\x00\x00\x00\x02\x8d\xb8\x08\x00.\x01\x00\x00\x02\xa5\xa8\x10\x00\x00\x00*\xc1\xec \n\xaa\x88 \x02@\xf6\xd0\x02\x00\x00\x00\x0bB\xb6\x14@U"\x80\x00\x01{`\x00\x00\x00\x00M\xa3\xf8 \x15*\x00\x00\x00\x10n\xc0\x04\x00\x00\x02\x06\xc2\xa8)\x00\x96\x84\x80\x00\x00\x1b\x00\x00\x80@\x10\x87\xa7\xf0\x84\x10\xaa\x10\x00\x00D\x00\x00\x02 \x00\x8a\x06\xfa\xe0P\n-\x02@\x00\x12\x00\x00\x00\x00\x10@\x83\xdf\xa0\x00\x08\xaa@\x00\x00\x01H\x00\x05H\x04\x12\x01\xf7\x81P\x02T\t\x00\x00\x00 \x00\x00\x84\x10\x00\x00z\x00@)* \x00\x00\x01\n\xa0\x02 \x05\n\x00\x00\x05\x10\x84\xa8\x84\x80\x00\x00@\x14\x00\x92\x10\x80\x00\x04\x11@\tT\x00\x00\x00\x00\n@\x00\x08\x84@$\x00H\x00\x12Q\x02\x00\x00\x00\x00\x90\x02A\x12\xa8\n\xaa\x92\x10\x04\xa8\x10@\x00\x00\x04\x04\x00\x04I\x00\x04\x14H\x80"R\x01\x00\x00\x00!@\x00\x00$\xa0EB\x80\x08\x95hH\x00\x00\x00\x84\x10 \x05Z\x00\x00(\x00\x02\x00\xa1\x01\x00\x00\x04\x00@\x82\x00\xadH*\x92P\x00\xaaP\x00\x00\x00\x00\x11\x02\x01*\xad\x01\x00\x01\x01"\x11D\x08\x00\x00\x10\x80 \x00\x81W\x80J\x94\x04\x08\xa5 !\x00\x00\x00\x02\x00B*\xae\xa1\x00\x80\x10\x01\x08\xa4\x00\x00\x00\x00\x00\x84\x00\t[@"HA\x04E\x00\x84\x00\x00\x00\x10\x00\x01J\xd5\x82\x90\x02\x00!\x02\xa2\x00\x00\x00\x00\x00\x00\x00\x05~\xa0\x00 \x10\n)\x00\x11\x00\x00\x00\x00\x00\x00!U\x80\xa8\x88\x82\x80\x01\x00\x00\x00\x00\x00\x00H@\x11\xaa\xc0\x82\x00 *\n\x00\x00\x00\x00\x00\x00\x00\x00\n\xabb@ \x04\x00! \x84\x00\x00\x00\x00\x02@\xa5\x15A$\x04\x81(\n\x00\x00\x00\x00\x00\x00 \x01\x10\x02\xe0\x91\x02\x00\x00\x04\x00\x00\x00\x00\x00\x00\x01 \xa9\tQH@\x91 P\x00\x00\x00\x00\x00\x00\x08\x00\x00\xa0T\xa5\x00@\x80\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"\x00\x00\x00\x00\xa2\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00 T\xa0\t\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00@\x02\xa0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00*\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x10\x00\x00\x10\x02\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00@\x04\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x08@\x10\x00\x00\x00\x00'
|
||||
img = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"\x00\x00\x00\x00\x04\x80\x00\x00\x00\x00\x00\x00\x00\x00\x04\x88\x02\x00\x00\x00\x02\x91\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x90@\x00\x11@\x00\x00\x00\x00\x00\x00\x08\x00\x10\x92\x12\x04\x00\x00\x05\x12D\x00\x00\x00\x00\x00 \x00\x00\x08\x00Q\x00\x00\x02\xc0\x00\x00\x00\x00\x00\x00\x00\x10\x02 \x01\x04J\x00)$\x00\x00\x00\x00\x80\x00\x00\x00\x00\x08\x10\xa1\x00\x00\x02\x81 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\tP\x00\x00\x00\x00\x00\x00 \x00\x00\xa0\x00\xa0R \x12\x84\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x08\x00\tP\x00\x00\x00\x00 \x00\x04 \x00\x80\x02\x00@\x02T\xc2 \x00\x00\x00\x00\x00\x00\x00\x10@\x00)\t@\n\xa0\x80\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x80@\x14\xa9H\x04\x00\x00\x88@\x00\x00\x00\x00\x00\x02\x02$\x00\x15B@\x00\nP\x00\x00\x00\x00\x00\x80\x00\x00\x91\x01UP\x00\x00 \x02\x00\x00\x00\x00\x00\x00\x02\x08@ Z\xa5 \x00\x00\x80\x00\x00\x00\x00\x00\x00\x08\xa1%\x14*\xa0\x00\x00\x02\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xaa\x91 \x00\x05E\x80\x00\x00\x00\x00\x00\x02*T\x05-D\x00\x00\x05 @\x00\x00\x00\x00\x00%@\x80\x11V\xa0\x88\x00\x05@\xb0\x00\x00\x00\x00\x00\x818$\x04\xabD \x00\x06\xa1T\x00\x00\x00\x00\x02\x03\xb8\x01R\xd5\x01\x00\x00\x05AP\x00\x00\x00\x00\x08\xadT\x00\x05j\xa4@\x00\x87ah\x00\x00\x00\x00\x02\x8d\xb8\x08\x00.\x01\x00\x00\x02\xa5\xa8\x10\x00\x00\x00*\xc1\xec \n\xaa\x88 \x02@\xf6\xd0\x02\x00\x00\x00\x0bB\xb6\x14@U"\x80\x00\x01{`\x00\x00\x00\x00M\xa3\xf8 \x15*\x00\x00\x00\x10n\xc0\x04\x00\x00\x02\x06\xc2\xa8)\x00\x96\x84\x80\x00\x00\x1b\x00\x00\x80@\x10\x87\xa7\xf0\x84\x10\xaa\x10\x00\x00D\x00\x00\x02 \x00\x8a\x06\xfa\xe0P\n-\x02@\x00\x12\x00\x00\x00\x00\x10@\x83\xdf\xa0\x00\x08\xaa@\x00\x00\x01H\x00\x05H\x04\x12\x01\xf7\x81P\x02T\t\x00\x00\x00 \x00\x00\x84\x10\x00\x00z\x00@)* \x00\x00\x01\n\xa0\x02 \x05\n\x00\x00\x05\x10\x84\xa8\x84\x80\x00\x00@\x14\x00\x92\x10\x80\x00\x04\x11@\tT\x00\x00\x00\x00\n@\x00\x08\x84@$\x00H\x00\x12Q\x02\x00\x00\x00\x00\x90\x02A\x12\xa8\n\xaa\x92\x10\x04\xa8\x10@\x00\x00\x04\x04\x00\x04I\x00\x04\x14H\x80"R\x01\x00\x00\x00!@\x00\x00$\xa0EB\x80\x08\x95hH\x00\x00\x00\x84\x10 \x05Z\x00\x00(\x00\x02\x00\xa1\x01\x00\x00\x04\x00@\x82\x00\xadH*\x92P\x00\xaaP\x00\x00\x00\x00\x11\x02\x01*\xad\x01\x00\x01\x01"\x11D\x08\x00\x00\x10\x80 \x00\x81W\x80J\x94\x04\x08\xa5 !\x00\x00\x00\x02\x00B*\xae\xa1\x00\x80\x10\x01\x08\xa4\x00\x00\x00\x00\x00\x84\x00\t[@"HA\x04E\x00\x84\x00\x00\x00\x10\x00\x01J\xd5\x82\x90\x02\x00!\x02\xa2\x00\x00\x00\x00\x00\x00\x00\x05~\xa0\x00 \x10\n)\x00\x11\x00\x00\x00\x00\x00\x00!U\x80\xa8\x88\x82\x80\x01\x00\x00\x00\x00\x00\x00H@\x11\xaa\xc0\x82\x00 *\n\x00\x00\x00\x00\x00\x00\x00\x00\n\xabb@ \x04\x00! \x84\x00\x00\x00\x00\x02@\xa5\x15A$\x04\x81(\n\x00\x00\x00\x00\x00\x00 \x01\x10\x02\xe0\x91\x02\x00\x00\x04\x00\x00\x00\x00\x00\x00\x01 \xa9\tQH@\x91 P\x00\x00\x00\x00\x00\x00\x08\x00\x00\xa0T\xa5\x00@\x80\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"\x00\x00\x00\x00\xa2\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00 T\xa0\t\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00@\x02\xa0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00*\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x10\x00\x00\x10\x02\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00@\x04\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x08@\x10\x00\x00\x00\x00'
|
||||
|
||||
with self.client:
|
||||
self.client.set_expected_responses([proto.ButtonRequest(),
|
||||
|
@ -10,65 +10,65 @@ class TestMsgCipherkeyvalue(common.TrezorTest):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
# different ask values
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], "test", "testing message!", ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(binascii.hexlify(res), '676faf8f13272af601776bc31bc14e8f')
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], b"test", b"testing message!", ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(binascii.hexlify(res), b'676faf8f13272af601776bc31bc14e8f')
|
||||
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], "test", "testing message!", ask_on_encrypt=True, ask_on_decrypt=False)
|
||||
self.assertEqual(binascii.hexlify(res), '5aa0fbcb9d7fa669880745479d80c622')
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], b"test", b"testing message!", ask_on_encrypt=True, ask_on_decrypt=False)
|
||||
self.assertEqual(binascii.hexlify(res), b'5aa0fbcb9d7fa669880745479d80c622')
|
||||
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], "test", "testing message!", ask_on_encrypt=False, ask_on_decrypt=True)
|
||||
self.assertEqual(binascii.hexlify(res), '958d4f63269b61044aaedc900c8d6208')
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], b"test", b"testing message!", ask_on_encrypt=False, ask_on_decrypt=True)
|
||||
self.assertEqual(binascii.hexlify(res), b'958d4f63269b61044aaedc900c8d6208')
|
||||
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], "test", "testing message!", ask_on_encrypt=False, ask_on_decrypt=False)
|
||||
self.assertEqual(binascii.hexlify(res), 'e0cf0eb0425947000eb546cc3994bc6c')
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], b"test", b"testing message!", ask_on_encrypt=False, ask_on_decrypt=False)
|
||||
self.assertEqual(binascii.hexlify(res), b'e0cf0eb0425947000eb546cc3994bc6c')
|
||||
|
||||
# different key
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], "test2", "testing message!", ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(binascii.hexlify(res), 'de247a6aa6be77a134bb3f3f925f13af')
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], b"test2", b"testing message!", ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(binascii.hexlify(res), b'de247a6aa6be77a134bb3f3f925f13af')
|
||||
|
||||
# different message
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], "test", "testing message! it is different", ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(binascii.hexlify(res), '676faf8f13272af601776bc31bc14e8f3ae1c88536bf18f1b44f1e4c2c4a613d')
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], b"test", b"testing message! it is different", ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(binascii.hexlify(res), b'676faf8f13272af601776bc31bc14e8f3ae1c88536bf18f1b44f1e4c2c4a613d')
|
||||
|
||||
# different path
|
||||
res = self.client.encrypt_keyvalue([0, 1, 3], "test", "testing message!", ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(binascii.hexlify(res), 'b4811a9d492f5355a5186ddbfccaae7b')
|
||||
res = self.client.encrypt_keyvalue([0, 1, 3], b"test", b"testing message!", ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(binascii.hexlify(res), b'b4811a9d492f5355a5186ddbfccaae7b')
|
||||
|
||||
def test_decrypt(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
# different ask values
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], "test", binascii.unhexlify("676faf8f13272af601776bc31bc14e8f"), ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(res, 'testing message!')
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test", binascii.unhexlify("676faf8f13272af601776bc31bc14e8f"), ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(res, b'testing message!')
|
||||
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], "test", binascii.unhexlify("5aa0fbcb9d7fa669880745479d80c622"), ask_on_encrypt=True, ask_on_decrypt=False)
|
||||
self.assertEqual(res, 'testing message!')
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test", binascii.unhexlify("5aa0fbcb9d7fa669880745479d80c622"), ask_on_encrypt=True, ask_on_decrypt=False)
|
||||
self.assertEqual(res, b'testing message!')
|
||||
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], "test", binascii.unhexlify("958d4f63269b61044aaedc900c8d6208"), ask_on_encrypt=False, ask_on_decrypt=True)
|
||||
self.assertEqual(res, 'testing message!')
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test", binascii.unhexlify("958d4f63269b61044aaedc900c8d6208"), ask_on_encrypt=False, ask_on_decrypt=True)
|
||||
self.assertEqual(res, b'testing message!')
|
||||
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], "test", binascii.unhexlify("e0cf0eb0425947000eb546cc3994bc6c"), ask_on_encrypt=False, ask_on_decrypt=False)
|
||||
self.assertEqual(res, 'testing message!')
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test", binascii.unhexlify("e0cf0eb0425947000eb546cc3994bc6c"), ask_on_encrypt=False, ask_on_decrypt=False)
|
||||
self.assertEqual(res, b'testing message!')
|
||||
|
||||
# different key
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], "test2", binascii.unhexlify("de247a6aa6be77a134bb3f3f925f13af"), ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(res, 'testing message!')
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test2", binascii.unhexlify("de247a6aa6be77a134bb3f3f925f13af"), ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(res, b'testing message!')
|
||||
|
||||
# different message
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], "test", binascii.unhexlify("676faf8f13272af601776bc31bc14e8f3ae1c88536bf18f1b44f1e4c2c4a613d"), ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(res, 'testing message! it is different')
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test", binascii.unhexlify("676faf8f13272af601776bc31bc14e8f3ae1c88536bf18f1b44f1e4c2c4a613d"), ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(res, b'testing message! it is different')
|
||||
|
||||
# different path
|
||||
res = self.client.decrypt_keyvalue([0, 1, 3], "test", binascii.unhexlify("b4811a9d492f5355a5186ddbfccaae7b"), ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(res, 'testing message!')
|
||||
res = self.client.decrypt_keyvalue([0, 1, 3], b"test", binascii.unhexlify("b4811a9d492f5355a5186ddbfccaae7b"), ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(res, b'testing message!')
|
||||
|
||||
def test_encrypt_badlen(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
self.assertRaises(Exception, self.client.encrypt_keyvalue, [0, 1, 2], "test", "testing")
|
||||
self.assertRaises(Exception, self.client.encrypt_keyvalue, [0, 1, 2], b"test", b"testing")
|
||||
|
||||
def test_decrypt_badlen(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
self.assertRaises(Exception, self.client.decrypt_keyvalue, [0, 1, 2], "test", "testing")
|
||||
self.assertRaises(Exception, self.client.decrypt_keyvalue, [0, 1, 2], b"test", b"testing")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -20,7 +20,7 @@ class TestMsgGetaddress(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=node, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=node, address_n=[2]),
|
||||
proto_types.HDNodePathType(node=node, address_n=[3])],
|
||||
signatures=['', '', ''],
|
||||
signatures=[b'', b'', b''],
|
||||
m=2,
|
||||
)
|
||||
|
||||
@ -38,7 +38,7 @@ class TestMsgGetaddress(common.TrezorTest):
|
||||
|
||||
multisig = proto_types.MultisigRedeemScriptType(
|
||||
pubkeys=pubs,
|
||||
signatures=[''] * 15,
|
||||
signatures=[b''] * 15,
|
||||
m=15,
|
||||
)
|
||||
|
||||
|
@ -15,7 +15,7 @@ def entropy(data):
|
||||
else:
|
||||
counts[c] = 1
|
||||
e = 0
|
||||
for _, v in counts.iteritems():
|
||||
for _, v in counts.items():
|
||||
p = 1.0 * v / len(data)
|
||||
e -= p * math.log(p, 256)
|
||||
return e
|
||||
|
@ -17,8 +17,12 @@ class TestDeviceLoad(common.TrezorTest):
|
||||
passphrase_protection = self.client.debug.read_passphrase_protection()
|
||||
self.assertEqual(passphrase_protection, False)
|
||||
|
||||
address = self.client.get_address('Bitcoin', [])
|
||||
self.assertEqual(address, '1EfKbQupktEMXf4gujJ9kCFo83k1iMqwqK')
|
||||
|
||||
def test_load_device_2(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
self.client.set_passphrase('passphrase')
|
||||
|
||||
mnemonic = self.client.debug.read_mnemonic()
|
||||
self.assertEqual(mnemonic, self.mnemonic12)
|
||||
@ -29,6 +33,9 @@ class TestDeviceLoad(common.TrezorTest):
|
||||
passphrase_protection = self.client.debug.read_passphrase_protection()
|
||||
self.assertEqual(passphrase_protection, True)
|
||||
|
||||
address = self.client.get_address('Bitcoin', [])
|
||||
self.assertEqual(address, '15fiTDFwZd2kauHYYseifGi9daH2wniDHH')
|
||||
|
||||
def test_load_device_3(self):
|
||||
self.client.load_device_by_xprv(xprv='xprv9s21ZrQH143K2JF8RafpqtKiTbsbaxEeUaMnNHsm5o6wCW3z8ySyH4UxFVSfZ8n7ESu7fgir8imbZKLYVBxFPND1pniTZ81vKfd45EHKX73', pin='', passphrase_protection=False, label='test', language='english')
|
||||
|
||||
|
@ -26,7 +26,7 @@ def generate_entropy(strength, internal_entropy, external_entropy):
|
||||
raise Exception("External entropy too short")
|
||||
|
||||
entropy = hashlib.sha256(internal_entropy + external_entropy).digest()
|
||||
entropy_stripped = entropy[:strength / 8]
|
||||
entropy_stripped = entropy[:strength // 8]
|
||||
|
||||
if len(entropy_stripped) * 8 != strength:
|
||||
raise Exception("Entropy length mismatch")
|
||||
@ -36,7 +36,7 @@ def generate_entropy(strength, internal_entropy, external_entropy):
|
||||
class TestDeviceReset(common.TrezorTest):
|
||||
def test_reset_device(self):
|
||||
# No PIN, no passphrase
|
||||
external_entropy = 'zlutoucky kun upel divoke ody' * 2
|
||||
external_entropy = b'zlutoucky kun upel divoke ody' * 2
|
||||
strength = 128
|
||||
|
||||
ret = self.client.call_raw(proto.ResetDevice(display_random=False,
|
||||
@ -56,7 +56,7 @@ class TestDeviceReset(common.TrezorTest):
|
||||
expected_mnemonic = Mnemonic('english').to_mnemonic(entropy)
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(strength/32*3):
|
||||
for _ in range(strength//32*3):
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
mnemonic.append(self.client.debug.read_reset_word())
|
||||
self.client.debug.press_yes()
|
||||
@ -68,7 +68,7 @@ class TestDeviceReset(common.TrezorTest):
|
||||
self.assertEqual(mnemonic, expected_mnemonic)
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(strength/32*3):
|
||||
for _ in range(strength//32*3):
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
mnemonic.append(self.client.debug.read_reset_word())
|
||||
self.client.debug.press_yes()
|
||||
@ -95,7 +95,7 @@ class TestDeviceReset(common.TrezorTest):
|
||||
self.assertIsInstance(resp, proto.Success)
|
||||
|
||||
def test_reset_device_pin(self):
|
||||
external_entropy = 'zlutoucky kun upel divoke ody' * 2
|
||||
external_entropy = b'zlutoucky kun upel divoke ody' * 2
|
||||
strength = 128
|
||||
|
||||
ret = self.client.call_raw(proto.ResetDevice(display_random=True,
|
||||
@ -130,7 +130,7 @@ class TestDeviceReset(common.TrezorTest):
|
||||
expected_mnemonic = Mnemonic('english').to_mnemonic(entropy)
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(strength/32*3):
|
||||
for _ in range(strength//32*3):
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
mnemonic.append(self.client.debug.read_reset_word())
|
||||
self.client.debug.press_yes()
|
||||
@ -142,7 +142,7 @@ class TestDeviceReset(common.TrezorTest):
|
||||
self.assertEqual(mnemonic, expected_mnemonic)
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(strength/32*3):
|
||||
for _ in range(strength//32*3):
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
mnemonic.append(self.client.debug.read_reset_word())
|
||||
self.client.debug.press_yes()
|
||||
@ -171,7 +171,7 @@ class TestDeviceReset(common.TrezorTest):
|
||||
self.client.call_raw(proto.Cancel())
|
||||
|
||||
def test_failed_pin(self):
|
||||
external_entropy = 'zlutoucky kun upel divoke ody' * 2
|
||||
external_entropy = b'zlutoucky kun upel divoke ody' * 2
|
||||
strength = 128
|
||||
|
||||
ret = self.client.call_raw(proto.ResetDevice(display_random=True,
|
||||
|
@ -38,8 +38,8 @@ class TestMsgSignidentity(common.TrezorTest):
|
||||
identity = proto_types.IdentityType(proto='https', user='satoshi', host='bitcoin.org', port='', path='/login', index=0)
|
||||
sig = self.client.sign_identity(identity, hidden, visual)
|
||||
self.assertEqual(sig.address, '17F17smBTX9VTZA9Mj8LM5QGYNZnmziCjL')
|
||||
self.assertEqual(binascii.hexlify(sig.public_key), '023a472219ad3327b07c18273717bb3a40b39b743756bf287fbd5fa9d263237f45')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), '20f2d1a42d08c3a362be49275c3ffeeaa415fc040971985548b9f910812237bb41770bf2c8d488428799fbb7e52c11f1a3404011375e4080e077e0e42ab7a5ba02')
|
||||
self.assertEqual(binascii.hexlify(sig.public_key), b'023a472219ad3327b07c18273717bb3a40b39b743756bf287fbd5fa9d263237f45')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'20f2d1a42d08c3a362be49275c3ffeeaa415fc040971985548b9f910812237bb41770bf2c8d488428799fbb7e52c11f1a3404011375e4080e077e0e42ab7a5ba02')
|
||||
|
||||
# URI : ftp://satoshi@bitcoin.org:2323/pub
|
||||
# hash : 79a6b53831c6ff224fb283587adc4ebae8fb0d734734a46c876838f52dff53f3
|
||||
@ -47,8 +47,8 @@ class TestMsgSignidentity(common.TrezorTest):
|
||||
identity = proto_types.IdentityType(proto='ftp', user='satoshi', host='bitcoin.org', port='2323', path='/pub', index=3)
|
||||
sig = self.client.sign_identity(identity, hidden, visual)
|
||||
self.assertEqual(sig.address, '1KAr6r5qF2kADL8bAaRQBjGKYEGxn9WrbS')
|
||||
self.assertEqual(binascii.hexlify(sig.public_key), '0266cf12d2ba381c5fd797da0d64f59c07a6f1b034ad276cca6bf2729e92b20d9c')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), '20bbd12dc657d534fc0f7e40186e22c447e0866a016f654f380adffa9a84e9faf412a1bb0ae908296537838cf91145e77da08681c63d07b7dca40728b9e6cb17cf')
|
||||
self.assertEqual(binascii.hexlify(sig.public_key), b'0266cf12d2ba381c5fd797da0d64f59c07a6f1b034ad276cca6bf2729e92b20d9c')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'20bbd12dc657d534fc0f7e40186e22c447e0866a016f654f380adffa9a84e9faf412a1bb0ae908296537838cf91145e77da08681c63d07b7dca40728b9e6cb17cf')
|
||||
|
||||
# URI : ssh://satoshi@bitcoin.org
|
||||
# hash : 5fa612f558a1a3b1fb7f010b2ea0a25cb02520a0ffa202ce74a92fc6145da5f3
|
||||
@ -56,8 +56,8 @@ class TestMsgSignidentity(common.TrezorTest):
|
||||
identity = proto_types.IdentityType(proto='ssh', user='satoshi', host='bitcoin.org', port='', path='', index=47)
|
||||
sig = self.client.sign_identity(identity, hidden, visual, ecdsa_curve_name='nist256p1')
|
||||
self.assertEqual(sig.address, '')
|
||||
self.assertEqual(binascii.hexlify(sig.public_key), '0373f21a3da3d0e96fc2189f81dd826658c3d76b2d55bd1da349bc6c3573b13ae4')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), '005122cebabb852cdd32103b602662afa88e54c0c0c1b38d7099c64dcd49efe908288114e66ed2d8c82f23a70b769a4db723173ec53840c08aafb840d3f09a18d3')
|
||||
self.assertEqual(binascii.hexlify(sig.public_key), b'0373f21a3da3d0e96fc2189f81dd826658c3d76b2d55bd1da349bc6c3573b13ae4')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'005122cebabb852cdd32103b602662afa88e54c0c0c1b38d7099c64dcd49efe908288114e66ed2d8c82f23a70b769a4db723173ec53840c08aafb840d3f09a18d3')
|
||||
|
||||
# URI : ssh://satoshi@bitcoin.org
|
||||
# hash : 5fa612f558a1a3b1fb7f010b2ea0a25cb02520a0ffa202ce74a92fc6145da5f3
|
||||
@ -65,8 +65,8 @@ class TestMsgSignidentity(common.TrezorTest):
|
||||
identity = proto_types.IdentityType(proto='ssh', user='satoshi', host='bitcoin.org', port='', path='', index=47)
|
||||
sig = self.client.sign_identity(identity, hidden, visual, ecdsa_curve_name='ed25519')
|
||||
self.assertEqual(sig.address, '')
|
||||
self.assertEqual(binascii.hexlify(sig.public_key), '000fac2a491e0f5b871dc48288a4cae551bac5cb0ed19df0764d6e721ec5fade18')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), '00f05e5085e666429de397c70a081932654369619c0bd2a6579ea6c1ef2af112ef79998d6c862a16b932d44b1ac1b83c8cbcd0fbda228274fde9e0d0ca6e9cb709')
|
||||
self.assertEqual(binascii.hexlify(sig.public_key), b'000fac2a491e0f5b871dc48288a4cae551bac5cb0ed19df0764d6e721ec5fade18')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'00f05e5085e666429de397c70a081932654369619c0bd2a6579ea6c1ef2af112ef79998d6c862a16b932d44b1ac1b83c8cbcd0fbda228274fde9e0d0ca6e9cb709')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -10,22 +10,21 @@ class TestMsgSignmessage(common.TrezorTest):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
sig = self.client.sign_message('Bitcoin', [0], "This is an example of a signed message.")
|
||||
self.assertEqual(sig.address, '14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), '209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
||||
|
||||
def test_sign_testnet(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
sig = self.client.sign_message('Testnet', [0], "This is an example of a signed message.")
|
||||
|
||||
self.assertEqual(sig.address, 'mirio8q3gtv7fhdnmb3TpZ4EuafdzSs7zL')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), '209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
||||
|
||||
def test_sign_long(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
sig = self.client.sign_message('Bitcoin', [0], "VeryLongMessage!" * 64)
|
||||
self.assertEqual(sig.address, '14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), '205ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'205ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed')
|
||||
|
||||
"""
|
||||
def test_sign_utf(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
@ -34,12 +33,11 @@ class TestMsgSignmessage(common.TrezorTest):
|
||||
|
||||
sig_nfkd = self.client.sign_message('Bitcoin', [0], words_nfkd)
|
||||
self.assertEqual(sig_nfkd.address, '14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e')
|
||||
self.assertEqual(binascii.hexlify(sig_nfkd.signature), '1fd0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda4e39588e4ec2b6a22dda4ec4f562f06e91129eea9a844a7193812de82d47c496b')
|
||||
self.assertEqual(binascii.hexlify(sig_nfkd.signature), b'20d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
|
||||
|
||||
sig_nfc = self.client.sign_message('Bitcoin', [0], words_nfc)
|
||||
self.assertEqual(sig_nfc.address, '14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e')
|
||||
self.assertEqual(binascii.hexlify(sig_nfc.signature), '1fd0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda4e39588e4ec2b6a22dda4ec4f562f06e91129eea9a844a7193812de82d47c496b')
|
||||
"""
|
||||
self.assertEqual(binascii.hexlify(sig_nfc.signature), b'20d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -1,7 +1,6 @@
|
||||
import unittest
|
||||
import common
|
||||
import binascii
|
||||
import itertools
|
||||
|
||||
import trezorlib.messages_pb2 as proto
|
||||
import trezorlib.types_pb2 as proto_types
|
||||
@ -17,7 +16,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
|
||||
inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
||||
# amount=390000,
|
||||
prev_hash=binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'),
|
||||
prev_hash=binascii.unhexlify(b'd5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'),
|
||||
prev_index=0,
|
||||
)
|
||||
|
||||
@ -29,10 +28,10 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
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.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=binascii.unhexlify(b"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"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),
|
||||
@ -45,7 +44,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||
|
||||
# Accepted by network: tx fd79435246dee76b2f159d2db08032d666c95adc544de64c8c49f474df4a7fee
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b4830450221009a0b7be0d4ed3146ee262b42202841834698bb3ee39c24e7437df208b8b7077102202b79ab1e7736219387dffe8d615bbdba87e11477104b867ef47afed1a5ede7810121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0160cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b4830450221009a0b7be0d4ed3146ee262b42202841834698bb3ee39c24e7437df208b8b7077102202b79ab1e7736219387dffe8d615bbdba87e11477104b867ef47afed1a5ede7810121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0160cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000')
|
||||
|
||||
def test_testnet_one_two_fee(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -54,7 +53,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
# input 1: 10.00000000 BTC
|
||||
inp1 = proto_types.TxInputType(address_n=[0], # mirio8q3gtv7fhdnmb3TpZ4EuafdzSs7zL
|
||||
# amount=1000000000,
|
||||
prev_hash=binascii.unhexlify('6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54'),
|
||||
prev_hash=binascii.unhexlify(b'6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54'),
|
||||
prev_index=1,
|
||||
)
|
||||
|
||||
@ -72,11 +71,11 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
self.client.set_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.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify("6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify("6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))),
|
||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=binascii.unhexlify(b"6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"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)),
|
||||
@ -90,7 +89,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, ], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '0100000001549d2977998f899a63c0a9da30dedb2841e33fef561097b05822eccbc7f3906f010000006b4830450221009c2d30385519fdb13dce13d5ac038be07d7b2dad0b0f7b2c1c339d7255bcf553022056a2f5bceab3cd0ffed4d388387e631f419d67ff9ce7798e3d7dfe6a6d6ec4bd0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0280ce341d000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac0065cd1d000000001976a9142db345c36563122e2fd0f5485fb7ea9bbf7cb5a288ac00000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000001549d2977998f899a63c0a9da30dedb2841e33fef561097b05822eccbc7f3906f010000006b4830450221009c2d30385519fdb13dce13d5ac038be07d7b2dad0b0f7b2c1c339d7255bcf553022056a2f5bceab3cd0ffed4d388387e631f419d67ff9ce7798e3d7dfe6a6d6ec4bd0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0280ce341d000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac0065cd1d000000001976a9142db345c36563122e2fd0f5485fb7ea9bbf7cb5a288ac00000000')
|
||||
|
||||
def test_testnet_fee_too_high(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -117,11 +116,11 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
self.client.set_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.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify("6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify("6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))),
|
||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=binascii.unhexlify(b"6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"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)),
|
||||
@ -136,7 +135,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, ], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '0100000001549d2977998f899a63c0a9da30dedb2841e33fef561097b05822eccbc7f3906f010000006a47304402205ea68e9d52d4be14420ccecf7f2e11489d49b86bedb79ee99b5e9b7188884150022056219cb3384a5df8048cca286a9533403dbda1571afd84b51379cdaee6a6dea80121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff020084d717000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac0065cd1d000000001976a9142db345c36563122e2fd0f5485fb7ea9bbf7cb5a288ac00000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000001549d2977998f899a63c0a9da30dedb2841e33fef561097b05822eccbc7f3906f010000006a47304402205ea68e9d52d4be14420ccecf7f2e11489d49b86bedb79ee99b5e9b7188884150022056219cb3384a5df8048cca286a9533403dbda1571afd84b51379cdaee6a6dea80121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff020084d717000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac0065cd1d000000001976a9142db345c36563122e2fd0f5485fb7ea9bbf7cb5a288ac00000000')
|
||||
|
||||
def test_one_two_fee(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -163,10 +162,10 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
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.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=binascii.unhexlify(b"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"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)),
|
||||
@ -180,7 +179,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b483045022100c1400d8485d3bdcae7413e123148f35ece84806fc387ab88c66b469df89aef1702201d481d04216b319dc549ffe2333143629ba18828a4e2d1783ab719a6aa263eb70121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff02e0930400000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac80380100000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac00000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b483045022100c1400d8485d3bdcae7413e123148f35ece84806fc387ab88c66b469df89aef1702201d481d04216b319dc549ffe2333143629ba18828a4e2d1783ab719a6aa263eb70121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff02e0930400000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac80380100000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac00000000')
|
||||
|
||||
def test_one_three_fee(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -212,10 +211,10 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
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.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=binascii.unhexlify(b"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"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)),
|
||||
@ -233,7 +232,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2, out3])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b483045022100e695e2c530c7c0fc32e6b79b7cff56a7f70a8c9da787534f46b4204070f914fc02207b0879a81408a11e23b11d4c7965c62b5fc6d5c2d92340f5ee2da7b40e99314a0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0300650400000000001976a914de9b2a8da088824e8fe51debea566617d851537888ace02e0000000000001976a9141fe1d337fb81afca42818051e12fd18245d1b17288ac80380100000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac00000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b483045022100e695e2c530c7c0fc32e6b79b7cff56a7f70a8c9da787534f46b4204070f914fc02207b0879a81408a11e23b11d4c7965c62b5fc6d5c2d92340f5ee2da7b40e99314a0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0300650400000000001976a914de9b2a8da088824e8fe51debea566617d851537888ace02e0000000000001976a9141fe1d337fb81afca42818051e12fd18245d1b17288ac80380100000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac00000000')
|
||||
|
||||
def test_two_two(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -268,16 +267,16 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
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("c6be22d34946593bcad1d2b013e12f74159e69574ffea21581dad115572e031c"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("c6be22d34946593bcad1d2b013e12f74159e69574ffea21581dad115572e031c"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("c6be22d34946593bcad1d2b013e12f74159e69574ffea21581dad115572e031c"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify("c6be22d34946593bcad1d2b013e12f74159e69574ffea21581dad115572e031c"))),
|
||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=binascii.unhexlify(b"c6be22d34946593bcad1d2b013e12f74159e69574ffea21581dad115572e031c"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"c6be22d34946593bcad1d2b013e12f74159e69574ffea21581dad115572e031c"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"c6be22d34946593bcad1d2b013e12f74159e69574ffea21581dad115572e031c"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"c6be22d34946593bcad1d2b013e12f74159e69574ffea21581dad115572e031c"))),
|
||||
|
||||
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=binascii.unhexlify("58497a7757224d1ff1941488d23087071103e5bf855f4c1c44e5c8d9d82ca46e"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("58497a7757224d1ff1941488d23087071103e5bf855f4c1c44e5c8d9d82ca46e"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("58497a7757224d1ff1941488d23087071103e5bf855f4c1c44e5c8d9d82ca46e"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify("58497a7757224d1ff1941488d23087071103e5bf855f4c1c44e5c8d9d82ca46e"))),
|
||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=binascii.unhexlify(b"58497a7757224d1ff1941488d23087071103e5bf855f4c1c44e5c8d9d82ca46e"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"58497a7757224d1ff1941488d23087071103e5bf855f4c1c44e5c8d9d82ca46e"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"58497a7757224d1ff1941488d23087071103e5bf855f4c1c44e5c8d9d82ca46e"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"58497a7757224d1ff1941488d23087071103e5bf855f4c1c44e5c8d9d82ca46e"))),
|
||||
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)),
|
||||
@ -297,7 +296,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, inp2], [out1, out2])
|
||||
|
||||
# Accepted by network: tx c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '01000000021c032e5715d1da8115a2fe4f57699e15742fe113b0d2d1ca3b594649d322bec6010000006b483045022100f773c403b2f85a5c1d6c9c4ad69c43de66930fff4b1bc818eb257af98305546a0220443bde4be439f276a6ce793664b463580e210ec6c9255d68354449ac0443c76501210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff6ea42cd8d9c8e5441c4c5f85bfe50311078730d2881494f11f4d2257777a4958010000006b48304502210090cff1c1911e771605358a8cddd5ae94c7b60cc96e50275908d9bf9d6367c79f02202bfa72e10260a146abd59d0526e1335bacfbb2b4401780e9e3a7441b0480c8da0121038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e3ffffffff02a0860100000000001976a9142f4490d5263906e4887ca2996b9e207af3e7824088aca0860100000000001976a914812c13d97f9159e54e326b481b8f88a73df8507a88ac00000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000021c032e5715d1da8115a2fe4f57699e15742fe113b0d2d1ca3b594649d322bec6010000006b483045022100f773c403b2f85a5c1d6c9c4ad69c43de66930fff4b1bc818eb257af98305546a0220443bde4be439f276a6ce793664b463580e210ec6c9255d68354449ac0443c76501210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff6ea42cd8d9c8e5441c4c5f85bfe50311078730d2881494f11f4d2257777a4958010000006b48304502210090cff1c1911e771605358a8cddd5ae94c7b60cc96e50275908d9bf9d6367c79f02202bfa72e10260a146abd59d0526e1335bacfbb2b4401780e9e3a7441b0480c8da0121038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e3ffffffff02a0860100000000001976a9142f4490d5263906e4887ca2996b9e207af3e7824088aca0860100000000001976a914812c13d97f9159e54e326b481b8f88a73df8507a88ac00000000')
|
||||
|
||||
"""
|
||||
def test_lots_of_inputs(self):
|
||||
@ -344,7 +343,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
cnt = 255
|
||||
for _ in range(cnt):
|
||||
out = proto_types.TxOutputType(address='1NwN6UduuVkJi6sw3gSiKZaCY5rHgVXC2h',
|
||||
amount=(100000 + 2540000 - 39000) / cnt,
|
||||
amount=(100000 + 2540000 - 39000) // cnt,
|
||||
script_type=proto_types.PAYTOADDRESS,
|
||||
)
|
||||
outputs.append(out)
|
||||
@ -352,18 +351,18 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
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("c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify("c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify("c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb"))),
|
||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=binascii.unhexlify(b"c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb"))),
|
||||
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=binascii.unhexlify("39a29e954977662ab3879c66fb251ef753e0912223a83d1dcb009111d28265e5"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("39a29e954977662ab3879c66fb251ef753e0912223a83d1dcb009111d28265e5"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("39a29e954977662ab3879c66fb251ef753e0912223a83d1dcb009111d28265e5"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify("39a29e954977662ab3879c66fb251ef753e0912223a83d1dcb009111d28265e5"))),
|
||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=binascii.unhexlify(b"39a29e954977662ab3879c66fb251ef753e0912223a83d1dcb009111d28265e5"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"39a29e954977662ab3879c66fb251ef753e0912223a83d1dcb009111d28265e5"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"39a29e954977662ab3879c66fb251ef753e0912223a83d1dcb009111d28265e5"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"39a29e954977662ab3879c66fb251ef753e0912223a83d1dcb009111d28265e5"))),
|
||||
] + [
|
||||
item for items in itertools.izip(
|
||||
item for items in zip(
|
||||
[proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=I)) for I in range(cnt)],
|
||||
[proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput)] * cnt
|
||||
) for item in items
|
||||
@ -386,7 +385,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, inp2], outputs)
|
||||
|
||||
if cnt == 255:
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '0100000002fb792f470a58993e14964c9bd46cdf37cb4bbc3f61540cb651580c82ed243ec6010000006b483045022100969da46f94a81f34f3717b014e0c3e1826eda1b0022ec2f9ce39f3d750ab9235022026da269770993211a1503413566a339bbb4389a482fffcf8e1f76713fc3b94f5012103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a7902ffffffffe56582d2119100cb1d3da8232291e053f71e25fb669c87b32a667749959ea239010000006a473044022052e1419bb237b9db400ab5e3df16db6355619d545fde9030924a360763ae9ad40220704beab04d72ecaeb42eca7d98faca7a0941e65f2e1341f183be2b83e6b09e1c012103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a7902fffffffffdff00' + 'd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088ac' * cnt + '00000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000002fb792f470a58993e14964c9bd46cdf37cb4bbc3f61540cb651580c82ed243ec6010000006b483045022100969da46f94a81f34f3717b014e0c3e1826eda1b0022ec2f9ce39f3d750ab9235022026da269770993211a1503413566a339bbb4389a482fffcf8e1f76713fc3b94f5012103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a7902ffffffffe56582d2119100cb1d3da8232291e053f71e25fb669c87b32a667749959ea239010000006a473044022052e1419bb237b9db400ab5e3df16db6355619d545fde9030924a360763ae9ad40220704beab04d72ecaeb42eca7d98faca7a0941e65f2e1341f183be2b83e6b09e1c012103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a7902fffffffffdff00' + b'd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088ac' * cnt + b'00000000')
|
||||
|
||||
def test_fee_too_high(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -408,10 +407,10 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
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.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=binascii.unhexlify(b"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"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),
|
||||
@ -423,7 +422,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b483045022100a3b17b37de3bfecca47f0d49f7bb0d0f68d45df7defe45713d57e83731f5e3d902205404b14630cea6a88b23a5f7c3a1b88494757a8ca5e1c0b0b93cf3c38231c3bd0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff01e0220200000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b483045022100a3b17b37de3bfecca47f0d49f7bb0d0f68d45df7defe45713d57e83731f5e3d902205404b14630cea6a88b23a5f7c3a1b88494757a8ca5e1c0b0b93cf3c38231c3bd0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff01e0220200000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000')
|
||||
|
||||
def test_not_enough_funds(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -445,10 +444,10 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
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.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=binascii.unhexlify(b"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"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)
|
||||
@ -478,10 +477,10 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
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.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=binascii.unhexlify(b"54aa5680dea781f45ebb536e53dffc526d68c0eb5c00547e323b2c32382dfba3"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"54aa5680dea781f45ebb536e53dffc526d68c0eb5c00547e323b2c32382dfba3"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"54aa5680dea781f45ebb536e53dffc526d68c0eb5c00547e323b2c32382dfba3"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=binascii.unhexlify(b"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),
|
||||
@ -493,7 +492,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||
|
||||
# Accepted by network: tx 8cc1f4adf7224ce855cf535a5104594a0004cb3b640d6714fdb00b9128832dd5
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '0100000001a3fb2d38322c3b327e54005cebc0686d52fcdf536e53bb5ef481a7de8056aa54010000006b4830450221009e020b0390ccad533b73b552f8a99a9d827212c558e4f755503674d07c92ad4502202d606f7316990e0461c51d4add25054f19c697aa3e3c2ced4d568f0b2c57e62f0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0170f305000000000017a9147f844bdb0b8fd54b64e3d16c85dc1170f1ff97c18700000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000001a3fb2d38322c3b327e54005cebc0686d52fcdf536e53bb5ef481a7de8056aa54010000006b4830450221009e020b0390ccad533b73b552f8a99a9d827212c558e4f755503674d07c92ad4502202d606f7316990e0461c51d4add25054f19c697aa3e3c2ced4d568f0b2c57e62f0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0170f305000000000017a9147f844bdb0b8fd54b64e3d16c85dc1170f1ff97c18700000000')
|
||||
|
||||
def test_attack_change_outputs(self):
|
||||
# This unit test attempts to modify data sent during ping-pong of streaming signing.
|
||||
@ -534,7 +533,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
def attack_processor(req, msg):
|
||||
global run_attack
|
||||
|
||||
if req.details.tx_hash != '':
|
||||
if req.details.tx_hash != b'':
|
||||
return msg
|
||||
|
||||
if req.details.request_index != 1:
|
||||
@ -551,7 +550,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
(_, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, inp2], [out1, out2])
|
||||
|
||||
# Accepted by network: tx c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '01000000021c032e5715d1da8115a2fe4f57699e15742fe113b0d2d1ca3b594649d322bec6010000006b483045022100f773c403b2f85a5c1d6c9c4ad69c43de66930fff4b1bc818eb257af98305546a0220443bde4be439f276a6ce793664b463580e210ec6c9255d68354449ac0443c76501210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff6ea42cd8d9c8e5441c4c5f85bfe50311078730d2881494f11f4d2257777a4958010000006b48304502210090cff1c1911e771605358a8cddd5ae94c7b60cc96e50275908d9bf9d6367c79f02202bfa72e10260a146abd59d0526e1335bacfbb2b4401780e9e3a7441b0480c8da0121038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e3ffffffff02a0860100000000001976a9142f4490d5263906e4887ca2996b9e207af3e7824088aca0860100000000001976a914812c13d97f9159e54e326b481b8f88a73df8507a88ac00000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000021c032e5715d1da8115a2fe4f57699e15742fe113b0d2d1ca3b594649d322bec6010000006b483045022100f773c403b2f85a5c1d6c9c4ad69c43de66930fff4b1bc818eb257af98305546a0220443bde4be439f276a6ce793664b463580e210ec6c9255d68354449ac0443c76501210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff6ea42cd8d9c8e5441c4c5f85bfe50311078730d2881494f11f4d2257777a4958010000006b48304502210090cff1c1911e771605358a8cddd5ae94c7b60cc96e50275908d9bf9d6367c79f02202bfa72e10260a146abd59d0526e1335bacfbb2b4401780e9e3a7441b0480c8da0121038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e3ffffffff02a0860100000000001976a9142f4490d5263906e4887ca2996b9e207af3e7824088aca0860100000000001976a914812c13d97f9159e54e326b481b8f88a73df8507a88ac00000000')
|
||||
|
||||
# Now run the attack, must trigger the exception
|
||||
self.assertRaises(CallException, self.client.sign_tx, 'Bitcoin', [inp1, inp2], [out1, out2], attack_processor)
|
||||
@ -578,9 +577,9 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
self.client.set_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.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("d6da21677d7cca5f42fbc7631d062c9ae918a0254f7c6c22de8e8cb7fd5b8236"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify("d6da21677d7cca5f42fbc7631d062c9ae918a0254f7c6c22de8e8cb7fd5b8236"))),
|
||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=binascii.unhexlify(b"d6da21677d7cca5f42fbc7631d062c9ae918a0254f7c6c22de8e8cb7fd5b8236"))),
|
||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"d6da21677d7cca5f42fbc7631d062c9ae918a0254f7c6c22de8e8cb7fd5b8236"))),
|
||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=binascii.unhexlify(b"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),
|
||||
@ -592,7 +591,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, ], [out1, ])
|
||||
|
||||
# Accepted by network: tx
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '010000000136825bfdb78c8ede226c7c4f25a018e99a2c061d63c7fb425fca7c7d6721dad6000000006a473044022047845c366eb24f40be315c7815a154513c444c7989eb80f7ce7ff6aeb703d26a022007c1f5efadf67c5889634fd7ac39a7ce78bffac291673e8772ecd8389c901d9f01210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff01c6100795000000001976a9143d2496e67f5f57a924353da42d4725b318e7a8ea88ac00000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000136825bfdb78c8ede226c7c4f25a018e99a2c061d63c7fb425fca7c7d6721dad6000000006a473044022047845c366eb24f40be315c7815a154513c444c7989eb80f7ce7ff6aeb703d26a022007c1f5efadf67c5889634fd7ac39a7ce78bffac291673e8772ecd8389c901d9f01210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff01c6100795000000001976a9143d2496e67f5f57a924353da42d4725b318e7a8ea88ac00000000')
|
||||
|
||||
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()
|
@ -47,7 +47,7 @@ class TestMultisig(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=node, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=node, address_n=[2]),
|
||||
proto_types.HDNodePathType(node=node, address_n=[3])],
|
||||
signatures=['', '', ''],
|
||||
signatures=[b'', b'', b''],
|
||||
m=2,
|
||||
)
|
||||
|
||||
@ -82,7 +82,7 @@ class TestMultisig(common.TrezorTest):
|
||||
# Now we have first signature
|
||||
(signatures1, _) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(signatures1[0]), '3045022100985cc1ba316d140eb4b2d4028d8cd1c451f87bff8ff679858732e516ad04cd3402207af6edda99972af0baa7702a3b7448517c8242e7bca669f6861771cdd16ee058')
|
||||
self.assertEqual(binascii.hexlify(signatures1[0]), b'3045022100985cc1ba316d140eb4b2d4028d8cd1c451f87bff8ff679858732e516ad04cd3402207af6edda99972af0baa7702a3b7448517c8242e7bca669f6861771cdd16ee058')
|
||||
|
||||
# ---------------------------------------
|
||||
# Let's do second signature using 3rd key
|
||||
@ -91,7 +91,7 @@ class TestMultisig(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=node, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=node, address_n=[2]),
|
||||
proto_types.HDNodePathType(node=node, address_n=[3])],
|
||||
signatures=[signatures1[0], '', ''], # Fill signature from previous signing process
|
||||
signatures=[signatures1[0], b'', b''], # Fill signature from previous signing process
|
||||
m=2,
|
||||
)
|
||||
|
||||
@ -120,10 +120,10 @@ class TestMultisig(common.TrezorTest):
|
||||
])
|
||||
(signatures2, serialized_tx) = self.client.sign_tx('Bitcoin', [inp3, ], [out1, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(signatures2[0]), '3045022100f5428fe0531b3095675b40d87cab607ee036fac823b22e8dcec35b65aff6e52b022032129b4577ff923d321a1c70db5a6cec5bcc142cb2c51901af8b989cced23e0d')
|
||||
self.assertEqual(binascii.hexlify(signatures2[0]), b'3045022100f5428fe0531b3095675b40d87cab607ee036fac823b22e8dcec35b65aff6e52b022032129b4577ff923d321a1c70db5a6cec5bcc142cb2c51901af8b989cced23e0d')
|
||||
|
||||
# Accepted by network: tx 8382a2b2e3ec8788800c1d46d285dfa9dd4051edddd75982fad166b9273e5ac6
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '010000000152ba4dfcde9c4bed88f55479cdea03e711ae586e9a89352a98230c4cdf1a09c601000000fdfe0000483045022100985cc1ba316d140eb4b2d4028d8cd1c451f87bff8ff679858732e516ad04cd3402207af6edda99972af0baa7702a3b7448517c8242e7bca669f6861771cdd16ee05801483045022100f5428fe0531b3095675b40d87cab607ee036fac823b22e8dcec35b65aff6e52b022032129b4577ff923d321a1c70db5a6cec5bcc142cb2c51901af8b989cced23e0d014c6952210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a621038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e32103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a790253aeffffffff01a0860100000000001976a91412e8391ad256dcdc023365978418d658dfecba1c88ac00000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000152ba4dfcde9c4bed88f55479cdea03e711ae586e9a89352a98230c4cdf1a09c601000000fdfe0000483045022100985cc1ba316d140eb4b2d4028d8cd1c451f87bff8ff679858732e516ad04cd3402207af6edda99972af0baa7702a3b7448517c8242e7bca669f6861771cdd16ee05801483045022100f5428fe0531b3095675b40d87cab607ee036fac823b22e8dcec35b65aff6e52b022032129b4577ff923d321a1c70db5a6cec5bcc142cb2c51901af8b989cced23e0d014c6952210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a621038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e32103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a790253aeffffffff01a0860100000000001976a91412e8391ad256dcdc023365978418d658dfecba1c88ac00000000')
|
||||
|
||||
def test_15_of_15(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -149,7 +149,7 @@ class TestMultisig(common.TrezorTest):
|
||||
# multisig address
|
||||
# 3QaKF8zobqcqY8aS6nxCD5ZYdiRfL3RCmU
|
||||
|
||||
signatures = [''] * 15
|
||||
signatures = [b''] * 15
|
||||
|
||||
out1 = proto_types.TxOutputType(address='17kTB7qSk3MupQxWdiv5ZU3zcrZc2Azes1',
|
||||
amount=10000,
|
||||
@ -174,7 +174,7 @@ class TestMultisig(common.TrezorTest):
|
||||
signatures[x] = sig[0]
|
||||
|
||||
# Accepted as tx id dd320786d1f58c095be0509dc56b277b6de8f2fb5517f519c6e6708414e3300b
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '01000000011553ef34c683f4d6a8d346844409e6e7fc4ff01eaa25b7e8ce215abbfee3896101000000fd43060048304502210098e23085ad7282de988bf98afa1e9add9c9830009132f8902a9fa4624d5dc98b0220733216e70ab67791aa64be5c83d2050cb4ed9ff7eda2a1acc35da024d2ab2a670147304402201f8c11fb6e90fd616e484986e9451929797eba039882a9abcc203210948060b9022044da031530de7d9747d3c5a8e7cec04b04b7af495c9120b854ce7362af7fa05a01483045022100ea67c70186acef019bdf1551881bf38e6f88186501b64d3a756a2ce18e4ba18002201c35110325653e21e448b60053a4b5dda46b61096faf701a1faca61fcde91f00014730440220315598992f156d2f9d7b4275395fa067aa61ea95829fa17730885c86df4de70d02203eda9ade1656e2198c668603b17e197acb0969ed183ab0841303ea261205618901473044022060fdd6621edde9b8cf6776bc4eef26ace9b57514d725b7214ba11d333520a30e022044c30744f94484aec0f896233c5613a3256878ec0379f566226906b6d1b6061401483045022100b1d907e3574f60f7834c7e9f2e367998ce0461dad7d742d84ef8917d713f41f902203b3ac54f7bb2f7fb8685f582d2a94f7213a37cb508acffe29090cc06ae01588b01483045022100e3bf90ff3ad6395e42f46002f253f94ca0e8ffaa0620f2ceb4fa21493abdca4d02201d4c28b10b740bb2dc4b3695b4205c18f8c0dad2bb69540eb8a36576463cd5280147304402202cfaf9fab7dc1c9f0c3c23bd46bd6d5cea0664d914139fc9add80766ce998808022012db2802c07853e4cbe147afdf0b47e60bdcbcd31f9df19e04c177ed9aa66c6d0147304402207cbc2d83f351eee5ee91df26bb0c7e1cb07fe328cbbcdb0bb9656d37922c497302201b3435d4c71ffd1b34d45892f2a487bd79c8c7f57cc04373287642bb9610cb840147304402202dc3eab30ccb06553703e794212f43ee9a659f5e787a8374e9ea0bf6de0def7402201a70e970c21a807783313ed102bf4f0a3406ac7c84f94bc8194c5e209464d7230147304402206b04530c190c46a879d7771a6ad53acd33547e0d7fd320d5ad0b5b1fdeb5d4c202207b812be81c3419daadc942cca0c55aa32c7759fa7566c6dc35f030ca87a1c5be01483045022100ce523dddd6eef73d5ae7c44c870466e1ac5a7a77d43475e8def024af68977a1e022028be0276435bfa2ea887d6cf89fa829f96c1c7a55edc57bb3fd667d523fd3bf601473044022019410b20ebcd8eb3ee7ec1eff6bf0f9cbfaea82116811c61f3cf24af7e4434b1022009e5823f3349f695be09ae40754185300d8442a22715ddb5ffa17c4213140e7201483045022100964ef26a9074c3cdafffcfbe4bd445933f8c842ba11fd887922adcf7fabe0c82022023055d94c75ab223c767fbaa825c917e9beecbc7d5758cccf20d886c63d4b72a0147304402207aa3a98197697d258a8baae681f0b4c0ee682982f4205534e6c95a37dabaddd60220517a7ed5c03da2f242e17ccfdae0d81d6f454d7f9ea931fc62df6c0eab922186014d01025f21023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43d210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a621038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e32103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a79022103fe91eca10602d7dad4c9dab2b2a0858f71e25a219a6940749ce7a48118480dae210234716c01c2dd03fa7ee302705e2b8fbd1311895d94b1dca15e62eedea9b0968f210341fb2ead334952cf60f4481ba435c4693d0be649be01d2cfe9b02018e483e7bd2102dad8b2bce360a705c16e74a50a36459b4f8f4b78f9cd67def29d54ef6f7c7cf9210222dbe3f5f197a34a1d50e2cbe2a1085cac2d605c9e176f9a240e0fd0c669330d2103fb41afab56c9cdb013fda63d777d4938ddc3cb2ad939712da688e3ed333f95982102435f177646bdc717cb3211bf46656ca7e8d642726144778c9ce816b8b8c36ccf2102158d8e20095364031d923c7e9f7f08a14b1be1ddee21fe1a5431168e31345e5521026259794892428ca0818c8fb61d2d459ddfe20e57f50803c7295e6f4e2f5586652102815f910a8689151db627e6e262e0a2075ad5ec2993a6bc1b876a9d420923d681210318f54647f645ff01bd49fedc0219343a6a22d3ea3180a3c3d3097e4b888a8db45faeffffffff0110270000000000001976a9144a087d89f8ad16ca029c675b037c02fd1c5f9aec88ac00000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000011553ef34c683f4d6a8d346844409e6e7fc4ff01eaa25b7e8ce215abbfee3896101000000fd43060048304502210098e23085ad7282de988bf98afa1e9add9c9830009132f8902a9fa4624d5dc98b0220733216e70ab67791aa64be5c83d2050cb4ed9ff7eda2a1acc35da024d2ab2a670147304402201f8c11fb6e90fd616e484986e9451929797eba039882a9abcc203210948060b9022044da031530de7d9747d3c5a8e7cec04b04b7af495c9120b854ce7362af7fa05a01483045022100ea67c70186acef019bdf1551881bf38e6f88186501b64d3a756a2ce18e4ba18002201c35110325653e21e448b60053a4b5dda46b61096faf701a1faca61fcde91f00014730440220315598992f156d2f9d7b4275395fa067aa61ea95829fa17730885c86df4de70d02203eda9ade1656e2198c668603b17e197acb0969ed183ab0841303ea261205618901473044022060fdd6621edde9b8cf6776bc4eef26ace9b57514d725b7214ba11d333520a30e022044c30744f94484aec0f896233c5613a3256878ec0379f566226906b6d1b6061401483045022100b1d907e3574f60f7834c7e9f2e367998ce0461dad7d742d84ef8917d713f41f902203b3ac54f7bb2f7fb8685f582d2a94f7213a37cb508acffe29090cc06ae01588b01483045022100e3bf90ff3ad6395e42f46002f253f94ca0e8ffaa0620f2ceb4fa21493abdca4d02201d4c28b10b740bb2dc4b3695b4205c18f8c0dad2bb69540eb8a36576463cd5280147304402202cfaf9fab7dc1c9f0c3c23bd46bd6d5cea0664d914139fc9add80766ce998808022012db2802c07853e4cbe147afdf0b47e60bdcbcd31f9df19e04c177ed9aa66c6d0147304402207cbc2d83f351eee5ee91df26bb0c7e1cb07fe328cbbcdb0bb9656d37922c497302201b3435d4c71ffd1b34d45892f2a487bd79c8c7f57cc04373287642bb9610cb840147304402202dc3eab30ccb06553703e794212f43ee9a659f5e787a8374e9ea0bf6de0def7402201a70e970c21a807783313ed102bf4f0a3406ac7c84f94bc8194c5e209464d7230147304402206b04530c190c46a879d7771a6ad53acd33547e0d7fd320d5ad0b5b1fdeb5d4c202207b812be81c3419daadc942cca0c55aa32c7759fa7566c6dc35f030ca87a1c5be01483045022100ce523dddd6eef73d5ae7c44c870466e1ac5a7a77d43475e8def024af68977a1e022028be0276435bfa2ea887d6cf89fa829f96c1c7a55edc57bb3fd667d523fd3bf601473044022019410b20ebcd8eb3ee7ec1eff6bf0f9cbfaea82116811c61f3cf24af7e4434b1022009e5823f3349f695be09ae40754185300d8442a22715ddb5ffa17c4213140e7201483045022100964ef26a9074c3cdafffcfbe4bd445933f8c842ba11fd887922adcf7fabe0c82022023055d94c75ab223c767fbaa825c917e9beecbc7d5758cccf20d886c63d4b72a0147304402207aa3a98197697d258a8baae681f0b4c0ee682982f4205534e6c95a37dabaddd60220517a7ed5c03da2f242e17ccfdae0d81d6f454d7f9ea931fc62df6c0eab922186014d01025f21023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43d210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a621038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e32103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a79022103fe91eca10602d7dad4c9dab2b2a0858f71e25a219a6940749ce7a48118480dae210234716c01c2dd03fa7ee302705e2b8fbd1311895d94b1dca15e62eedea9b0968f210341fb2ead334952cf60f4481ba435c4693d0be649be01d2cfe9b02018e483e7bd2102dad8b2bce360a705c16e74a50a36459b4f8f4b78f9cd67def29d54ef6f7c7cf9210222dbe3f5f197a34a1d50e2cbe2a1085cac2d605c9e176f9a240e0fd0c669330d2103fb41afab56c9cdb013fda63d777d4938ddc3cb2ad939712da688e3ed333f95982102435f177646bdc717cb3211bf46656ca7e8d642726144778c9ce816b8b8c36ccf2102158d8e20095364031d923c7e9f7f08a14b1be1ddee21fe1a5431168e31345e5521026259794892428ca0818c8fb61d2d459ddfe20e57f50803c7295e6f4e2f5586652102815f910a8689151db627e6e262e0a2075ad5ec2993a6bc1b876a9d420923d681210318f54647f645ff01bd49fedc0219343a6a22d3ea3180a3c3d3097e4b888a8db45faeffffffff0110270000000000001976a9144a087d89f8ad16ca029c675b037c02fd1c5f9aec88ac00000000')
|
||||
|
||||
def test_missing_pubkey(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -199,7 +199,7 @@ class TestMultisig(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=node, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=node, address_n=[2]),
|
||||
proto_types.HDNodePathType(node=node, address_n=[3])],
|
||||
signatures=['', '', ''],
|
||||
signatures=[b'', b'', b''],
|
||||
m=2,
|
||||
)
|
||||
|
||||
|
@ -44,7 +44,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=node_ext1, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=node_ext2, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=node_int, address_n=[1])],
|
||||
signatures=['', '', ''],
|
||||
signatures=[b'', b'', b''],
|
||||
m=2,
|
||||
)
|
||||
|
||||
@ -52,7 +52,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=node_ext1, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=node_int, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=node_ext2, address_n=[1])],
|
||||
signatures=['', '', ''],
|
||||
signatures=[b'', b'', b''],
|
||||
m=2,
|
||||
)
|
||||
|
||||
@ -60,7 +60,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=node_ext1, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=node_ext3, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=node_int, address_n=[1])],
|
||||
signatures=['', '', ''],
|
||||
signatures=[b'', b'', b''],
|
||||
m=2,
|
||||
)
|
||||
|
||||
@ -143,7 +143,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
self.client.set_expected_responses(self._responses(self.inp1, self.inp2))
|
||||
(_, serialized_tx) = self.client.sign_tx('Bitcoin', [self.inp1, self.inp2, ], [out1, out2, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b500483045022100c4116c9a584083021dacb690d4d4938027cc3f2085dc15157162b589f2a0b52f02200bdec59f76376255afc7b76f759106f6f00edf0134db2a0ae5d28000ea517fd2014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff9643add957ab239b1d8fe387cc3807b48130a553a7b181e447ee9c089d82e2a600000000b400473044022044e77c67a5a78c8eb4f304cf23972a7763cce6f7dc3587d6e77e2aa05212ea6402200be874d39c32ad2475d03342cb0b164ec618297231c519186e3d0efde7a3374d014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c153aeffffffff02a0860100000000001976a91412e8391ad256dcdc023365978418d658dfecba1c88aca0860100000000001976a9144a087d89f8ad16ca029c675b037c02fd1c5f9aec88ac00000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b500483045022100c4116c9a584083021dacb690d4d4938027cc3f2085dc15157162b589f2a0b52f02200bdec59f76376255afc7b76f759106f6f00edf0134db2a0ae5d28000ea517fd2014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff9643add957ab239b1d8fe387cc3807b48130a553a7b181e447ee9c089d82e2a600000000b400473044022044e77c67a5a78c8eb4f304cf23972a7763cce6f7dc3587d6e77e2aa05212ea6402200be874d39c32ad2475d03342cb0b164ec618297231c519186e3d0efde7a3374d014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c153aeffffffff02a0860100000000001976a91412e8391ad256dcdc023365978418d658dfecba1c88aca0860100000000001976a9144a087d89f8ad16ca029c675b037c02fd1c5f9aec88ac00000000')
|
||||
|
||||
# first external, second internal
|
||||
def test_external_internal(self):
|
||||
@ -161,7 +161,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
self.client.set_expected_responses(self._responses(self.inp1, self.inp2, change=2))
|
||||
(_, serialized_tx) = self.client.sign_tx('Bitcoin', [self.inp1, self.inp2, ], [out1, out2, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b5004830450221008f48ee3c6e69f8d2aeea9c482e3e80233fc83d78eb1ac7416362b25ae57d3eee02207f6b568f8f611efb17bd6bf8d0b32d334aa4110a2cc97a06f48aba4d045b7cd4014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff9643add957ab239b1d8fe387cc3807b48130a553a7b181e447ee9c089d82e2a600000000b40047304402206c5f93cbedc06ac1bae846d850a27c56b0e6f75ef247d3d67a10bbe8ea9da90302203d64f4803c0cbe5703268d58a80d54a3ad72cb1b856f19a6c6c999aad011a5b9014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c153aeffffffff02a0860100000000001976a91412e8391ad256dcdc023365978418d658dfecba1c88aca0860100000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088ac00000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b5004830450221008f48ee3c6e69f8d2aeea9c482e3e80233fc83d78eb1ac7416362b25ae57d3eee02207f6b568f8f611efb17bd6bf8d0b32d334aa4110a2cc97a06f48aba4d045b7cd4014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff9643add957ab239b1d8fe387cc3807b48130a553a7b181e447ee9c089d82e2a600000000b40047304402206c5f93cbedc06ac1bae846d850a27c56b0e6f75ef247d3d67a10bbe8ea9da90302203d64f4803c0cbe5703268d58a80d54a3ad72cb1b856f19a6c6c999aad011a5b9014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c153aeffffffff02a0860100000000001976a91412e8391ad256dcdc023365978418d658dfecba1c88aca0860100000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088ac00000000')
|
||||
|
||||
# first internal, second external
|
||||
def test_internal_external(self):
|
||||
@ -179,7 +179,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
self.client.set_expected_responses(self._responses(self.inp1, self.inp2, change=1))
|
||||
(_, serialized_tx) = self.client.sign_tx('Bitcoin', [self.inp1, self.inp2, ], [out1, out2, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b4004730440220740f305af9cd10f290b0d5dd27968d3c08f313d58e70feb260e076bd57d427bd02202c0296b38e82993983b971196589a2c74cdc4931a2da88aa2c2bd89e58a3fdb2014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff9643add957ab239b1d8fe387cc3807b48130a553a7b181e447ee9c089d82e2a600000000b400473044022042f53a8cd53762fb95113d11f56f050dab9dead9a2026807c728d5c42ed62e9902202e708162a50ca16f5fac082c1a2a5350fcb74cbfce39968e76300a36457f45a7014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c153aeffffffff02a0860100000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088aca0860100000000001976a9144a087d89f8ad16ca029c675b037c02fd1c5f9aec88ac00000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b4004730440220740f305af9cd10f290b0d5dd27968d3c08f313d58e70feb260e076bd57d427bd02202c0296b38e82993983b971196589a2c74cdc4931a2da88aa2c2bd89e58a3fdb2014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff9643add957ab239b1d8fe387cc3807b48130a553a7b181e447ee9c089d82e2a600000000b400473044022042f53a8cd53762fb95113d11f56f050dab9dead9a2026807c728d5c42ed62e9902202e708162a50ca16f5fac082c1a2a5350fcb74cbfce39968e76300a36457f45a7014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c153aeffffffff02a0860100000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088aca0860100000000001976a9144a087d89f8ad16ca029c675b037c02fd1c5f9aec88ac00000000')
|
||||
|
||||
# both outputs are external
|
||||
def test_multisig_external_external(self):
|
||||
@ -189,7 +189,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=self.node_ext1, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=self.node_ext2, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=self.node_ext3, address_n=[1])],
|
||||
signatures=['', '', ''],
|
||||
signatures=[b'', b'', b''],
|
||||
m=2,
|
||||
)
|
||||
|
||||
@ -197,7 +197,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=self.node_ext1, address_n=[2]),
|
||||
proto_types.HDNodePathType(node=self.node_ext2, address_n=[2]),
|
||||
proto_types.HDNodePathType(node=self.node_ext3, address_n=[2])],
|
||||
signatures=['', '', ''],
|
||||
signatures=[b'', b'', b''],
|
||||
m=2,
|
||||
)
|
||||
|
||||
@ -213,7 +213,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
self.client.set_expected_responses(self._responses(self.inp1, self.inp2))
|
||||
(_, serialized_tx) = self.client.sign_tx('Bitcoin', [self.inp1, self.inp2, ], [out1, out2, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b500483045022100915e3761efb41895d40fa3bf8d3a68be7eb949e2411ec5655e231bbb334925ea02205814166b786a912f8f47315c9ede4955d2dfc70bb0b51230fccaaacf5a39a0ae014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff9643add957ab239b1d8fe387cc3807b48130a553a7b181e447ee9c089d82e2a600000000b400473044022018ca5516ee127eeeb8c70f10c267dd803b599688eade659e3b210bbf1712fffe02206c1adb35e672e67ee102dc232456ac5edc86f58f83d698995981e68d2a2a4294014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c153aeffffffff02a08601000000000017a9143bc72e27ec21644ace15b367ef7ba491f2507eb587a08601000000000017a9147615527d78854293edadf83682ea26937f8a51bb8700000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b500483045022100915e3761efb41895d40fa3bf8d3a68be7eb949e2411ec5655e231bbb334925ea02205814166b786a912f8f47315c9ede4955d2dfc70bb0b51230fccaaacf5a39a0ae014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff9643add957ab239b1d8fe387cc3807b48130a553a7b181e447ee9c089d82e2a600000000b400473044022018ca5516ee127eeeb8c70f10c267dd803b599688eade659e3b210bbf1712fffe02206c1adb35e672e67ee102dc232456ac5edc86f58f83d698995981e68d2a2a4294014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c153aeffffffff02a08601000000000017a9143bc72e27ec21644ace15b367ef7ba491f2507eb587a08601000000000017a9147615527d78854293edadf83682ea26937f8a51bb8700000000')
|
||||
|
||||
# inputs match, change matches (first is change)
|
||||
def test_multisig_change_match_first(self):
|
||||
@ -223,7 +223,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=self.node_int, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=self.node_ext1, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=self.node_ext2, address_n=[1])],
|
||||
signatures=['', '', ''],
|
||||
signatures=[b'', b'', b''],
|
||||
m=2,
|
||||
)
|
||||
|
||||
@ -231,7 +231,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=self.node_ext1, address_n=[2]),
|
||||
proto_types.HDNodePathType(node=self.node_ext2, address_n=[2]),
|
||||
proto_types.HDNodePathType(node=self.node_ext3, address_n=[2])],
|
||||
signatures=['', '', ''],
|
||||
signatures=[b'', b'', b''],
|
||||
m=2,
|
||||
)
|
||||
|
||||
@ -247,7 +247,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
self.client.set_expected_responses(self._responses(self.inp1, self.inp2, change=1))
|
||||
(_, serialized_tx) = self.client.sign_tx('Bitcoin', [self.inp1, self.inp2, ], [out1, out2, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b40047304402203cb26eac850f590951b12b513a5369c0b301c6d3ae1cd251aa837ce35427bdec0220289834c8c5cb837351ae06498d77fa6707611c09d628864a1f0a7e1d381bddd8014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff9643add957ab239b1d8fe387cc3807b48130a553a7b181e447ee9c089d82e2a600000000b40047304402207c2e39254d1e9cff42b523bcc0bf5ab66ae0c584deb2413759d9b269b1fe9e6f02205bc93a1884625b2359247c15a57e4e80b184b21a5f95e7f5ce846323236e30ac014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c153aeffffffff02a08601000000000017a914b69a5c6a63c01a09a90eb690031963f737cf96ed87a08601000000000017a9147615527d78854293edadf83682ea26937f8a51bb8700000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b40047304402203cb26eac850f590951b12b513a5369c0b301c6d3ae1cd251aa837ce35427bdec0220289834c8c5cb837351ae06498d77fa6707611c09d628864a1f0a7e1d381bddd8014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff9643add957ab239b1d8fe387cc3807b48130a553a7b181e447ee9c089d82e2a600000000b40047304402207c2e39254d1e9cff42b523bcc0bf5ab66ae0c584deb2413759d9b269b1fe9e6f02205bc93a1884625b2359247c15a57e4e80b184b21a5f95e7f5ce846323236e30ac014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c153aeffffffff02a08601000000000017a914b69a5c6a63c01a09a90eb690031963f737cf96ed87a08601000000000017a9147615527d78854293edadf83682ea26937f8a51bb8700000000')
|
||||
|
||||
# inputs match, change matches (second is change)
|
||||
def test_multisig_change_match_second(self):
|
||||
@ -257,7 +257,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=self.node_ext1, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=self.node_ext1, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=self.node_ext2, address_n=[1])],
|
||||
signatures=['', '', ''],
|
||||
signatures=[b'', b'', b''],
|
||||
m=2,
|
||||
)
|
||||
|
||||
@ -265,7 +265,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=self.node_int, address_n=[2]),
|
||||
proto_types.HDNodePathType(node=self.node_ext1, address_n=[2]),
|
||||
proto_types.HDNodePathType(node=self.node_ext2, address_n=[2])],
|
||||
signatures=['', '', ''],
|
||||
signatures=[b'', b'', b''],
|
||||
m=2,
|
||||
)
|
||||
|
||||
@ -281,7 +281,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
self.client.set_expected_responses(self._responses(self.inp1, self.inp2, change=2))
|
||||
(_, serialized_tx) = self.client.sign_tx('Bitcoin', [self.inp1, self.inp2, ], [out1, out2, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b5004830450221008d5710ba7df3c32358a723c69458acc81a296646cad262217975ba00b24fdc6402201623a3e3778e6abad9025343cef6fad361a054463f928509324ee862a2e84e6a014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff9643add957ab239b1d8fe387cc3807b48130a553a7b181e447ee9c089d82e2a600000000b400473044022014d07e6a67c14a81d1042be2990d4c4ac29d9a46ba051168a9ccc09e987d97e202203cfe6714cff04421a90d5a4507f875515a1357fc2df306a44617ae7f88c7fcd1014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c153aeffffffff02a08601000000000017a9143fdb3ed6e85c87d77f263be3b0d0abc508fe4e3787a08601000000000017a914021809d0cb4a6fcf436e6b8cc743511b09d183218700000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b5004830450221008d5710ba7df3c32358a723c69458acc81a296646cad262217975ba00b24fdc6402201623a3e3778e6abad9025343cef6fad361a054463f928509324ee862a2e84e6a014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff9643add957ab239b1d8fe387cc3807b48130a553a7b181e447ee9c089d82e2a600000000b400473044022014d07e6a67c14a81d1042be2990d4c4ac29d9a46ba051168a9ccc09e987d97e202203cfe6714cff04421a90d5a4507f875515a1357fc2df306a44617ae7f88c7fcd1014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c153aeffffffff02a08601000000000017a9143fdb3ed6e85c87d77f263be3b0d0abc508fe4e3787a08601000000000017a914021809d0cb4a6fcf436e6b8cc743511b09d183218700000000')
|
||||
|
||||
# inputs match, change mismatches (second is change)
|
||||
def test_multisig_mismatch_change(self):
|
||||
@ -291,7 +291,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=self.node_ext1, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=self.node_ext2, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=self.node_ext3, address_n=[1])],
|
||||
signatures=['', '', ''],
|
||||
signatures=[b'', b'', b''],
|
||||
m=2,
|
||||
)
|
||||
|
||||
@ -299,7 +299,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=self.node_int, address_n=[2]),
|
||||
proto_types.HDNodePathType(node=self.node_ext1, address_n=[2]),
|
||||
proto_types.HDNodePathType(node=self.node_ext3, address_n=[2])],
|
||||
signatures=['', '', ''],
|
||||
signatures=[b'', b'', b''],
|
||||
m=2,
|
||||
)
|
||||
|
||||
@ -315,7 +315,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
self.client.set_expected_responses(self._responses(self.inp1, self.inp2))
|
||||
(_, serialized_tx) = self.client.sign_tx('Bitcoin', [self.inp1, self.inp2, ], [out1, out2, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b40047304402202a6238e8c9955a3d01609cbdaafcf47b0a53b2eabe2e28cf942fe9e253457eba02207f67afb4c35a8d28603e71a0696d0c123c0ca2370d78076c692ca3036c0a2c35014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff9643add957ab239b1d8fe387cc3807b48130a553a7b181e447ee9c089d82e2a600000000b40047304402200e87ee683b27f3995a2f8c9e9b4b17e24399d43a4c69ce5402105b6b93ac63cf0220201ba91db1f4ca2768f9277c115e95c2297bbe40969dcf9d10d0836a75c8ac9c014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c153aeffffffff02a08601000000000017a9143bc72e27ec21644ace15b367ef7ba491f2507eb587a08601000000000017a9143f22da0a6d4a4341be319e48e7b51b5a113fda208700000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b40047304402202a6238e8c9955a3d01609cbdaafcf47b0a53b2eabe2e28cf942fe9e253457eba02207f67afb4c35a8d28603e71a0696d0c123c0ca2370d78076c692ca3036c0a2c35014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff9643add957ab239b1d8fe387cc3807b48130a553a7b181e447ee9c089d82e2a600000000b40047304402200e87ee683b27f3995a2f8c9e9b4b17e24399d43a4c69ce5402105b6b93ac63cf0220201ba91db1f4ca2768f9277c115e95c2297bbe40969dcf9d10d0836a75c8ac9c014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c153aeffffffff02a08601000000000017a9143bc72e27ec21644ace15b367ef7ba491f2507eb587a08601000000000017a9143f22da0a6d4a4341be319e48e7b51b5a113fda208700000000')
|
||||
|
||||
# inputs mismatch, change matches with first input
|
||||
def test_multisig_mismatch_inputs(self):
|
||||
@ -325,7 +325,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=self.node_ext1, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=self.node_ext2, address_n=[1]),
|
||||
proto_types.HDNodePathType(node=self.node_int, address_n=[1])],
|
||||
signatures=['', '', ''],
|
||||
signatures=[b'', b'', b''],
|
||||
m=2,
|
||||
)
|
||||
|
||||
@ -333,7 +333,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
pubkeys=[proto_types.HDNodePathType(node=self.node_ext1, address_n=[2]),
|
||||
proto_types.HDNodePathType(node=self.node_ext2, address_n=[2]),
|
||||
proto_types.HDNodePathType(node=self.node_ext3, address_n=[2])],
|
||||
signatures=['', '', ''],
|
||||
signatures=[b'', b'', b''],
|
||||
m=2,
|
||||
)
|
||||
|
||||
@ -349,7 +349,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
self.client.set_expected_responses(self._responses(self.inp1, self.inp3))
|
||||
(_, serialized_tx) = self.client.sign_tx('Bitcoin', [self.inp1, self.inp3, ], [out1, out2, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b40047304402204b7d6c7e9feef91209cbdf4deaf855696dc22a40e57bd3eafd5e00b0ee41d9de0220262c5a05d0b46ef98fddfef3831b3ebb6841ffbeb10666f8fb6f8d2e3023e30d014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffffe39b254db8137202c7690cb0c6738f2e61661ce16f92b3f2087a00e5e51abce401000000b500483045022100bb2118da21c8a84f115b655f640f269a40be77ae2c0af9c5ffd8260a85dbfc7702202e7b5b6c05b8f50bd879dbee88828e80e85448d686b63a1a50e99d921923f6f5014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e2102e0c21e2a7cf00b94c5421725acff97f9826598b91f2340c5ddda730caca7d648210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff02a08601000000000017a914a4efc33d43d7a8a0040182c76ab624ff862f50d287a08601000000000017a9147615527d78854293edadf83682ea26937f8a51bb8700000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b40047304402204b7d6c7e9feef91209cbdf4deaf855696dc22a40e57bd3eafd5e00b0ee41d9de0220262c5a05d0b46ef98fddfef3831b3ebb6841ffbeb10666f8fb6f8d2e3023e30d014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffffe39b254db8137202c7690cb0c6738f2e61661ce16f92b3f2087a00e5e51abce401000000b500483045022100bb2118da21c8a84f115b655f640f269a40be77ae2c0af9c5ffd8260a85dbfc7702202e7b5b6c05b8f50bd879dbee88828e80e85448d686b63a1a50e99d921923f6f5014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e2102e0c21e2a7cf00b94c5421725acff97f9826598b91f2340c5ddda730caca7d648210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff02a08601000000000017a914a4efc33d43d7a8a0040182c76ab624ff862f50d287a08601000000000017a9147615527d78854293edadf83682ea26937f8a51bb8700000000')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -27,7 +27,7 @@ class TestOpReturn(common.TrezorTest):
|
||||
script_type=proto_types.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
out2 = proto_types.TxOutputType(op_return_data='test of the op_return data',
|
||||
out2 = proto_types.TxOutputType(op_return_data=b'test of the op_return data',
|
||||
amount=0,
|
||||
script_type=proto_types.PAYTOOPRETURN,
|
||||
)
|
||||
@ -52,7 +52,7 @@ class TestOpReturn(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006a4730440220187b7b9c340a32fc8445418ad11fb3827d2e8bac7d730e1c9ad800353e7ba62f02206c0c5820ba8882c82923a39aee8d36d6d32e13daed73f7a3d6199de5f8e7ddfd0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0260cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000000000001c6a1a74657374206f6620746865206f705f72657475726e206461746100000000')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006a4730440220187b7b9c340a32fc8445418ad11fb3827d2e8bac7d730e1c9ad800353e7ba62f02206c0c5820ba8882c82923a39aee8d36d6d32e13daed73f7a3d6199de5f8e7ddfd0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0260cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000000000001c6a1a74657374206f6620746865206f705f72657475726e206461746100000000')
|
||||
|
||||
def test_nonzero_opreturn(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -71,7 +71,7 @@ class TestOpReturn(common.TrezorTest):
|
||||
script_type=proto_types.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
out1 = proto_types.TxOutputType(op_return_data='test of the op_return data',
|
||||
out1 = proto_types.TxOutputType(op_return_data=b'test of the op_return data',
|
||||
amount=10000,
|
||||
script_type=proto_types.PAYTOOPRETURN,
|
||||
)
|
||||
|
@ -3,10 +3,17 @@ from __future__ import print_function
|
||||
import unittest
|
||||
import common
|
||||
import binascii
|
||||
import sys
|
||||
|
||||
import trezorlib.messages_pb2 as proto
|
||||
import trezorlib.types_pb2 as proto_types
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def byteindex(data, index):
|
||||
return ord(data[index])
|
||||
else:
|
||||
byteindex = lambda data, index: data[index]
|
||||
|
||||
# address_n = [177] < 68
|
||||
# address_n = [16518] < 66
|
||||
class TestZeroSig(common.TrezorTest):
|
||||
@ -34,7 +41,7 @@ class TestZeroSig(common.TrezorTest):
|
||||
|
||||
tx = self.client.call(msg)
|
||||
|
||||
siglen = ord(tx.serialized_tx[44])
|
||||
siglen = byteindex(tx.serialized_tx, 44)
|
||||
print(siglen)
|
||||
if siglen < 67:
|
||||
print("!!!!", n)
|
||||
@ -58,7 +65,7 @@ class TestZeroSig(common.TrezorTest):
|
||||
)
|
||||
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||
siglen = ord(serialized_tx[44])
|
||||
siglen = byteindex(serialized_tx, 44)
|
||||
|
||||
# TREZOR must strip leading zero from signature
|
||||
self.assertEqual(siglen, 67)
|
||||
@ -79,7 +86,7 @@ class TestZeroSig(common.TrezorTest):
|
||||
)
|
||||
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||
siglen = ord(serialized_tx[44])
|
||||
siglen = byteindex(serialized_tx, 44)
|
||||
|
||||
# TREZOR must strip leading zero from signature
|
||||
self.assertEqual(siglen, 66)
|
||||
|
@ -1,6 +1,7 @@
|
||||
import struct
|
||||
import hmac
|
||||
import hashlib
|
||||
import sys
|
||||
|
||||
import ecdsa
|
||||
from ecdsa.util import string_to_number, number_to_string
|
||||
@ -12,12 +13,19 @@ from . import types_pb2 as proto_types
|
||||
|
||||
PRIME_DERIVATION_FLAG = 0x80000000
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def byteindex(data, index):
|
||||
return ord(data[index])
|
||||
else:
|
||||
byteindex = lambda data, index: data[index]
|
||||
|
||||
|
||||
def point_to_pubkey(point):
|
||||
order = SECP256k1.order
|
||||
x_str = number_to_string(point.x(), order)
|
||||
y_str = number_to_string(point.y(), order)
|
||||
vk = x_str + y_str
|
||||
return chr((ord(vk[63]) & 1) + 2) + vk[0:32] # To compressed key
|
||||
return struct.pack('B', (byteindex(vk, 63) & 1) + 2) + vk[0:32] # To compressed key
|
||||
|
||||
def sec_to_public_pair(pubkey):
|
||||
"""Convert a public key in sec binary format to a public pair."""
|
||||
@ -91,14 +99,14 @@ def get_subnode(node, i):
|
||||
return node_out
|
||||
|
||||
def serialize(node, version=0x0488B21E):
|
||||
s = ''
|
||||
s = b''
|
||||
s += struct.pack('>I', version)
|
||||
s += struct.pack('>B', node.depth)
|
||||
s += struct.pack('>I', node.fingerprint)
|
||||
s += struct.pack('>I', node.child_num)
|
||||
s += node.chain_code
|
||||
if node.private_key:
|
||||
s += '\x00' + node.private_key
|
||||
s += b'\x00' + node.private_key
|
||||
else:
|
||||
s += node.public_key
|
||||
s += tools.Hash(s)[:4]
|
||||
@ -117,7 +125,7 @@ def deserialize(xpub):
|
||||
node.chain_code = data[13:45]
|
||||
|
||||
key = data[45:-4]
|
||||
if key[0] == '\x00':
|
||||
if byteindex(key, 0) == 0:
|
||||
node.private_key = key[1:]
|
||||
else:
|
||||
node.public_key = key
|
||||
|
@ -501,7 +501,7 @@ class ProtocolMixin(object):
|
||||
def sign_message(self, coin_name, n, message):
|
||||
n = self._convert_prime(n)
|
||||
# Convert message to UTF8 NFC (seems to be a bitcoin-qt standard)
|
||||
message = normalize_nfc(message)
|
||||
message = normalize_nfc(message).encode("utf-8")
|
||||
return self.call(proto.SignMessage(coin_name=coin_name, address_n=n, message=message))
|
||||
|
||||
@expect(proto.SignedIdentity)
|
||||
@ -520,7 +520,7 @@ class ProtocolMixin(object):
|
||||
|
||||
def verify_message(self, address, signature, message):
|
||||
# Convert message to UTF8 NFC (seems to be a bitcoin-qt standard)
|
||||
message = normalize_nfc(message)
|
||||
message = normalize_nfc(message).encode("utf-8")
|
||||
try:
|
||||
if address:
|
||||
resp = self.call(proto.VerifyMessage(address=address, signature=signature, message=message))
|
||||
@ -547,7 +547,7 @@ class ProtocolMixin(object):
|
||||
|
||||
@field('value')
|
||||
@expect(proto.CipheredKeyValue)
|
||||
def encrypt_keyvalue(self, n, key, value, ask_on_encrypt=True, ask_on_decrypt=True, iv=None):
|
||||
def encrypt_keyvalue(self, n, key, value, ask_on_encrypt=True, ask_on_decrypt=True, iv=b''):
|
||||
n = self._convert_prime(n)
|
||||
return self.call(proto.CipherKeyValue(address_n=n,
|
||||
key=key,
|
||||
@ -555,11 +555,11 @@ class ProtocolMixin(object):
|
||||
encrypt=True,
|
||||
ask_on_encrypt=ask_on_encrypt,
|
||||
ask_on_decrypt=ask_on_decrypt,
|
||||
iv=iv if iv is not None else ''))
|
||||
iv=iv))
|
||||
|
||||
@field('value')
|
||||
@expect(proto.CipheredKeyValue)
|
||||
def decrypt_keyvalue(self, n, key, value, ask_on_encrypt=True, ask_on_decrypt=True, iv=None):
|
||||
def decrypt_keyvalue(self, n, key, value, ask_on_encrypt=True, ask_on_decrypt=True, iv=b''):
|
||||
n = self._convert_prime(n)
|
||||
return self.call(proto.CipherKeyValue(address_n=n,
|
||||
key=key,
|
||||
@ -567,7 +567,7 @@ class ProtocolMixin(object):
|
||||
encrypt=False,
|
||||
ask_on_encrypt=ask_on_encrypt,
|
||||
ask_on_decrypt=ask_on_decrypt,
|
||||
iv=iv if iv is not None else ''))
|
||||
iv=iv))
|
||||
|
||||
@field('tx_size')
|
||||
@expect(proto.TxSize)
|
||||
@ -608,7 +608,7 @@ class ProtocolMixin(object):
|
||||
tx.outputs.extend(outputs)
|
||||
|
||||
txes = {}
|
||||
txes[''] = tx
|
||||
txes[b''] = tx
|
||||
|
||||
known_hashes = []
|
||||
for inp in inputs:
|
||||
@ -640,7 +640,7 @@ class ProtocolMixin(object):
|
||||
|
||||
# Prepare structure for signatures
|
||||
signatures = [None] * len(inputs)
|
||||
serialized_tx = ''
|
||||
serialized_tx = b''
|
||||
|
||||
counter = 0
|
||||
while True:
|
||||
@ -759,7 +759,7 @@ class ProtocolMixin(object):
|
||||
raise Exception("Invalid response, expected EntropyRequest")
|
||||
|
||||
external_entropy = self._get_local_entropy()
|
||||
log("Computer generated entropy: " + binascii.hexlify(external_entropy))
|
||||
log("Computer generated entropy: " + binascii.hexlify(external_entropy).decode('ascii'))
|
||||
ret = self.call(proto.EntropyAck(entropy=external_entropy))
|
||||
self.init_device()
|
||||
return ret
|
||||
@ -803,10 +803,10 @@ class ProtocolMixin(object):
|
||||
node = types.HDNodeType()
|
||||
data = binascii.hexlify(tools.b58decode(xprv, None))
|
||||
|
||||
if data[90:92] != '00':
|
||||
if data[90:92] != b'00':
|
||||
raise Exception("Contain invalid private key")
|
||||
|
||||
checksum = hashlib.sha256(hashlib.sha256(binascii.unhexlify(data[:156])).digest()).hexdigest()[:8]
|
||||
checksum = binascii.hexlify(hashlib.sha256(hashlib.sha256(binascii.unhexlify(data[:156])).digest()).digest()[:4])
|
||||
if checksum != data[156:]:
|
||||
raise Exception("Checksum doesn't match")
|
||||
|
||||
@ -821,8 +821,8 @@ class ProtocolMixin(object):
|
||||
node.depth = int(data[8:10], 16)
|
||||
node.fingerprint = int(data[10:18], 16)
|
||||
node.child_num = int(data[18:26], 16)
|
||||
node.chain_code = data[26:90].decode('hex')
|
||||
node.private_key = data[92:156].decode('hex') # skip 0x00 indicating privkey
|
||||
node.chain_code = binascii.unhexlify(data[26:90])
|
||||
node.private_key = binascii.unhexlify(data[92:156]) # skip 0x00 indicating privkey
|
||||
|
||||
resp = self.call(proto.LoadDevice(node=node,
|
||||
pin=pin,
|
||||
|
@ -1,7 +1,17 @@
|
||||
import hashlib
|
||||
import binascii
|
||||
import struct
|
||||
import sys
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def byteindex(data, index):
|
||||
return ord(data[index])
|
||||
def iterbytes(data):
|
||||
return (ord (char) for char in data)
|
||||
else:
|
||||
byteindex = lambda data, index: data[index]
|
||||
iterbytes = iter
|
||||
|
||||
Hash = lambda x: hashlib.sha256(hashlib.sha256(x).digest()).digest()
|
||||
|
||||
def hash_160(public_key):
|
||||
@ -11,14 +21,14 @@ def hash_160(public_key):
|
||||
|
||||
|
||||
def hash_160_to_bc_address(h160, address_type):
|
||||
vh160 = chr(address_type) + h160
|
||||
vh160 = struct.pack('<B', address_type) + h160
|
||||
h = Hash(vh160)
|
||||
addr = vh160 + h[0:4]
|
||||
return b58encode(addr)
|
||||
|
||||
def compress_pubkey(public_key):
|
||||
if public_key[0] == '\x04':
|
||||
return chr((ord(public_key[64]) & 1) + 2) + public_key[1:33]
|
||||
if byteindex(public_key, 0) == 4:
|
||||
return bytes((byteindex(public_key, 64) & 1) + 2) + public_key[1:33]
|
||||
raise Exception("Pubkey is already compressed")
|
||||
|
||||
def public_key_to_bc_address(public_key, address_type, compress=True):
|
||||
@ -35,8 +45,8 @@ def b58encode(v):
|
||||
""" encode v, which is a string of bytes, to base58."""
|
||||
|
||||
long_value = 0
|
||||
for (i, c) in enumerate(v[::-1]):
|
||||
long_value += (256 ** i) * ord(c)
|
||||
for c in iterbytes(v):
|
||||
long_value = long_value * 256 + c
|
||||
|
||||
result = ''
|
||||
while long_value >= __b58base:
|
||||
@ -48,8 +58,8 @@ def b58encode(v):
|
||||
# Bitcoin does a little leading-zero-compression:
|
||||
# leading 0-bytes in the input become leading-1s
|
||||
nPad = 0
|
||||
for c in v:
|
||||
if c == '\0':
|
||||
for c in iterbytes(v):
|
||||
if c == 0:
|
||||
nPad += 1
|
||||
else:
|
||||
break
|
||||
@ -62,12 +72,12 @@ def b58decode(v, length):
|
||||
for (i, c) in enumerate(v[::-1]):
|
||||
long_value += __b58chars.find(c) * (__b58base ** i)
|
||||
|
||||
result = ''
|
||||
result = b''
|
||||
while long_value >= 256:
|
||||
div, mod = divmod(long_value, 256)
|
||||
result = chr(mod) + result
|
||||
result = struct.pack('B', mod) + result
|
||||
long_value = div
|
||||
result = chr(long_value) + result
|
||||
result = struct.pack('B', long_value) + result
|
||||
|
||||
nPad = 0
|
||||
for c in v:
|
||||
@ -76,14 +86,11 @@ def b58decode(v, length):
|
||||
else:
|
||||
break
|
||||
|
||||
result = chr(0) * nPad + result
|
||||
result = b'\x00' * nPad + result
|
||||
if length is not None and len(result) != length:
|
||||
return None
|
||||
|
||||
if sys.version_info[0] < 3:
|
||||
return result
|
||||
else:
|
||||
return str.encode(result)
|
||||
return result
|
||||
|
||||
def monkeypatch_google_protobuf_text_format():
|
||||
# monkeypatching: text formatting of protobuf messages
|
||||
|
@ -24,7 +24,7 @@ def insight_tx(url, rawdata=False):
|
||||
for vin in data['vin']:
|
||||
i = t.inputs.add()
|
||||
if 'coinbase' in vin.keys():
|
||||
i.prev_hash = "\0"*32
|
||||
i.prev_hash = b"\0"*32
|
||||
i.prev_index = 0xffffffff # signed int -1
|
||||
i.script_sig = binascii.unhexlify(vin['coinbase'])
|
||||
i.sequence = vin['sequence']
|
||||
@ -57,7 +57,7 @@ def smartbit_tx(url, rawdata=False):
|
||||
for vin in data['inputs']:
|
||||
i = t.inputs.add()
|
||||
if 'coinbase' in vin.keys():
|
||||
i.prev_hash = "\0"*32
|
||||
i.prev_hash = b"\0"*32
|
||||
i.prev_index = 0xffffffff # signed int -1
|
||||
i.script_sig = binascii.unhexlify(vin['coinbase'])
|
||||
i.sequence = vin['sequence']
|
||||
@ -79,7 +79,7 @@ class TXAPIBitcoin(object):
|
||||
|
||||
# @filecache(DAY)
|
||||
def get_tx(self, txhash):
|
||||
url = 'https://insight.bitpay.com/api/tx/%s' % txhash
|
||||
url = 'https://insight.bitpay.com/api/tx/%s' % txhash.decode('ascii')
|
||||
return insight_tx(url)
|
||||
|
||||
|
||||
@ -87,12 +87,12 @@ class TXAPITestnet(object):
|
||||
|
||||
# @filecache(DAY)
|
||||
def get_tx(self, txhash):
|
||||
url = 'https://test-insight.bitpay.com/api/tx/%s' % txhash
|
||||
url = 'https://test-insight.bitpay.com/api/tx/%s' % txhash.decode('ascii')
|
||||
return insight_tx(url)
|
||||
|
||||
class TXAPISegnet(object):
|
||||
|
||||
# @filecache(DAY)
|
||||
def get_tx(self, txhash):
|
||||
url = 'https://segnet-api.smartbit.com.au/v1/blockchain/tx/%s' % txhash
|
||||
url = 'https://segnet-api.smartbit.com.au/v1/blockchain/tx/%s' % txhash.decode('ascii')
|
||||
return smartbit_tx(url)
|
||||
|
Loading…
Reference in New Issue
Block a user