1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-17 19:00:58 +00:00

feat(core): Support no_script_type option in SignMessage.

This commit is contained in:
Andrew Kozlik 2021-11-05 18:00:35 +01:00 committed by Andrew Kozlik
parent c2f1850abb
commit bc4a56b2c0
2 changed files with 8 additions and 3 deletions

View File

@ -0,0 +1 @@
Support no_script_type option in SignMessage.

View File

@ -36,12 +36,16 @@ async def sign_message(
signature = secp256k1.sign(seckey, digest)
if script_type == InputScriptType.SPENDADDRESS:
pass
script_type_info = 0
elif script_type == InputScriptType.SPENDP2SHWITNESS:
signature = bytes([signature[0] + 4]) + signature[1:]
script_type_info = 4
elif script_type == InputScriptType.SPENDWITNESS:
signature = bytes([signature[0] + 8]) + signature[1:]
script_type_info = 8
else:
raise wire.ProcessError("Unsupported script type")
# Add script type information to the recovery byte.
if script_type_info != 0 and not msg.no_script_type:
signature = bytes([signature[0] + script_type_info]) + signature[1:]
return MessageSignature(address=address, signature=signature)