Class Block


  • public class Block
    extends Object

    Block class.

    • Field Detail

      • GENESIS_BLOCK

        public static final Int GENESIS_BLOCK
        Constant GENESIS_BLOCK
      • TESTNET_GENESIS_BLOCK

        public static final Int TESTNET_GENESIS_BLOCK
        Constant TESTNET_GENESIS_BLOCK
      • LOWEST_BITS

        public static final Int LOWEST_BITS
        Constant LOWEST_BITS
    • Constructor Detail

      • Block

        public Block​(Int version,
                     byte[] prevBlock,
                     byte[] merkleRoot,
                     Int timestamp,
                     byte[] bits,
                     byte[] nonce)

        Constructor for Block.

        Parameters:
        version - a Int object
        prevBlock - an array of byte objects
        merkleRoot - an array of byte objects
        timestamp - a Int object
        bits - an array of byte objects
        nonce - an array of byte objects
    • Method Detail

      • serialize

        public byte[] serialize()
        Returns the 80 byte block header
        Returns:
        an array of byte objects
      • hash

        public byte[] hash()
        Returns the hash256 interpreted little endian of the block
        Returns:
        an array of byte objects
      • isBip9

        public boolean isBip9()
        Returns whether this block is signaling readiness for BIP9
        Returns:
        a boolean
      • isBip91

        public boolean isBip91()
        Returns whether this block is signaling readiness for BIP91
        Returns:
        a boolean
      • isBip141

        public boolean isBip141()
        Returns whether this block is signaling readiness for BIP141
        Returns:
        a boolean
      • target

        public Int target()
        Returns the proof-of-work target based on the bits
        Returns:
        a Int object
      • difficulty

        public Int difficulty()
        Returns the block difficulty based on the bits
        Returns:
        a Int object
      • proof

        public Int proof()

        proof.

        Returns:
        a Int object
      • checkPow

        public boolean checkPow()
        Returns whether this block satisfies proof of work
        Returns:
        a boolean
      • validateMerkleRoot

        public boolean validateMerkleRoot()
        Gets the merkle root of the tx_hashes and checks that it's the same as the merkle root of this block.
        Returns:
        a boolean
      • getVersion

        public Int getVersion()

        Getter for the field version.

        Returns:
        a Int object
      • getTimestamp

        public Int getTimestamp()

        Getter for the field timestamp.

        Returns:
        a Int object
      • getPrevBlock

        public byte[] getPrevBlock()

        Getter for the field prevBlock.

        Returns:
        an array of byte objects
      • getMerkleRoot

        public byte[] getMerkleRoot()

        Getter for the field merkleRoot.

        Returns:
        an array of byte objects
      • getBits

        public byte[] getBits()

        Getter for the field bits.

        Returns:
        an array of byte objects
      • getNonce

        public byte[] getNonce()

        Getter for the field nonce.

        Returns:
        an array of byte objects
      • setTxHashes

        public void setTxHashes​(List<byte[]> txHashes)

        Setter for the field txHashes.

        Parameters:
        txHashes - a List object