private byte[] HashTransactionForSignature(SigHash type, bool anyoneCanPay)
{
using (var bos = new MemoryStream())
{
BitcoinSerializeToStream(bos);
// We also have to write a hash type.
var hashType = (uint) type + 1;
if (anyoneCanPay)
hashType |= 0x80;
Utils.Uint32ToByteStreamLe(hashType, bos);
// 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.
return Utils.DoubleDigest(bos.ToArray());
}
}