Enum SignatureHashType

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<SignatureHashType>

    public enum SignatureHashType
    extends java.lang.Enum<SignatureHashType>
    In case of an OPCODE of type OP_CHECKSIG in the pubkey script of a transaction, this option determines what parts of the transactions the signers want to sign (and therefore not allow others to modify afterwards)

    Descriptions of the fields are courtesy of the Bitcoin Core Documentation
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      ALL
      The default, signs all the inputs and outputs, protecting everything except the signature scripts against modification
      ALL_ANYONECANPAY
      Signs all of the outputs but only this one input, and it also allows anyone to add or remove other inputs, so anyone can contribute additional satoshis but they cannot change how many satoshis are sent nor where they go
      NONE
      Signs all of the inputs but none of the outputs, allowing anyone to change where the satoshis are going unless other signatures using other signature hash flags protect the outputs.
      NONE_ANYONECANPAY
      Signs only this one input and allows anyone to add or remove other inputs or outputs, so anyone who gets a copy of this input can spend it however they’d like
      SINGLE
      The only output signed is the one corresponding to this input (the output with the same output index number as this input), ensuring nobody can change your part of the transaction but allowing other signers to change their part of the transaction.
      SINGLE_ANYONECANPAY
      Signs this one input and its corresponding output.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String toString()  
      static SignatureHashType valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static SignatureHashType[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • ALL

        public static final SignatureHashType ALL
        The default, signs all the inputs and outputs, protecting everything except the signature scripts against modification
      • NONE

        public static final SignatureHashType NONE
        Signs all of the inputs but none of the outputs, allowing anyone to change where the satoshis are going unless other signatures using other signature hash flags protect the outputs.
      • SINGLE

        public static final SignatureHashType SINGLE
        The only output signed is the one corresponding to this input (the output with the same output index number as this input), ensuring nobody can change your part of the transaction but allowing other signers to change their part of the transaction. The corresponding output must exist or the value “1” will be signed, breaking the security scheme. This input, as well as other inputs, are included in the signature. The sequence numbers of other inputs are not included in the signature, and can be updated.
      • ALL_ANYONECANPAY

        public static final SignatureHashType ALL_ANYONECANPAY
        Signs all of the outputs but only this one input, and it also allows anyone to add or remove other inputs, so anyone can contribute additional satoshis but they cannot change how many satoshis are sent nor where they go
      • NONE_ANYONECANPAY

        public static final SignatureHashType NONE_ANYONECANPAY
        Signs only this one input and allows anyone to add or remove other inputs or outputs, so anyone who gets a copy of this input can spend it however they’d like
      • SINGLE_ANYONECANPAY

        public static final SignatureHashType SINGLE_ANYONECANPAY
        Signs this one input and its corresponding output. Allows anyone to add or remove other inputs
    • Method Detail

      • values

        public static SignatureHashType[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (SignatureHashType c : SignatureHashType.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static SignatureHashType valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Enum<SignatureHashType>