From 40bf2c5d2e0cca2c34544e2aadc4ef1780b8506e Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Tue, 11 Jun 2019 15:34:58 +0300 Subject: [PATCH] core: ensure pubkeyhash/scripthash have the correct length (#220) --- core/src/apps/wallet/sign_tx/scripts.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/apps/wallet/sign_tx/scripts.py b/core/src/apps/wallet/sign_tx/scripts.py index e7e303a629..8876cc60b6 100644 --- a/core/src/apps/wallet/sign_tx/scripts.py +++ b/core/src/apps/wallet/sign_tx/scripts.py @@ -31,6 +31,7 @@ def input_script_p2pkh_or_p2sh( def output_script_p2pkh(pubkeyhash: bytes) -> bytearray: + ensure(len(pubkeyhash) == 20) s = bytearray(25) s[0] = 0x76 # OP_DUP s[1] = 0xA9 # OP_HASH_160 @@ -43,7 +44,7 @@ def output_script_p2pkh(pubkeyhash: bytes) -> bytearray: def output_script_p2sh(scripthash: bytes) -> bytearray: # A9 14 87 - + ensure(len(scripthash) == 20) s = bytearray(23) s[0] = 0xA9 # OP_HASH_160 s[1] = 0x14 # pushing 20 bytes