mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-24 15:28:10 +00:00
core: ensure correct pubkeyhash/witprog length in scripts.py (#254)
This commit is contained in:
parent
e3e2811f7a
commit
6fb76f95d1
@ -88,6 +88,7 @@ def output_script_native_p2wpkh_or_p2wsh(witprog: bytes) -> bytearray:
|
|||||||
# Either:
|
# Either:
|
||||||
# 00 14 <20-byte-key-hash>
|
# 00 14 <20-byte-key-hash>
|
||||||
# 00 20 <32-byte-script-hash>
|
# 00 20 <32-byte-script-hash>
|
||||||
|
ensure(len(witprog) == 20 or len(witprog) == 32)
|
||||||
|
|
||||||
w = empty_bytearray(3 + len(witprog))
|
w = empty_bytearray(3 + len(witprog))
|
||||||
w.append(0x00) # witness version byte
|
w.append(0x00) # witness version byte
|
||||||
@ -107,6 +108,7 @@ def output_script_native_p2wpkh_or_p2wsh(witprog: bytes) -> bytearray:
|
|||||||
def input_script_p2wpkh_in_p2sh(pubkeyhash: bytes) -> bytearray:
|
def input_script_p2wpkh_in_p2sh(pubkeyhash: bytes) -> bytearray:
|
||||||
# 16 00 14 <pubkeyhash>
|
# 16 00 14 <pubkeyhash>
|
||||||
# Signature is moved to the witness.
|
# Signature is moved to the witness.
|
||||||
|
ensure(len(pubkeyhash) == 20)
|
||||||
|
|
||||||
w = empty_bytearray(3 + len(pubkeyhash))
|
w = empty_bytearray(3 + len(pubkeyhash))
|
||||||
w.append(0x16) # length of the data
|
w.append(0x16) # length of the data
|
||||||
|
Loading…
Reference in New Issue
Block a user