From b0739df2e548b3c1abe9f68da0323a6f137445e8 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Thu, 2 Feb 2012 18:21:28 +0100 Subject: [PATCH] Expose hashTransactionForSignature. The API will likely change in future. --- src/com/google/bitcoin/core/Transaction.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/com/google/bitcoin/core/Transaction.java b/src/com/google/bitcoin/core/Transaction.java index eab82a2d..32e2324a 100644 --- a/src/com/google/bitcoin/core/Transaction.java +++ b/src/com/google/bitcoin/core/Transaction.java @@ -628,7 +628,17 @@ public class Transaction extends ChildMessage implements Serializable { // Every input is now complete. } - private byte[] hashTransactionForSignature(SigHash type, boolean anyoneCanPay) { + /** + * Calculates a signature hash, that is, a hash of a simplified form of the transaction. How exactly the transaction + * is simplified is specified by the type and anyoneCanPay parameters.

+ * + * You don't normally ever need to call this yourself. It will become more useful in future as the contracts + * features of Bitcoin are developed. + * + * @param type Should be SigHash.ALL + * @param anyoneCanPay should be false. + */ + public byte[] hashTransactionForSignature(SigHash type, boolean anyoneCanPay) { try { ByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(length == UNKNOWN_LENGTH ? 256 : length + 4); bitcoinSerialize(bos);