Documentation ¶
Index ¶
- Constants
- Variables
- func MakeMerkleTree(TS []Transaction) (res [32]byte)
- func MakeMerkleTreeFromHashes(hashes []byte) (res [32]byte)
- type AddrMsg
- type Block
- type GetBlocksMsg
- type InvMsg
- type Inventory
- type MerkleBlockMsg
- type MerkleTree
- type NetworkIPAddress
- type Outpoint
- type SerializedBlock
- type Transaction
- type TxIn
- type TxOut
Constants ¶
View Source
const ( MSG_TX = 1 MSG_BLOCK = 2 MSG_FILTERED_BLOCK = 3 MSG_CMPCT_BLOCK = 4 MSG_WITNESS_FLAG = 1 << 30 MSG_WITNESS_TX = MSG_TX | MSG_WITNESS_FLAG MSG_WITNESS_BLOCK = MSG_BLOCK | MSG_WITNESS_FLAG MSG_FILTERED_WITNESS_BLOCK = MSG_FILTERED_BLOCK | MSG_WITNESS_FLAG )
https://developer.bitcoin.org/reference/p2p_networking.html#data-messages
View Source
const HashL = 32
View Source
const InvMaxItemCount = 50_000
Variables ¶
View Source
var MerkleBlockNotEnoughFlags = errors.New("MerkleBlockNotEnoughFlags")
View Source
var MerkleBlockNotEnoughHash = errors.New("MerkleBlockNotEnoughHash")
View Source
var MerkleBlockTooManyFlags = errors.New("MerkleBlockTooManyFlags")
View Source
var MerkleBlockTooManyHashes = errors.New("MerkleBlockTooManyHashes")
Functions ¶
func MakeMerkleTree ¶
func MakeMerkleTree(TS []Transaction) (res [32]byte)
Types ¶
type AddrMsg ¶
type AddrMsg struct {
Addrs []NetworkIPAddress
}
type Block ¶
type Block struct { Version int32 Previous_block_header_hash [32]byte Merkle_root_hash [32]byte Time uint32 NBits uint32 Nonce uint32 }
func CreateBlock ¶
type GetBlocksMsg ¶
type GetBlocksMsg struct { Version uint32 // Hashes should be provided in reverse order of block height, // so highest-height hashes are listed first and lowest-height hashes are listed last. BlockHeaderHashes [][32]byte // if all zero, request an "inv" message // otherwise its the last header hash being requested // not included in the array above StopHash [32]byte }
https://developer.bitcoin.org/reference/p2p_networking.html#getblocks
func (*GetBlocksMsg) LoadBuffer ¶
func (ret *GetBlocksMsg) LoadBuffer(reader utils.BufReader) (err error)
type InvMsg ¶
type InvMsg struct {
Inv []Inventory
}
Inventory https://developer.bitcoin.org/reference/p2p_networking.html#inv
type MerkleBlockMsg ¶
type MerkleBlockMsg struct { // TODO: Block header TxCount uint32 // contains filtered or unexported fields }
func NewMerkleBlockMsg ¶
func NewMerkleBlockMsg(reader utils.BufReader) (ret MerkleBlockMsg, err error)
type MerkleTree ¶
type MerkleTree struct { Hash [32]byte Lson, Rson *MerkleTree IsLeaf bool // "Used" means that this transaction is included in this Merkle Tree // Unused nodes appear in the tree because they are needed for hash calculation // This variable makes sense only if IsLeaf is true Used bool }
type NetworkIPAddress ¶
type NetworkIPAddress struct { Ipv6 [16]byte Port uint16 // contains filtered or unexported fields }
func (*NetworkIPAddress) LoadBuffer ¶
func (a *NetworkIPAddress) LoadBuffer(reader utils.BufReader) (err error)
type Outpoint ¶
func NewOutPoint ¶
type SerializedBlock ¶
type SerializedBlock struct { Header Block HeaderHash [32]byte Txns []Transaction }
https://developer.bitcoin.org/reference/block_chain.html#serialized-blocks
func CreateSerialBlock ¶
func CreateSerialBlock(block Block, tx []Transaction) (sb SerializedBlock, err error)
func (*SerializedBlock) HexString ¶
func (b *SerializedBlock) HexString() string
func (*SerializedBlock) LoadBuffer ¶
func (b *SerializedBlock) LoadBuffer(reader utils.BufReader) (err error)
type Transaction ¶
func CreateTransaction ¶
func CreateTransaction(version int32, tx_in []TxIn, tx_out []TxOut, lock_time uint32) Transaction
func (*Transaction) LoadBuffer ¶
func (tx *Transaction) LoadBuffer(reader utils.BufReader) (err error)
Click to show internal directories.
Click to hide internal directories.