Block extends Message { public void verify(final int height, final EnumSet<VerifyFlag> flags) throws VerificationException { verifyHeader(); verifyTransactions(height, flags); } Block(NetworkParameters params, long setVersion); @Deprecated  Block(NetworkParameters params, byte[] payloadBytes);  Block(NetworkParameters params, byte[] payloadBytes, MessageSerializer serializer, int length);  Block(NetworkParameters params, byte[] payloadBytes, int offset, MessageSerializer serializer, int length);  Block(NetworkParameters params, byte[] payloadBytes, int offset, @Nullable Message parent, MessageSerializer serializer, int length);  Block(NetworkParameters params, long version, Sha256Hash prevBlockHash, Sha256Hash merkleRoot, long time,
                 long difficultyTarget, long nonce, List<Transaction> transactions); Coin getBlockInflation(int height, long nPrevBits, boolean fSuperblockPartOnly); static Coin getBlockInflation(NetworkParameters params, int height, long nPrevBits, boolean fSuperblockPartOnly); int getOptimalEncodingMessageSize(); @Override byte[] bitcoinSerialize(); String getHashAsString(); @Override Sha256Hash getHash(); BigInteger getWork(); Block cloneAsHeader(); @Override String toString(); void solve(); BigInteger getDifficultyTargetAsInteger(); void verifyHeader(); void verifyTransactions(final int height, final EnumSet<VerifyFlag> flags); void verify(final int height, final EnumSet<VerifyFlag> flags); @Override boolean equals(Object o); @Override int hashCode(); Sha256Hash getMerkleRoot(); void addTransaction(Transaction t); long getVersion(); Sha256Hash getPrevBlockHash(); long getTimeSeconds(); Date getTime(); void setTime(long time); long getDifficultyTarget(); void setDifficultyTarget(long compactForm); long getNonce(); void setNonce(long nonce); @Nullable List<Transaction> getTransactions(); @VisibleForTesting Block createNextBlock(Address to, long version, long time, int blockHeight); @VisibleForTesting Block createNextBlock(@Nullable Address to, TransactionOutPoint prevOut); @VisibleForTesting Block createNextBlock(@Nullable Address to, Coin value); @VisibleForTesting Block createNextBlock(@Nullable Address to); @VisibleForTesting Block createNextBlockWithCoinbase(long version, byte[] pubKey, Coin coinbaseValue, final int height); boolean hasTransactions(); boolean isBIP34(); boolean isBIP66(); boolean isBIP65(); static final int HEADER_SIZE; static final int MAX_BLOCK_SIZE; static final int MAX_BLOCK_SIZE_DIP0001; static final int MAX_BLOCK_SIGOPS; static final int MAX_BLOCK_SIGOPS_DIP00001; static final long EASIEST_DIFFICULTY_TARGET; static final int BLOCK_HEIGHT_UNKNOWN; static final int BLOCK_HEIGHT_GENESIS; static final long BLOCK_VERSION_GENESIS; static final long BLOCK_VERSION_BIP34; static final long BLOCK_VERSION_BIP66; static final long BLOCK_VERSION_BIP65; }
@Test public void testBadTransactions() throws Exception { Block block = PARAMS.getDefaultSerializer().makeBlock(blockBytes); Transaction tx1 = block.transactions.get(0); Transaction tx2 = block.transactions.get(1); block.transactions.set(0, tx2); block.transactions.set(1, tx1); try { block.verify(Block.BLOCK_HEIGHT_GENESIS, EnumSet.noneOf(Block.VerifyFlag.class)); fail(); } catch (VerificationException e) { } }