Documentation ¶
Index ¶
- Constants
- Variables
- type Addr
- type BlockLocators
- type Checkpoints
- type IPv4
- type InvVector
- type Magic
- type Message
- func NewGetCFilters(network Magic, start *block.Header, stop *block.Header) (*Message, error)
- func NewMessage(cmd string, networkMagic Magic, payload interface{}) (*Message, error)
- func NewMsgCFilter(network Magic, blockHash *chainhash.Hash, filter *gcs.Filter) (*Message, error)
- func NewMsgGetHeaders(network Magic, hashStop [hashLen]byte, blockLocator blockchain.BlockLocator) (*Message, error)
- func NewPingMsg(network Magic) (*Message, uint64, error)
- func NewPongMsg(network Magic, nonce uint64) (*Message, error)
- func NewSendHeadersMessage(network Magic) (*Message, error)
- func NewVerackMsg(network Magic) (*Message, error)
- func NewVersionMsg(network Magic, userAgent string, peerIP IPv4, peerPort uint16, ...) (*Message, error)
- type MessageHeader
- type MsgBlock
- type MsgCFilter
- type MsgGetCFilters
- type MsgGetData
- type MsgGetHeaders
- type MsgHeaders
- type MsgInv
- type MsgPing
- type MsgPong
- type MsgSendCmpct
- type MsgTx
- type MsgVersion
- type ServiceFlag
- type VarInt
- type VarStr
- type VersionNetAddr
Constants ¶
const ( DataObjectError = iota DataObjectTx DataObjectBlock DataObjectFilterBlock DataObjectCmpctBlock )
const (
BIP157MaxHeightDiff = 1000
)
const ( // MsgHeaderLength specifies the length of Message in bytes MsgHeaderLength = magicLength + commandLength + checksumLength + 4 // 4 - payload length value )
const (
Version = 70016 // protocol version of this package
)
Variables ¶
var ( MagicLiquid Magic = [magicLength]byte{0xfa, 0xbf, 0xb5, 0xda} MagicRegtest Magic = [magicLength]byte{0x12, 0x34, 0x56, 0x78} MagicLiquidTestnet Magic = [magicLength]byte{0x41, 0x0e, 0xdd, 0x62} Networks = map[string][magicLength]byte{ "liquid": MagicLiquid, "testnet": MagicLiquidTestnet, "regtest": MagicRegtest, } RegtestGenesisBlockHash string = "00902a6b70c2ca83b5d9c815d96a0e2f4202179316970d14ea1847dae5b1ca21" RegtestGenesisHeader block.Header = block.Header{ Version: 1, Height: 0, PrevBlockHash: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, MerkleRoot: []byte{46, 75, 249, 225, 64, 134, 195, 46, 56, 186, 164, 252, 108, 175, 148, 174, 115, 209, 137, 70, 141, 151, 21, 63, 19, 27, 194, 72, 155, 25, 65, 187}, Timestamp: 1296688602, ExtData: &block.ExtData{ IsDyna: false, DynamicFederation: nil, Proof: &block.Proof{ Challenge: []byte{81}, Solution: []byte{}, }, }, } LiquidTestnetGenesisBlockHash string = "a771da8e52ee6ad581ed1e9a99825e5b3b7992225534eaa2ae23244fe26ab1c1" LiquidTestnetGenesisHeader block.Header = block.Header{ Version: 1, Height: 0, PrevBlockHash: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, MerkleRoot: []byte{247, 201, 80, 216, 138, 108, 89, 38, 73, 200, 224, 188, 135, 98, 180, 159, 117, 177, 166, 29, 69, 37, 83, 5, 42, 9, 140, 91, 33, 108, 143, 23}, Timestamp: 1296688602, ExtData: &block.ExtData{ IsDyna: false, DynamicFederation: nil, Proof: &block.Proof{ Challenge: []byte{81, 33, 2, 23, 228, 3, 221, 177, 129, 135, 44, 50, 160, 205, 70, 140, 113, 0, 64, 178, 245, 61, 140, 172, 105, 241, 141, 173, 7, 152, 94, 227, 126, 154, 113, 81, 174}, Solution: []byte{}, }, }, } LiquidGenesisBlockHash string = "1466275836220db2944ca059a3a10ef6fd2ea684b0688d2c379296888a206003" LiquidGenesisHeader block.Header = block.Header{ Version: 1, Height: 0, PrevBlockHash: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, MerkleRoot: []byte{215, 103, 242, 4, 119, 125, 142, 189, 8, 37, 244, 242, 108, 61, 119, 60, 13, 63, 64, 38, 141, 198, 175, 179, 99, 42, 15, 203, 212, 159, 222, 69}, Timestamp: 1296688602, ExtData: &block.ExtData{ IsDyna: false, DynamicFederation: nil, Proof: &block.Proof{ Challenge: []byte{91, 33, 2, 106, 42, 16, 110, 195, 44, 138, 30, 128, 82, 229, 208, 42, 123, 10, 21, 4, 35, 219, 217, 177, 22, 252, 72, 212, 102, 48, 255, 110, 106, 5, 185, 33, 2, 121, 22, 70, 168, 180, 156, 39, 64, 53, 43, 68, 149, 193, 24, 216, 118, 52, 123, 244, 125, 5, 81, 192, 28, 67, 50, 253, 194, 223, 82, 111, 26, 33, 2, 136, 139, 218, 83, 164, 36, 70, 107, 4, 81, 98, 125, 242, 32, 144, 20, 59, 191, 124, 6, 14, 158, 172, 177, 227, 132, 38, 246, 176, 127, 42, 225, 33, 2, 174, 232, 150, 113, 80, 222, 226, 32, 246, 19, 222, 59, 35, 147, 32, 53, 90, 73, 136, 8, 8, 74, 147, 234, 243, 154, 52, 220, 214, 32, 36, 133, 33, 2, 212, 110, 146, 89, 208, 160, 187, 43, 203, 196, 97, 163, 230, 143, 52, 173, 202, 39, 184, 208, 143, 190, 152, 88, 83, 153, 43, 75, 16, 78, 39, 65, 33, 2, 233, 148, 78, 53, 229, 117, 10, 182, 33, 224, 152, 20, 91, 142, 108, 243, 115, 194, 115, 183, 192, 71, 71, 209, 170, 2, 11, 224, 175, 64, 204, 214, 33, 2, 249, 169, 212, 177, 10, 109, 108, 86, 216, 201, 85, 197, 71, 51, 12, 88, 155, 180, 94, 119, 69, 81, 212, 109, 65, 94, 81, 205, 154, 213, 17, 99, 33, 3, 59, 66, 21, 102, 193, 36, 223, 222, 77, 185, 222, 254, 64, 132, 183, 170, 78, 127, 54, 116, 71, 88, 217, 40, 6, 184, 247, 44, 46, 148, 51, 9, 33, 3, 83, 220, 198, 180, 207, 106, 210, 138, 206, 183, 247, 178, 219, 146, 164, 191, 7, 172, 66, 211, 87, 173, 247, 86, 243, 236, 167, 144, 102, 67, 20, 182, 33, 3, 127, 85, 152, 10, 240, 69, 94, 79, 181, 90, 173, 155, 133, 165, 80, 104, 187, 109, 196, 116, 14, 168, 114, 118, 220, 105, 63, 69, 152, 219, 69, 250, 33, 3, 132, 0, 29, 170, 136, 218, 189, 35, 219, 135, 141, 187, 28, 229, 180, 194, 165, 250, 114, 195, 17, 62, 53, 20, 191, 96, 35, 37, 208, 195, 123, 142, 33, 3, 144, 86, 208, 137, 242, 254, 114, 219, 192, 161, 71, 128, 180, 99, 91, 13, 200, 161, 180, 11, 122, 89, 16, 99, 37, 221, 27, 196, 92, 199, 4, 147, 33, 3, 151, 171, 142, 167, 176, 191, 133, 188, 127, 197, 107, 178, 123, 248, 94, 117, 80, 46, 148, 231, 106, 103, 129, 196, 9, 243, 242, 236, 61, 17, 34, 25, 33, 3, 176, 14, 59, 91, 119, 136, 75, 243, 202, 226, 4, 196, 180, 234, 192, 3, 96, 29, 167, 95, 150, 152, 47, 252, 179, 220, 178, 156, 94, 228, 25, 185, 33, 3, 193, 243, 192, 135, 76, 254, 52, 184, 19, 26, 243, 70, 153, 88, 154, 172, 236, 64, 147, 57, 151, 57, 174, 53, 46, 138, 70, 248, 10, 111, 104, 55, 95, 174}, Solution: []byte{}, }, }, } )
Functions ¶
This section is empty.
Types ¶
type BlockLocators ¶
type BlockLocators [][hashLen]byte
func (BlockLocators) MarshalBinary ¶
func (locators BlockLocators) MarshalBinary() ([]byte, error)
func (BlockLocators) UnmarshalBinary ¶
func (locators BlockLocators) UnmarshalBinary(r io.Reader) error
type Checkpoints ¶
func GetCheckpoints ¶
func GetCheckpoints(net Magic) Checkpoints
type IPv4 ¶
type IPv4 [4]byte
IPv4 ...
func (IPv4) MarshalBinary ¶
MarshalBinary implements the binary.Marshaler interface
type Message ¶
type Message struct { MessageHeader Payload []byte }
Message ...
func NewGetCFilters ¶
func NewMessage ¶
NewMessage returns a new Message.
func NewMsgCFilter ¶
func NewMsgGetHeaders ¶
func NewMsgGetHeaders(network Magic, hashStop [hashLen]byte, blockLocator blockchain.BlockLocator) (*Message, error)
func NewPingMsg ¶
NewPingMsg returns a new MsgPing.
func NewPongMsg ¶
NewPongMsg returns a new MsgPong.
func NewSendHeadersMessage ¶
func NewVerackMsg ¶
NewVerackMsg returns a new 'verack' message.
func NewVersionMsg ¶
func NewVersionMsg(network Magic, userAgent string, peerIP IPv4, peerPort uint16, Services ServiceFlag) (*Message, error)
NewVersionMsg returns a new MsgVersion.
type MessageHeader ¶
type MessageHeader struct { Magic [magicLength]byte Command [commandLength]byte Length uint32 Checksum [checksumLength]byte }
MessageHeader ...
func (MessageHeader) CommandString ¶
func (mh MessageHeader) CommandString() string
CommandString returns command as a string with zero bytes removed.
func (MessageHeader) HasValidCommand ¶
func (mh MessageHeader) HasValidCommand() bool
HasValidCommand returns true if the message header contains a supported command. Returns false otherwise.
func (MessageHeader) HasValidMagic ¶
func (mh MessageHeader) HasValidMagic() bool
HasValidMagic returns true if the message header contains a supported magic. Returns false otherwise.
type MsgCFilter ¶
func (*MsgCFilter) MarshalBinary ¶
func (msg *MsgCFilter) MarshalBinary() ([]byte, error)
func (*MsgCFilter) UnmarshalBinary ¶
func (msg *MsgCFilter) UnmarshalBinary(r io.Reader) error
type MsgGetCFilters ¶
type MsgGetData ¶
MsgGetData represents 'getdata' message.
func (MsgGetData) MarshalBinary ¶
func (gd MsgGetData) MarshalBinary() ([]byte, error)
MarshalBinary implements binary.Marshaler interface.
type MsgGetHeaders ¶
type MsgGetHeaders struct { Version uint32 BlockLocatorHashes BlockLocators HashStop [hashLen]byte }
type MsgHeaders ¶
func (*MsgHeaders) UnmarshalBinary ¶
func (msgHeaders *MsgHeaders) UnmarshalBinary(r io.Reader) error
type MsgSendCmpct ¶
type MsgTx ¶
type MsgTx struct {
transaction.Transaction
}
MsgTx represents 'tx' message.
func NewMsgTxFromHex ¶
func (MsgTx) MarshalBinary ¶
MarshalBinary implements binary.Marshaler interface.
type MsgVersion ¶
type MsgVersion struct { Version int32 Services uint64 Timestamp int64 AddrRecv VersionNetAddr AddrFrom VersionNetAddr Nonce uint64 UserAgent VarStr StartHeight int32 Relay bool }
MsgVersion ...
func (MsgVersion) HasService ¶
func (msg MsgVersion) HasService(service ServiceFlag) bool
type ServiceFlag ¶
type ServiceFlag uint64
ServiceFlag identifies services supported by a bitcoin peer.
const ( // SFNodeNetwork is a flag used to indicate a peer is a full node. SFNodeNetwork ServiceFlag = 1 << iota // SFNodeGetUTXO is a flag used to indicate a peer supports the // getutxos and utxos commands (BIP0064). SFNodeGetUTXO // SFNodeBloom is a flag used to indicate a peer supports bloom // filtering. SFNodeBloom // SFNodeWitness is a flag used to indicate a peer supports blocks // and transactions including witness data (BIP0144). SFNodeWitness // SFNodeXthin is a flag used to indicate a peer supports xthin blocks. SFNodeXthin // SFNodeBit5 is a flag used to indicate a peer supports a service // defined by bit 5. SFNodeBit5 // SFNodeCF is a flag used to indicate a peer supports committed // filters (CFs). SFNodeCF // SFNode2X is a flag used to indicate a peer is running the Segwit2X // software. SFNode2X )
type VarInt ¶
type VarInt struct {
Value interface{}
}
VarInt is variable length integer.
func (*VarInt) MarshalBinary ¶
type VersionNetAddr ¶
VersionNetAddr ...