Skip to content

Commit b8ff69f

Browse files
author
Jeff Garzik
committed
Merge pull request jgarzik#14 from petertodd/signaturehash-returns-one-fix
Make SignatureHash() return 1 correctly; bug-for-bug
2 parents 72b01bb + 1dab0cb commit b8ff69f

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

bitcoin/scripteval.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
def SignatureHash(script, txTo, inIdx, hashtype):
2323
if inIdx >= len(txTo.vin):
24-
return (0, "inIdx %d out of range (%d)" % (inIdx, len(txTo.vin)))
24+
return (1, "inIdx %d out of range (%d)" % (inIdx, len(txTo.vin)))
2525
txtmp = CTransaction()
2626
txtmp.copy(txTo)
2727

@@ -39,7 +39,7 @@ def SignatureHash(script, txTo, inIdx, hashtype):
3939
elif (hashtype & 0x1f) == SIGHASH_SINGLE:
4040
outIdx = inIdx
4141
if outIdx >= len(txtmp.vout):
42-
return (0, "outIdx %d out of range (%d)" % (outIdx, len(txtmp.vout)))
42+
return (1, "outIdx %d out of range (%d)" % (outIdx, len(txtmp.vout)))
4343

4444
tmp = txtmp.vout[outIdx]
4545
txtmp.vout = []
@@ -76,8 +76,6 @@ def CheckSig(sig, pubkey, script, txTo, inIdx, hashtype):
7676
sig = sig[:-1]
7777

7878
tup = SignatureHash(script, txTo, inIdx, hashtype)
79-
if tup[0] == 0:
80-
return False
8179
return key.verify(ser_uint256(tup[0]), sig)
8280

8381
def CheckMultiSig(opcode, script, stack, txTo, inIdx, hashtype):

0 commit comments

Comments
 (0)