lian / bitcoin-ruby

bitcoin utils and protocol in ruby.
Other
923 stars 323 forks source link

Explanation about PartialMerkleTree flags params #246

Closed Curter29 closed 6 years ago

Curter29 commented 6 years ago

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?

kento1218 commented 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;

Procedure to encode/decode flags is described in BIP37 https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki#partial-merkle-branch-format