From e6d693d18accf91d10ec2cec2b4c2c6b1257b59e Mon Sep 17 00:00:00 2001 From: Tomas Susanka Date: Fri, 9 Feb 2018 13:21:22 +0100 Subject: [PATCH] signing: forgotten sig hash --- src/apps/wallet/sign_tx/scripts.py | 8 +++----- src/apps/wallet/sign_tx/signing.py | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/apps/wallet/sign_tx/scripts.py b/src/apps/wallet/sign_tx/scripts.py index 0034e11b78..751605eb43 100644 --- a/src/apps/wallet/sign_tx/scripts.py +++ b/src/apps/wallet/sign_tx/scripts.py @@ -1,6 +1,4 @@ -from apps.wallet.sign_tx.multisig import * from apps.wallet.sign_tx.writers import * -from apps.common.hash_writer import HashWriter from trezor.crypto.hashlib import sha256, ripemd160 @@ -102,7 +100,7 @@ def input_script_p2wpkh_in_p2sh(pubkeyhash: bytes) -> bytearray: # =============== Multisig =============== -def input_script_multisig(current_signature, other_signatures, pubkeys, m: int): +def input_script_multisig(current_signature, other_signatures, pubkeys, m: int, sighash: int): w = bytearray() # starts with OP_FALSE because of an old OP_CHECKMULTISIG bug, # which consumes one additional item on the stack @@ -110,9 +108,9 @@ def input_script_multisig(current_signature, other_signatures, pubkeys, m: int): w.append(0x00) for s in other_signatures: if len(s): - append_signature(w, s) + append_signature(w, s, sighash) - append_signature(w, current_signature) + append_signature(w, current_signature, sighash) # redeem script redeem_script = script_multisig(pubkeys, m) diff --git a/src/apps/wallet/sign_tx/signing.py b/src/apps/wallet/sign_tx/signing.py index 769296ca2d..71e67a783b 100644 --- a/src/apps/wallet/sign_tx/signing.py +++ b/src/apps/wallet/sign_tx/signing.py @@ -512,7 +512,8 @@ def input_derive_script(coin: CoinType, i: TxInputType, pubkey: bytes, signature return input_script_native_p2wpkh_or_p2wsh() # mutlisig elif i.script_type == InputScriptType.SPENDMULTISIG: - return input_script_multisig(signature, i.multisig.signatures, multisig_get_pubkeys(i.multisig), i.multisig.m) + return input_script_multisig(signature, i.multisig.signatures, multisig_get_pubkeys(i.multisig), i.multisig.m, + get_hash_type(coin)) else: raise SigningError(FailureType.ProcessError, 'Invalid script type')