Package ch.bitagent.bitcoin.lib.block
Class Block
- java.lang.Object
-
- ch.bitagent.bitcoin.lib.block.Block
-
public class Block extends Object
Block class.
-
-
Field Summary
Fields Modifier and Type Field Description static IntGENESIS_BLOCKConstantGENESIS_BLOCKstatic IntLOWEST_BITSConstantLOWEST_BITSstatic IntTESTNET_GENESIS_BLOCKConstantTESTNET_GENESIS_BLOCK
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckPow()Returns whether this block satisfies proof of workIntdifficulty()Returns the block difficulty based on the bitsbyte[]getBits()Getter for the fieldbits.byte[]getMerkleRoot()Getter for the fieldmerkleRoot.byte[]getNonce()Getter for the fieldnonce.byte[]getPrevBlock()Getter for the fieldprevBlock.IntgetTimestamp()Getter for the fieldtimestamp.IntgetVersion()Getter for the fieldversion.byte[]hash()Returns the hash256 interpreted little endian of the blockbooleanisBip141()Returns whether this block is signaling readiness for BIP141booleanisBip9()Returns whether this block is signaling readiness for BIP9booleanisBip91()Returns whether this block is signaling readiness for BIP91static Blockparse(ByteArrayInputStream stream)Takes a byte stream and parses a block.Intproof()proof.byte[]serialize()Returns the 80 byte block headervoidsetTxHashes(List<byte[]> txHashes)Setter for the fieldtxHashes.Inttarget()Returns the proof-of-work target based on the bitsbooleanvalidateMerkleRoot()Gets the merkle root of the tx_hashes and checks that it's the same as the merkle root of this block.
-
-
-
Method Detail
-
parse
public static Block parse(ByteArrayInputStream stream)
Takes a byte stream and parses a block. Returns a Block object- Parameters:
stream- aByteArrayInputStreamobject- Returns:
- a
Blockobject
-
serialize
public byte[] serialize()
Returns the 80 byte block header- Returns:
- an array of
byteobjects
-
hash
public byte[] hash()
Returns the hash256 interpreted little endian of the block- Returns:
- an array of
byteobjects
-
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
-
difficulty
public Int difficulty()
Returns the block difficulty based on the bits- Returns:
- a
Intobject
-
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
-
getPrevBlock
public byte[] getPrevBlock()
Getter for the field
prevBlock.- Returns:
- an array of
byteobjects
-
getMerkleRoot
public byte[] getMerkleRoot()
Getter for the field
merkleRoot.- Returns:
- an array of
byteobjects
-
getBits
public byte[] getBits()
Getter for the field
bits.- Returns:
- an array of
byteobjects
-
getNonce
public byte[] getNonce()
Getter for the field
nonce.- Returns:
- an array of
byteobjects
-
-