Class ScriptChunk


  • public class ScriptChunk
    extends java.lang.Object
    A script element that is either a data push (signature, pubkey, etc) or a non-push (logic, numeric, etc) operation.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      byte[] data
      For push operations, this is the vector to be pushed on the stack.
      int opcode
      Operation to be executed.
    • Constructor Summary

      Constructors 
      Constructor Description
      ScriptChunk​(int opcode, byte[] data)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int decodeOpN()
      If this chunk is an OP_N opcode returns the equivalent integer value.
      boolean equals​(java.lang.Object o)  
      boolean equalsOpCode​(int opcode)  
      int hashCode()  
      boolean isOpCode()
      If this chunk is a single byte of non-pushdata content (could be OP_RESERVED or some invalid Opcode)
      boolean isPushData()
      Returns true if this chunk is pushdata content, including the single-byte pushdatas.
      boolean isShortestPossiblePushData()
      Called on a pushdata chunk, returns true if it uses the smallest possible way (according to BIP62) to push the data.
      int size()  
      byte[] toByteArray()  
      java.lang.String toString()  
      void write​(java.io.OutputStream stream)  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • opcode

        public final int opcode
        Operation to be executed. Opcodes are defined in ScriptOpCodes.
      • data

        @Nullable
        public final byte[] data
        For push operations, this is the vector to be pushed on the stack. For ScriptOpCodes.OP_0, the vector is empty. Null for non-push operations.
    • Constructor Detail

      • ScriptChunk

        public ScriptChunk​(int opcode,
                           @Nullable
                           byte[] data)
    • Method Detail

      • equalsOpCode

        public boolean equalsOpCode​(int opcode)
      • isOpCode

        public boolean isOpCode()
        If this chunk is a single byte of non-pushdata content (could be OP_RESERVED or some invalid Opcode)
      • isPushData

        public boolean isPushData()
        Returns true if this chunk is pushdata content, including the single-byte pushdatas.
      • decodeOpN

        public int decodeOpN()
        If this chunk is an OP_N opcode returns the equivalent integer value.
      • isShortestPossiblePushData

        public boolean isShortestPossiblePushData()
        Called on a pushdata chunk, returns true if it uses the smallest possible way (according to BIP62) to push the data.
      • write

        public void write​(java.io.OutputStream stream)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • toByteArray

        public byte[] toByteArray()
      • size

        public int size()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object