Class CheckpointManager

java.lang.Object
org.bitcoinj.core.CheckpointManager

public class CheckpointManager extends Object

Vends hard-coded StoredBlocks for blocks throughout the chain. Checkpoints serve two purposes:

  1. They act as a safety mechanism against huge re-orgs that could rewrite large chunks of history, thus constraining the block chain to be a consensus mechanism only for recent parts of the timeline.
  2. They allow synchronization to the head of the chain for new wallets/users much faster than syncing all headers from the genesis block.

Checkpoints are used by the SPV BlockChain to initialize fresh SPVBlockStores. They are not used by fully validating mode, which instead has a different concept of checkpoints that are used to hard-code the validity of blocks that violate BIP30 (duplicate coinbase transactions). Those "checkpoints" can be found in NetworkParameters.

Checkpoints are read from a text file, one value per line. It consists of the magic string "TXT CHECKPOINTS 1", followed by the number of signatures to read. The value may not be larger than 256. If the number of signatures is larger than zero, each 65 byte ECDSA secp256k1 signature then follows. The signatures sign the hash of all bytes that follow the last signature.

After the signatures come the number of checkpoints in the file. Then each checkpoint follows one per line in compact format (as written by StoredBlock.serializeCompactV2(ByteBuffer)) as a base64-encoded blob.