Java Code Examples for org.bitcoinj.crypto.TransactionSignature#calcSigHashValue()

The following examples show how to use org.bitcoinj.crypto.TransactionSignature#calcSigHashValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Transaction.java    From bcm-android with GNU General Public License v3.0 2 votes vote down vote up
/**
 * <p>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.</p>
 * <p>
 * <p>This is a low level API and when using the regular {@link Wallet} class you don't have to call this yourself.
 * When working with more complex transaction types and contracts, it can be necessary. When signing a P2SH output
 * the redeemScript should be the script encoded into the scriptSig field, for normal transactions, it's the
 * scriptPubKey of the output you're signing for.</p>
 *
 * @param inputIndex   input the signature is being calculated for. Tx signatures are always relative to an input.
 * @param redeemScript the bytes that should be in the given input during signing.
 * @param type         Should be SigHash.ALL
 * @param anyoneCanPay should be false.
 */
public Sha256Hash hashForSignature(int inputIndex, byte[] redeemScript,
                                   SigHash type, boolean anyoneCanPay) {
    byte sigHashType = (byte) TransactionSignature.calcSigHashValue(type, anyoneCanPay);
    return hashForSignature(inputIndex, redeemScript, sigHashType);
}
 
Example 2
Source File: Transaction.java    From bcm-android with GNU General Public License v3.0 2 votes vote down vote up
/**
 * <p>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.</p>
 * <p>
 * <p>This is a low level API and when using the regular {@link Wallet} class you don't have to call this yourself.
 * When working with more complex transaction types and contracts, it can be necessary. When signing a P2SH output
 * the redeemScript should be the script encoded into the scriptSig field, for normal transactions, it's the
 * scriptPubKey of the output you're signing for.</p>
 *
 * @param inputIndex   input the signature is being calculated for. Tx signatures are always relative to an input.
 * @param redeemScript the script that should be in the given input during signing.
 * @param type         Should be SigHash.ALL
 * @param anyoneCanPay should be false.
 */
public Sha256Hash hashForSignature(int inputIndex, Script redeemScript,
                                   SigHash type, boolean anyoneCanPay) {
    int sigHash = TransactionSignature.calcSigHashValue(type, anyoneCanPay);
    return hashForSignature(inputIndex, redeemScript.getProgram(), (byte) sigHash);
}
 
Example 3
Source File: Transaction.java    From green_android with GNU General Public License v3.0 2 votes vote down vote up
/**
 * <p>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.</p>
 *
 * <p>This is a low level API and when using the regular {@link Wallet} class you don't have to call this yourself.
 * When working with more complex transaction types and contracts, it can be necessary. When signing a P2SH output
 * the redeemScript should be the script encoded into the scriptSig field, for normal transactions, it's the
 * scriptPubKey of the output you're signing for.</p>
 *
 * @param inputIndex input the signature is being calculated for. Tx signatures are always relative to an input.
 * @param redeemScript the bytes that should be in the given input during signing.
 * @param type Should be SigHash.ALL
 * @param anyoneCanPay should be false.
 */
public Sha256Hash hashForSignature(int inputIndex, byte[] redeemScript,
                                                SigHash type, boolean anyoneCanPay) {
    byte sigHashType = (byte) TransactionSignature.calcSigHashValue(type, anyoneCanPay);
    return hashForSignature(inputIndex, redeemScript, sigHashType);
}
 
Example 4
Source File: Transaction.java    From green_android with GNU General Public License v3.0 2 votes vote down vote up
/**
 * <p>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.</p>
 *
 * <p>This is a low level API and when using the regular {@link Wallet} class you don't have to call this yourself.
 * When working with more complex transaction types and contracts, it can be necessary. When signing a P2SH output
 * the redeemScript should be the script encoded into the scriptSig field, for normal transactions, it's the
 * scriptPubKey of the output you're signing for.</p>
 *
 * @param inputIndex input the signature is being calculated for. Tx signatures are always relative to an input.
 * @param redeemScript the script that should be in the given input during signing.
 * @param type Should be SigHash.ALL
 * @param anyoneCanPay should be false.
 */
public Sha256Hash hashForSignature(int inputIndex, Script redeemScript,
                                                SigHash type, boolean anyoneCanPay) {
    int sigHash = TransactionSignature.calcSigHashValue(type, anyoneCanPay);
    return hashForSignature(inputIndex, redeemScript.getProgram(), (byte) sigHash);
}
 
Example 5
Source File: Transaction.java    From GreenBits with GNU General Public License v3.0 2 votes vote down vote up
/**
 * <p>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.</p>
 *
 * <p>This is a low level API and when using the regular {@link Wallet} class you don't have to call this yourself.
 * When working with more complex transaction types and contracts, it can be necessary. When signing a P2SH output
 * the redeemScript should be the script encoded into the scriptSig field, for normal transactions, it's the
 * scriptPubKey of the output you're signing for.</p>
 *
 * @param inputIndex input the signature is being calculated for. Tx signatures are always relative to an input.
 * @param redeemScript the bytes that should be in the given input during signing.
 * @param type Should be SigHash.ALL
 * @param anyoneCanPay should be false.
 */
public Sha256Hash hashForSignature(int inputIndex, byte[] redeemScript,
                                                SigHash type, boolean anyoneCanPay) {
    byte sigHashType = (byte) TransactionSignature.calcSigHashValue(type, anyoneCanPay);
    return hashForSignature(inputIndex, redeemScript, sigHashType);
}
 
Example 6
Source File: Transaction.java    From GreenBits with GNU General Public License v3.0 2 votes vote down vote up
/**
 * <p>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.</p>
 *
 * <p>This is a low level API and when using the regular {@link Wallet} class you don't have to call this yourself.
 * When working with more complex transaction types and contracts, it can be necessary. When signing a P2SH output
 * the redeemScript should be the script encoded into the scriptSig field, for normal transactions, it's the
 * scriptPubKey of the output you're signing for.</p>
 *
 * @param inputIndex input the signature is being calculated for. Tx signatures are always relative to an input.
 * @param redeemScript the script that should be in the given input during signing.
 * @param type Should be SigHash.ALL
 * @param anyoneCanPay should be false.
 */
public Sha256Hash hashForSignature(int inputIndex, Script redeemScript,
                                                SigHash type, boolean anyoneCanPay) {
    int sigHash = TransactionSignature.calcSigHashValue(type, anyoneCanPay);
    return hashForSignature(inputIndex, redeemScript.getProgram(), (byte) sigHash);
}