Documentation ¶
Index ¶
- Variables
- func NewMerkleBlockWithFilter(block *bchutil.Block, filter *bloom.Filter) (*wire.MsgMerkleBlock, []uint32)
- func NewMerkleBlockWithTxnSet(block *bchutil.Block, txnSet []*chainhash.Hash) (*wire.MsgMerkleBlock, []uint32)
- func TxInSet(tx *chainhash.Hash, set []*chainhash.Hash) bool
- type MerkleBlock
- type PartialBlock
Constants ¶
This section is empty.
Variables ¶
var MaxTxnCount = wire.MaxBlockPayload() / 61
MaxTxnCount defines the maximum number of transactions we will process before aborting merkle tree traversal operations.
bitcoin core uses formula of max blocksize divided by segwit transaction size (240 bytes) to calculate max number of transactions that could fit in a block which at this time is 4000000/240=16666
bitcoin ABC has removed this check and has been marked "FIXME".
we have opted to use a similar calculation to core based on smallest possible transaction size spending OP_TRUE at 61 bytes with max block size variable
Functions ¶
func NewMerkleBlockWithFilter ¶
func NewMerkleBlockWithFilter(block *bchutil.Block, filter *bloom.Filter) (*wire.MsgMerkleBlock, []uint32)
NewMerkleBlockWithFilter returns a new *wire.MsgMerkleBlock and an array of the matched transaction index numbers based on the passed block and bloom filter.
func NewMerkleBlockWithTxnSet ¶
func NewMerkleBlockWithTxnSet(block *bchutil.Block, txnSet []*chainhash.Hash) (*wire.MsgMerkleBlock, []uint32)
NewMerkleBlockWithTxnSet returns a new *wire.MsgMerkleBlock containing a partial merkle tree built using the list of transactions provided
Types ¶
type MerkleBlock ¶
type MerkleBlock struct {
// contains filtered or unexported fields
}
MerkleBlock is used to house intermediate information needed to generate a wire.MsgMerkleBlock
type PartialBlock ¶
type PartialBlock struct {
// contains filtered or unexported fields
}
PartialBlock is used to house intermediate information needed to decode a wire.MsgMerkleBlock
func NewMerkleBlockFromMsg ¶
func NewMerkleBlockFromMsg(msg wire.MsgMerkleBlock) *PartialBlock
NewMerkleBlockFromMsg returns a MerkleBlock from parsing a wire.MsgMerkleBlock which can be used for extracting transaction matches from for verification on a partial merkle tree.
source code based off bitcoin c++ code at https://github.com/bitcoin/bitcoin/blob/master/src/merkleblock.cpp with protocol reference documentation at https://bitcoin.org/en/developer-examples#parsing-a-merkleblock
func (*PartialBlock) BadTree ¶
func (m *PartialBlock) BadTree() bool
BadTree returns status of partial merkle tree traversal
func (*PartialBlock) ExtractMatches ¶
func (m *PartialBlock) ExtractMatches() *chainhash.Hash
ExtractMatches traverses the partial merkle tree and returns the merkle root on successful traversal or nil if an error occured during traversal due to an invalid block being parsed
func (*PartialBlock) GetItems ¶
func (m *PartialBlock) GetItems() []uint32
GetItems returns the item number of the matched transactions placement in the merkle block
func (*PartialBlock) GetMatches ¶
func (m *PartialBlock) GetMatches() []*chainhash.Hash
GetMatches returns the transaction hashes matched in the partial merkle tree