Class BlockValidationException

All Implemented Interfaces:
Serializable

public final class BlockValidationException extends BlockchainException
Thrown when a Block fails validation during Blockchain.addBlock().

Possible causes include:

  • The block's hash does not satisfy the consensus difficulty target
  • block.previousHash does not match the current chain tip's hash
  • The block's Merkle root does not match the computed root of its transactions
  • The block's stored hash does not match a fresh computation (corruption)
Since:
1.0.0
See Also:
  • Constructor Details

    • BlockValidationException

      public BlockValidationException(String message, Block block)
      Constructs an exception with a detail message and the offending block.
      Parameters:
      message - human-readable description of why the block was rejected
      block - the block that failed validation (maybe null)
    • BlockValidationException

      public BlockValidationException(String message, Throwable cause, Block block)
      Constructs an exception with a detail message, cause, and the offending block.
      Parameters:
      message - human-readable description of why the block was rejected
      cause - the underlying exception
      block - the block that failed validation (maybe null)
  • Method Details

    • getBlock

      public Block getBlock()
      Returns the block that triggered this exception.
      Returns:
      the invalid block, or null if not available