Documentation
¶
Index ¶
- Constants
- func MessageType(Command []byte) int
- func TestEverything()
- type AddressList
- type Alert
- type BitMessage
- func (bm *BitMessage) Compile() []byte
- func (bm *BitMessage) CompileVerack() []byte
- func (bm *BitMessage) CompileVersion() []byte
- func (bm *BitMessage) GetMagic() []byte
- func (bm *BitMessage) GiveMessageType() int
- func (bm *BitMessage) SetCommand(newCommand string)
- func (bm *BitMessage) SetMagic(newMagic uint32)
- func (bm *BitMessage) SetPayloadAddr(al *AddressList)
- func (bm *BitMessage) SetPayloadByte(pld []byte)
- func (bm *BitMessage) SetPayloadVersion(vm *VersionMessage)
- type Block
- func (b *Block) AddTx(t *Tx)
- func (b *Block) Clear()
- func (b *Block) Compile() []byte
- func (b *Block) GetBits() []byte
- func (b *Block) GetHeader() *BlockHeader
- func (b *Block) GetMerkleRoot() []byte
- func (b *Block) GetNonce() []byte
- func (b *Block) GetPrevBlock() []byte
- func (b *Block) GetTimestamp() []byte
- func (b *Block) GetTxnCount() mymath.VarInt
- func (b *Block) GetTxns() []*Tx
- func (b *Block) GetVersion() []byte
- func (b *Block) Hash() []byte
- func (b *Block) Len() int
- func (b *Block) SetBits(bi uint32)
- func (b *Block) SetMerkleRoot(merkle []byte)
- func (b *Block) SetMerkleRootStr(merkle string)
- func (b *Block) SetMerkleRootStrRev(merkle string)
- func (b *Block) SetNonce(non uint32)
- func (b *Block) SetPrevBlock(prev []byte)
- func (b *Block) SetPrevBlockStr(prev string)
- func (b *Block) SetPrevBlockStrRev(prev string)
- func (b *Block) SetTimestamp(time uint32)
- func (b *Block) SetVersion(ver uint32)
- type BlockHeader
- func (bh *BlockHeader) Compile() []byte
- func (bh *BlockHeader) GetBits() []byte
- func (bh *BlockHeader) GetMerkleRoot() []byte
- func (bh *BlockHeader) GetNonce() []byte
- func (bh *BlockHeader) GetPrevBlock() []byte
- func (bh *BlockHeader) GetTimestamp() []byte
- func (bh *BlockHeader) GetTxnCount() []byte
- func (bh *BlockHeader) GetVersion() []byte
- func (bh *BlockHeader) Hash() []byte
- func (bh *BlockHeader) Len() int
- func (bh *BlockHeader) SetBits(bi uint32)
- func (bh *BlockHeader) SetMerkleRoot(merkle []byte)
- func (bh *BlockHeader) SetMerkleRootStr(merkle string)
- func (bh *BlockHeader) SetNonce(non uint32)
- func (bh *BlockHeader) SetPrevBlock(prev []byte)
- func (bh *BlockHeader) SetPrevBlockStr(prev string)
- func (bh *BlockHeader) SetTimestamp(time uint32)
- func (bh *BlockHeader) SetVersion(ver uint32)
- type CheckOrder
- type GetBlocks
- type GetData
- type GetHeaders
- type Hash
- type Headers
- type Inv
- type InventoryVector
- type NetworkAddress
- func (na *NetworkAddress) Compile() []byte
- func (na *NetworkAddress) CompileForVersion() []byte
- func (na *NetworkAddress) GetHash() []byte
- func (na *NetworkAddress) SetIP(IP net.IP)
- func (na *NetworkAddress) SetPort(port uint16)
- func (na *NetworkAddress) SetServices(ser uint64)
- func (na *NetworkAddress) SetTimestamp(setTime uint32)
- func (na *NetworkAddress) SetTimestampNow(setTime uint32)
- type OutPoint
- type Reply
- type SubmitOrder
- type Tx
- func (t *Tx) AddIn(txin *TxIn)
- func (t *Tx) AddOut(txout *TxOut)
- func (t *Tx) ClearIn()
- func (t *Tx) ClearOut()
- func (t *Tx) Compile() []byte
- func (t *Tx) GetLockTime() []byte
- func (t *Tx) GetTxIn() []*TxIn
- func (t *Tx) GetTxInCount() mymath.VarInt
- func (t *Tx) GetTxOut() []*TxOut
- func (t *Tx) GetTxOutCount() mymath.VarInt
- func (t *Tx) GetVersion() []byte
- func (t *Tx) Hash() []byte
- func (t *Tx) Len() int
- func (t *Tx) SetLockTime(time uint32)
- func (t *Tx) SetVersion(ver uint32)
- type TxIn
- func (ti *TxIn) Compile() []byte
- func (ti *TxIn) GetPreviousOutput() OutPoint
- func (ti *TxIn) GetScriptLength() mymath.VarInt
- func (ti *TxIn) GetSequence() []byte
- func (ti *TxIn) GetSignatureScript() []byte
- func (ti *TxIn) Len() int
- func (ti *TxIn) SetOutPoint(out OutPoint)
- func (ti *TxIn) SetSequence(seq uint32)
- func (ti *TxIn) SetSignature(sig []byte)
- type TxOut
- func (to *TxOut) Compile() []byte
- func (to *TxOut) GetPkScript() []byte
- func (to *TxOut) GetPkScriptLength() mymath.VarInt
- func (to *TxOut) GetValue() []byte
- func (to *TxOut) Len() int
- func (to *TxOut) SetScript(script []byte)
- func (to *TxOut) SetScriptStr(script string, opcode byte)
- func (to *TxOut) SetValue(val uint64)
- type VersionMessage
- func (vm *VersionMessage) Compile() []byte
- func (vm *VersionMessage) SetAddrMe(ip net.IP, ser uint64, port uint16)
- func (vm *VersionMessage) SetAddrYou(ip net.IP, ser uint64, port uint16)
- func (vm *VersionMessage) SetNonce(n uint64)
- func (vm *VersionMessage) SetRandomNonce()
- func (vm *VersionMessage) SetServices(ser uint64)
- func (vm *VersionMessage) SetStartHeight(block uint32)
- func (vm *VersionMessage) SetSubVersionNull()
- func (vm *VersionMessage) SetTimestamp(setTime uint64)
- func (vm *VersionMessage) SetTimestampNow()
- func (vm *VersionMessage) SetVersion(ver uint32)
Constants ¶
View Source
const ( WRONGMESSAGE = iota VERSION = iota VERACK = iota ADDR = iota INV = iota GETDATA = iota GETBLOCKS = iota GETHEADERS = iota TX = iota BLOCK = iota HEADERS = iota GETADDR = iota CHECKORDER = iota SUBMITORDER = iota REPLY = iota PING = iota ALERT = iota )
View Source
const ( ERROR uint32 = iota //==0 MSG_TX uint32 = iota //==1 MSG_BLOCK uint32 = iota //==2 )
View Source
const ( SUCCESS uint32 = iota //==0 //The IP Transaction can proceed (checkorder), or has been accepted (submitorder) WALLET_ERROR uint32 = iota //==1 //AcceptWalletTransaction() failed DENIED uint32 = iota //==2 //IP Transactions are not accepted by this node )
View Source
const ( NOT_NODE_NETWORK uint64 = iota //==0 NODE_NETWORK uint64 = iota //==1 )
View Source
const MainNetMagic uint32 = 0xD9B4BEF9
View Source
const MainNetPort uint16 = 8333
View Source
const TestNetMagic uint32 = 0xDAB5BFFA
View Source
const TestNetPort uint16 = 18333
Variables ¶
This section is empty.
Functions ¶
func MessageType ¶
func TestEverything ¶
func TestEverything()
Types ¶
type AddressList ¶
type AddressList struct {
Count uint8
AddrList []*NetworkAddress
}
checked, works as expected
func (*AddressList) AddAddress ¶
func (al *AddressList) AddAddress(na *NetworkAddress)
func (*AddressList) Clear ¶
func (al *AddressList) Clear()
func (*AddressList) Compile ¶
func (al *AddressList) Compile() []byte
TODO: double check if 30 is really the answer
type BitMessage ¶
type BitMessage struct {
Magic [4]byte //Magic 4 network bytes
Command [12]byte //12 ASCII characters identifying package content, NULL padded
Length [4]byte //Length of the Payload
Checksum [4]byte //first 4 bytes of sha256(sha256(Payload))
Payload []byte //the actual data
}
func DecodeMessage ¶
func DecodeMessage(msg []byte) *BitMessage
func DeserializeMessages ¶
func DeserializeMessages(msgs []byte) []*BitMessage
func (*BitMessage) Compile ¶
func (bm *BitMessage) Compile() []byte
func (*BitMessage) CompileVerack ¶
func (bm *BitMessage) CompileVerack() []byte
send the special verack message (without Checksum)
func (*BitMessage) CompileVersion ¶
func (bm *BitMessage) CompileVersion() []byte
send the special version message (without Checksum)
func (*BitMessage) GetMagic ¶
func (bm *BitMessage) GetMagic() []byte
func (*BitMessage) SetCommand ¶
func (bm *BitMessage) SetCommand(newCommand string)
func (*BitMessage) SetMagic ¶
func (bm *BitMessage) SetMagic(newMagic uint32)
func (*BitMessage) SetPayloadAddr ¶
func (bm *BitMessage) SetPayloadAddr(al *AddressList)
func (*BitMessage) SetPayloadByte ¶
func (bm *BitMessage) SetPayloadByte(pld []byte)
func (*BitMessage) SetPayloadVersion ¶
func (bm *BitMessage) SetPayloadVersion(vm *VersionMessage)
type Block ¶
type Block struct {
Version [4]byte
PrevBlock [32]byte //char[32]
MerkleRoot [32]byte //char[32]
Timestamp [4]byte
Bits [4]byte
Nonce [4]byte
TxnCount mymath.VarInt
Txns []*Tx //tx[]
}
TODO: test
func (*Block) GetHeader ¶
func (b *Block) GetHeader() *BlockHeader
func (*Block) GetMerkleRoot ¶
func (*Block) GetPrevBlock ¶
func (*Block) GetTimestamp ¶
func (*Block) GetTxnCount ¶
func (*Block) GetVersion ¶
func (*Block) SetMerkleRoot ¶
func (*Block) SetMerkleRootStr ¶
func (*Block) SetMerkleRootStrRev ¶
func (*Block) SetPrevBlock ¶
func (*Block) SetPrevBlockStr ¶
func (*Block) SetPrevBlockStrRev ¶
func (*Block) SetTimestamp ¶
func (*Block) SetVersion ¶
type BlockHeader ¶
type BlockHeader struct {
Version [4]byte
PrevBlock [32]byte //char[32]
MerkleRoot [32]byte //char[32]
Timestamp [4]byte
Bits [4]byte
Nonce [4]byte
TxnCount [1]byte
}
TODO: test
func (*BlockHeader) Compile ¶
func (bh *BlockHeader) Compile() []byte
func (*BlockHeader) GetBits ¶
func (bh *BlockHeader) GetBits() []byte
func (*BlockHeader) GetMerkleRoot ¶
func (bh *BlockHeader) GetMerkleRoot() []byte
func (*BlockHeader) GetNonce ¶
func (bh *BlockHeader) GetNonce() []byte
func (*BlockHeader) GetPrevBlock ¶
func (bh *BlockHeader) GetPrevBlock() []byte
func (*BlockHeader) GetTimestamp ¶
func (bh *BlockHeader) GetTimestamp() []byte
func (*BlockHeader) GetTxnCount ¶
func (bh *BlockHeader) GetTxnCount() []byte
func (*BlockHeader) GetVersion ¶
func (bh *BlockHeader) GetVersion() []byte
func (*BlockHeader) Hash ¶
func (bh *BlockHeader) Hash() []byte
func (*BlockHeader) Len ¶
func (bh *BlockHeader) Len() int
func (*BlockHeader) SetBits ¶
func (bh *BlockHeader) SetBits(bi uint32)
func (*BlockHeader) SetMerkleRoot ¶
func (bh *BlockHeader) SetMerkleRoot(merkle []byte)
func (*BlockHeader) SetMerkleRootStr ¶
func (bh *BlockHeader) SetMerkleRootStr(merkle string)
func (*BlockHeader) SetNonce ¶
func (bh *BlockHeader) SetNonce(non uint32)
func (*BlockHeader) SetPrevBlock ¶
func (bh *BlockHeader) SetPrevBlock(prev []byte)
func (*BlockHeader) SetPrevBlockStr ¶
func (bh *BlockHeader) SetPrevBlockStr(prev string)
func (*BlockHeader) SetTimestamp ¶
func (bh *BlockHeader) SetTimestamp(time uint32)
func (*BlockHeader) SetVersion ¶
func (bh *BlockHeader) SetVersion(ver uint32)
type CheckOrder ¶
type CheckOrder struct {
}
TODO: do TODO: figure out? https://en.bitcoin.it/wiki/Protocol_specification#checkorder
type GetBlocks ¶
type GetBlocks struct {
Version [4]byte
StartCount mymath.VarInt //var_int
BlockLocatorHashes []Hash
HashStop Hash
}
func (*GetBlocks) SetStopHash ¶
func (*GetBlocks) SetVersion ¶
type GetHeaders ¶
func (*GetHeaders) SetStartCount ¶
func (gh *GetHeaders) SetStartCount(start mymath.VarInt)
func (*GetHeaders) SetStartHash ¶
func (gh *GetHeaders) SetStartHash(start Hash)
func (*GetHeaders) SetStopHash ¶
func (gh *GetHeaders) SetStopHash(stop Hash)
type Headers ¶
type Headers struct {
Count mymath.VarInt
Headers []*BlockHeader //block_header[]
}
TODO:test
func (*Headers) AddHeader ¶
func (hs *Headers) AddHeader(bh *BlockHeader)
TODO:check if there is any limit on Count
type Inv ¶
type Inv struct {
Count mymath.VarInt //var_int
Inventory []*InventoryVector
}
type InventoryVector ¶
TODO: test
func (*InventoryVector) Compile ¶
func (iv *InventoryVector) Compile() []byte
func (*InventoryVector) SetHash ¶
func (iv *InventoryVector) SetHash(newhash []byte)
func (*InventoryVector) SetType ¶
func (iv *InventoryVector) SetType(newtype uint32)
type NetworkAddress ¶
func (*NetworkAddress) Compile ¶
func (na *NetworkAddress) Compile() []byte
func (*NetworkAddress) CompileForVersion ¶
func (na *NetworkAddress) CompileForVersion() []byte
func (*NetworkAddress) SetIP ¶
func (na *NetworkAddress) SetIP(IP net.IP)
func (*NetworkAddress) SetPort ¶
func (na *NetworkAddress) SetPort(port uint16)
func (*NetworkAddress) SetServices ¶
func (na *NetworkAddress) SetServices(ser uint64)
func (*NetworkAddress) SetTimestamp ¶
func (na *NetworkAddress) SetTimestamp(setTime uint32)
func (*NetworkAddress) SetTimestampNow ¶
func (na *NetworkAddress) SetTimestampNow(setTime uint32)
type SubmitOrder ¶
type SubmitOrder struct {
// contains filtered or unexported fields
}
TODO: do https://en.bitcoin.it/wiki/Protocol_specification#submitorder
type Tx ¶
type Tx struct {
Version [4]byte
TxInCount mymath.VarInt
TxIn []*TxIn //[]TxIn
TxOutCount mymath.VarInt
TxOut []*TxOut //[]TxOut
LockTime [4]byte
}
TODO: test
func (*Tx) GetLockTime ¶
func (*Tx) GetTxInCount ¶
func (*Tx) GetTxOutCount ¶
func (*Tx) GetVersion ¶
func (*Tx) SetLockTime ¶
func (*Tx) SetVersion ¶
type TxIn ¶
type TxIn struct {
PreviousOutput OutPoint
ScriptLength mymath.VarInt
SignatureScript []byte //uchar[]
Sequence [4]byte
}
TODO:test
func DecodeMultipleTxIns ¶
TODO: test
func (*TxIn) GetPreviousOutput ¶
func (*TxIn) GetScriptLength ¶
func (*TxIn) GetSequence ¶
func (*TxIn) GetSignatureScript ¶
func (*TxIn) SetOutPoint ¶
func (*TxIn) SetSequence ¶
func (*TxIn) SetSignature ¶
type TxOut ¶
TODO:test
func DecodeMultipleTxOuts ¶
TODO: test
func (*TxOut) GetPkScript ¶
func (*TxOut) GetPkScriptLength ¶
func (*TxOut) SetScriptStr ¶
type VersionMessage ¶
type VersionMessage struct {
Version [4]byte
Services [8]byte
Timestamp [8]byte
AddrYou [26]byte
AddrMe [26]byte
Nonce [8]byte
SubVersionNum []byte
StartHeight [4]byte
}
TODO: double checks, but it's probably OK
func (*VersionMessage) Compile ¶
func (vm *VersionMessage) Compile() []byte
func (*VersionMessage) SetAddrMe ¶
func (vm *VersionMessage) SetAddrMe(ip net.IP, ser uint64, port uint16)
func (*VersionMessage) SetAddrYou ¶
func (vm *VersionMessage) SetAddrYou(ip net.IP, ser uint64, port uint16)
func (*VersionMessage) SetNonce ¶
func (vm *VersionMessage) SetNonce(n uint64)
func (*VersionMessage) SetRandomNonce ¶
func (vm *VersionMessage) SetRandomNonce()
func (*VersionMessage) SetServices ¶
func (vm *VersionMessage) SetServices(ser uint64)
func (*VersionMessage) SetStartHeight ¶
func (vm *VersionMessage) SetStartHeight(block uint32)
func (*VersionMessage) SetSubVersionNull ¶
func (vm *VersionMessage) SetSubVersionNull()
func (*VersionMessage) SetTimestamp ¶
func (vm *VersionMessage) SetTimestamp(setTime uint64)
func (*VersionMessage) SetTimestampNow ¶
func (vm *VersionMessage) SetTimestampNow()
func (*VersionMessage) SetVersion ¶
func (vm *VersionMessage) SetVersion(ver uint32)
Click to show internal directories.
Click to hide internal directories.