1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-27 00:28:10 +00:00

src/apps/wallet/sign_tx: fix last commit, add bip115 test

This commit is contained in:
Pavol Rusnak 2018-07-04 18:08:05 +02:00
parent 622eb001a6
commit 2ee57da5d8
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 22 additions and 2 deletions

View File

@ -1,7 +1,7 @@
from trezor.crypto.hashlib import ripemd160, sha256 from trezor.crypto.hashlib import ripemd160, sha256
from trezor.messages.MultisigRedeemScriptType import MultisigRedeemScriptType from trezor.messages.MultisigRedeemScriptType import MultisigRedeemScriptType
from apps.wallet.sign_tx.multisig import multisig_get_pubkeys from apps.wallet.sign_tx.multisig import multisig_get_pubkeys
from apps.wallet.sign_tx.writers import bytearray_with_cap, write_bytes, write_varint, write_op_push from apps.wallet.sign_tx.writers import bytearray_with_cap, write_bytes, write_varint, write_op_push, write_scriptnum
class ScriptsError(ValueError): class ScriptsError(ValueError):

View File

@ -85,7 +85,7 @@ def write_scriptnum(w, n: int):
w.append(n & 0xFF) w.append(n & 0xFF)
w.append((n >> 8) & 0xFF) w.append((n >> 8) & 0xFF)
w.append((n >> 16) & 0xFF) w.append((n >> 16) & 0xFF)
elif: else:
w.append(4) w.append(4)
w.append(n & 0xFF) w.append(n & 0xFF)
w.append((n >> 8) & 0xFF) w.append((n >> 8) & 0xFF)

View File

@ -0,0 +1,20 @@
from common import *
from apps.wallet.sign_tx.scripts import script_replay_protection_bip115
class TestSigntxScripts(unittest.TestCase):
# pylint: disable=C0301
def test_script_replay_protection_bip115(self):
vectors=[
('206ec9b310745775c20cbe5bae8751daeb7f086cf913399d4f7634ef2a0000000003122005b4', '6ec9b310745775c20cbe5bae8751daeb7f086cf913399d4f7634ef2a00000000', 335890),
('20caaa71b60cf893c1604b38e5af1bdc322dbb31818239088647272d1400000000030e2005b4', 'caaa71b60cf893c1604b38e5af1bdc322dbb31818239088647272d1400000000', 335886),
]
for out, hsh, height in vectors:
hsh = unhexlify(hsh)
res = hexlify(script_replay_protection_bip115(hsh, height)).decode()
self.assertEqual(out, res)
if __name__ == '__main__':
unittest.main()