org.bitcoinj.core.Block.checkMerkleRoot()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中org.bitcoinj.core.Block.checkMerkleRoot()方法的一些代码示例,展示了Block.checkMerkleRoot()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.checkMerkleRoot()方法的具体详情如下:
包路径:org.bitcoinj.core.Block
类名称:Block
方法名:checkMerkleRoot

Block.checkMerkleRoot介绍

暂无

代码示例

代码示例来源:origin: fr.acinq/bitcoinj-core

/**
 * Checks the block contents
 *
 * @param height block height, if known, or -1 otherwise. If valid, used
 * to validate the coinbase input script of v2 and above blocks.
 * @param flags flags to indicate which tests should be applied (i.e.
 * whether to test for height in the coinbase transaction).
 * @throws VerificationException if there was an error verifying the block.
 */
public void verifyTransactions(final int height, final EnumSet<VerifyFlag> flags) throws VerificationException {
  // Now we need to check that the body of the block actually matches the headers. The network won't generate
  // an invalid block, but if we didn't validate this then an untrusted man-in-the-middle could obtain the next
  // valid block from the network and simply replace the transactions in it with their own fictional
  // transactions that reference spent or non-existant inputs.
  if (transactions.isEmpty())
    throw new VerificationException("Block had no transactions");
  if (this.getOptimalEncodingMessageSize() > MAX_BLOCK_SIZE)
    throw new VerificationException("Block larger than MAX_BLOCK_SIZE");
  checkTransactions(height, flags);
  checkMerkleRoot();
  checkSigOps();
  if (flags.contains(VerifyFlag.SEGWIT)) checkSegwitCommit();
  for (Transaction transaction : transactions)
    transaction.verify();
  }

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

/**
 * Checks the block contents
 *
 * @param height block height, if known, or -1 otherwise. If valid, used
 * to validate the coinbase input script of v2 and above blocks.
 * @param flags flags to indicate which tests should be applied (i.e.
 * whether to test for height in the coinbase transaction).
 * @throws VerificationException if there was an error verifying the block.
 */
public void verifyTransactions(final int height, final EnumSet<VerifyFlag> flags) throws VerificationException {
  // Now we need to check that the body of the block actually matches the headers. The network won't generate
  // an invalid block, but if we didn't validate this then an untrusted man-in-the-middle could obtain the next
  // valid block from the network and simply replace the transactions in it with their own fictional
  // transactions that reference spent or non-existant inputs.
  if (transactions.isEmpty())
    throw new VerificationException("Block had no transactions");
  if (this.getOptimalEncodingMessageSize() > MAX_BLOCK_SIZE)
    throw new VerificationException("Block larger than MAX_BLOCK_SIZE");
  checkTransactions(height, flags);
  checkMerkleRoot();
  checkSigOps();
  for (Transaction transaction : transactions)
    transaction.verify();
  }

代码示例来源:origin: greenaddress/GreenBits

/**
 * Checks the block contents
 *
 * @param height block height, if known, or -1 otherwise. If valid, used
 * to validate the coinbase input script of v2 and above blocks.
 * @param flags flags to indicate which tests should be applied (i.e.
 * whether to test for height in the coinbase transaction).
 * @throws VerificationException if there was an error verifying the block.
 */
public void verifyTransactions(final int height, final EnumSet<VerifyFlag> flags) throws VerificationException {
  // Now we need to check that the body of the block actually matches the headers. The network won't generate
  // an invalid block, but if we didn't validate this then an untrusted man-in-the-middle could obtain the next
  // valid block from the network and simply replace the transactions in it with their own fictional
  // transactions that reference spent or non-existant inputs.
  if (transactions.isEmpty())
    throw new VerificationException("Block had no transactions");
  if (this.getOptimalEncodingMessageSize() > MAX_BLOCK_SIZE)
    throw new VerificationException("Block larger than MAX_BLOCK_SIZE");
  checkTransactions(height, flags);
  checkMerkleRoot();
  checkSigOps();
  for (Transaction transaction : transactions)
    transaction.verify();
  }

代码示例来源:origin: HashEngineering/dashj

/**
 * Checks the block contents
 *
 * @param height block height, if known, or -1 otherwise. If valid, used
 * to validate the coinbase input script of v2 and above blocks.
 * @param flags flags to indicate which tests should be applied (i.e.
 * whether to test for height in the coinbase transaction).
 * @throws VerificationException if there was an error verifying the block.
 */
public void verifyTransactions(final int height, final EnumSet<VerifyFlag> flags) throws VerificationException {
  // Now we need to check that the body of the block actually matches the headers. The network won't generate
  // an invalid block, but if we didn't validate this then an untrusted man-in-the-middle could obtain the next
  // valid block from the network and simply replace the transactions in it with their own fictional
  // transactions that reference spent or non-existant inputs.
  if (transactions.isEmpty())
    throw new VerificationException("Block had no transactions");
  if (this.getOptimalEncodingMessageSize() > (height >= params.getDIP0001BlockHeight() ? MAX_BLOCK_SIZE_DIP0001 : MAX_BLOCK_SIZE))
    throw new VerificationException("Block larger than MAX_BLOCK_SIZE");
  checkTransactions(height, flags);
  checkMerkleRoot();
  checkSigOps();
  for (Transaction transaction : transactions)
    transaction.verify();
  }

相关文章