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

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

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

Block.buildMerkleTree介绍

暂无

代码示例

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

private Sha256Hash calculateMerkleRoot() {
  List<byte[]> tree = buildMerkleTree();
  return Sha256Hash.wrap(tree.get(tree.size() - 1));
}

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

private Sha256Hash calculateMerkleRoot() {
  List<byte[]> tree = buildMerkleTree();
  return Sha256Hash.wrap(tree.get(tree.size() - 1));
}

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

private Sha256Hash calculateMerkleRoot(boolean segwit) {
  List<byte[]> tree = buildMerkleTree(segwit);
  return Sha256Hash.wrap(tree.get(tree.size() - 1));
}

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

private Sha256Hash calculateMerkleRoot() {
  List<byte[]> tree = buildMerkleTree();
  return Sha256Hash.wrap(tree.get(tree.size() - 1));
}

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

private List<byte[]> buildMerkleTree(boolean segwit) {
  // The Merkle root is based on a tree of hashes calculated from the transactions:
  //
  //     root
  //      / \
  //   A      B
  //  / \    / \
  // t1 t2 t3 t4
  //
  // The tree is represented as a list: t1,t2,t3,t4,A,B,root where each
  // entry is a hash.
  //
  // The hashing algorithm is double SHA-256. The leaves are a hash of the serialized contents of the transaction.
  // The interior nodes are hashes of the concenation of the two child hashes.
  //
  // This structure allows the creation of proof that a transaction was included into a block without having to
  // provide the full block contents. Instead, you can provide only a Merkle branch. For example to prove tx2 was
  // in a block you can just provide tx2, the hash(tx1) and B. Now the other party has everything they need to
  // derive the root, which can be checked against the block header. These proofs aren't used right now but
  // will be helpful later when we want to download partial block contents.
  //
  // Note that if the number of transactions is not even the last tx is repeated to make it so (see
  // tx3 above). A tree with 5 transactions would look like this:
  //
  //         root
  //        /     \
  //       1        5
  //     /   \     / \
  //    2     3    4  4
  //  / \   / \   / \

相关文章