Closed Curter29 closed 6 years ago
org.bitcoinj.core.PartialMerkleTree#buildFromLeaves
may be a good reference.
https://github.com/bitcoinj/bitcoinj/blob/master/core/src/main/java/org/bitcoinj/core/PartialMerkleTree.java#L87
It creates flags
(bits
in bitcoinj, very confusing...) from tx hashes and markings;
List< Sha256Hash > allLeafHashes
: list of all tx hashes in the blockbyte[] includeBits
: bit flags in little-endian order, i
-th bit of includeBits
indicates whether PMT includes allLeafHashes[i]
Procedure to encode/decode flags
is described in BIP37 https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki#partial-merkle-branch-format
https://github.com/lian/bitcoin-ruby/blob/master/spec/bitcoin/protocol/partial_merkle_tree_spec.rb#L21
How calculate flag params for real world example?