3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-30 23:02:15 +00:00

Fix #292 by &'ing sigHashType to treat it as unsigned.

This commit is contained in:
Matt Corallo 2013-01-27 02:09:17 -05:00
parent 3211fe59f3
commit 38d01e14a6

View File

@ -869,8 +869,8 @@ public class Transaction extends ChildMessage implements Serializable {
ByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(length == UNKNOWN_LENGTH ? 256 : length + 4); ByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(length == UNKNOWN_LENGTH ? 256 : length + 4);
bitcoinSerialize(bos); bitcoinSerialize(bos);
// We also have to write a hash type. // We also have to write a hash type (sigHashType is actually an unsigned char)
uint32ToByteStreamLE(sigHashType, bos); uint32ToByteStreamLE(0x000000ff & sigHashType, bos);
// Note that this is NOT reversed to ensure it will be signed correctly. If it were to be printed out // Note that this is NOT reversed to ensure it will be signed correctly. If it were to be printed out
// however then we would expect that it is IS reversed. // however then we would expect that it is IS reversed.
Sha256Hash hash = new Sha256Hash(doubleDigest(bos.toByteArray())); Sha256Hash hash = new Sha256Hash(doubleDigest(bos.toByteArray()));