gimiq

package module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2020 License: GPL-3.0 Imports: 25 Imported by: 0

README

Gimiq

GoDoc

Golang Test Nimiq Node

Implemented:

  • WS/WSS client protocol
  • Basic handshake
  • Pings
  • Get blockchain head / blocks
  • Get neighbors of peer

Usage:

$ go get github.com/terorie/gimiq/cmd/gimiq/

$ ~/go/bin/gimiq peer ping ws://dev.nimiq-network.com:8080
... PING ...

$ ~/go/bin/gimiq peer block ws://dev.nimiq-network.com:8080 vQD/t7ttNg6Tf5lzb85xKyiWzW1h/53FKeFG8D449tI=
... BLOCK ...

$ ~/go/bin/gimiq peer head ws://dev.nimiq-network.com:8080
{
        "height": 15020,
        "n_bits": 0x1e68b17e,
        "timestamp": 1544857704,
        "nonce": 0x00006dc8,
        "prev_hash": "vQD/t7ttNg6Tf5lzb85xKyiWzW1h/53FKeFG8D449tI=",
        "interlink_hash": "/ArhKKvhRDCnxgNa1vmFIuEfJTWmGGPNV8VgG1F/I/o=",
        "body_hash": "RKmvLBzA2CE7q6QpQisDN0+zCJnGi+GrJ5FtAj0iSmQ=",
        "accounts_hash": "G5lgd7yJSnW/cNbPj+pgWefJIneAekS+QG1wDeffEtI=",
}

Documentation

Index

Constants

View Source
const (
	AccountBasic   = 0
	AccountVesting = 1
	AccountHTLC    = 2
	AccountStaking = 3
)
View Source
const (
	CloseGetBlocksTimeout         = 1
	CloseGetChainProofTimeout     = 2
	CloseGetAccTreeChunkTimeout   = 3
	CloseGetHeaderTimeout         = 4
	CloseInvalidAccTreeChunk      = 5
	CloseAccTreeChunkRootMismatch = 6
	CloseGotWrongHeader           = 8
	CloseRequestedHeaderTimeout   = 9

	CloseGetAccProofTimeout   = 11
	CloseGetTxProofTimeout    = 12
	CloseGetTxReceiptsTimeout = 13
	CloseInvalidAccProof      = 14
	CloseAccProofRootMismatch = 15
	CloseIncompleteAccProof   = 16
	CloseInvalidBlock         = 17
	CloseInvalidChainProof    = 18
	CloseInvalidTxProf        = 19
	CloseInvalidBlockProof    = 20

	CloseSendPingFailed    = 22
	CloseSendVersionFailed = 23

	CloseSimultaneousConn    = 29
	CloseDupConn             = 30
	ClosePeerBanned          = 31
	CloseManualNetDisconnect = 33
	CloseManualWsDisconnect  = 34
	CloseMaxPeerCount        = 35

	ClosePeerConnRecycled                = 36
	ClosePeerConnRecycledInboundExchange = 37
	CloseInboundConnsBlocked             = 38

	CloseInvalidConnState = 40

	CloseManualPeerDisconnect = 90
)

Regular Close Types

View Source
const (
	CloseGotInvalidBlock          = 100
	CloseChainSyncFailed          = 101
	CloseGotInvalidHeader         = 102
	CloseGotTxNotMatchingSub      = 103
	CloseOversizeAddrMsg          = 104
	CloseInvalidAddr              = 105
	CloseAddrNotGloballyReachable = 106
	CloseInvalidSignalTTL         = 107
	CloseInvalidSignature         = 108
	CloseGotBlockNotMachingSub    = 109

	CloseIncompatibleVersion           = 110
	CloseOtherGenesis                  = 111
	CloseVersionMsg_InvalidPeerAddr    = 112
	CloseVersionMsg_UnexpectedPeerAddr = 113
	CloseVerAckMsg_InvalidPubKey       = 114
	CloseVerAckMsg_InvalidSignature    = 115
	CloseBannedIP                      = 116

	CloseRateLimit = 120

	CloseManualPeerBan = 190
)

Ban Close Types

View Source
const (
	CloseByRemote           = 200
	ClosePingTimeout        = 201
	CloseConnFailed         = 202
	CloseNetworkError       = 203
	CloseVersionTimeout     = 204
	CloseVerAckTimeout      = 205
	CloseAbortedSync        = 206
	CloseUnknownMessageType = 207
	CloseIPConnLimit        = 208
	CloseChannelClosing     = 209
	CloseDumbConnLimit      = 210

	CloseManualPeerFail = 290
)

Fail Close Types

View Source
const (
	ChunkSizeMax   = 16 * 1024
	MessageSizeMax = 10 * 1024 * 1024
)
View Source
const (
	HashBlake2b = 1
	HashArgon2d = 2
	HashSha256  = 3
	HashSha512  = 4
)
View Source
const (
	HashBlake2bSize = 32
	HashArgon2dSize = 32
	HashSha256Size  = 32
	HashSha512Size  = 64
)
View Source
const (

	// Not a IBAN starting with NQ
	ErrIBANInvalidCountryCode
	// IBAN length without spaces not 36
	ErrIBANInvalidLength
	// Corrupt IBAN: checksum (first two digits)
	// don't match the rest
	ErrIBANChecksum
	// IBAN contains character that can't be decoded
	ErrIBANInvalidCharacter
)
View Source
const (
	InvError = 0
	InvTx    = 1
	InvBlock = 2
)
View Source
const (
	DirectionForward  = 1
	DirectionBackward = 2
)
View Source
const (
	MessageVersion   = 0
	MessageInv       = 1
	MessageGetData   = 2
	MessageGetHeader = 3
	MessageNotFound  = 4
	MessageGetBlocks = 5
	MessageBlock     = 6
	MessageHeader    = 7
	MessageTx        = 8
	MessageMempool   = 9
	MessageReject    = 10
	MessageSubscribe = 11

	MessageAddr    = 20
	MessageGetAddr = 21
	MessagePing    = 22
	MessagePong    = 23

	MessageSignal = 30

	MessageGetChainProof        = 40
	MessageChainProof           = 41
	MessageGetAccountsProof     = 42
	MessageAccountsProof        = 43
	MessageGetAccountsTreeChunk = 44
	MessageAccountsTreeChunk    = 45
	MessageGetTxProof           = 47
	MessageTxProof              = 48
	MessageGetTxReceipts        = 49
	MessageTxReceipts           = 50
	MessageGetBlockProof        = 51
	MessageBlockProof           = 52

	MessageGetHead = 60
	MessageHead    = 61

	MessageVerAck = 90
)
View Source
const (
	NetAddressIPv4        = 0
	NetAddressIPv6        = 1
	NetAddressUnspecified = 2
	NetAddressUnknown     = 3
)
View Source
const (
	HandshakeTimeout = 4 * time.Second
	VerAckTimeout    = 8 * time.Second
)
View Source
const (
	PeerConnecting = uint32(iota)
	PeerNegotiating
	PeerConnected
	PeerDisconnected
)
View Source
const (
	ProtocolDumb = uint8(0)
	ProtocolWSS  = uint8(1 << 0)
	ProtocolRTC  = uint8(1 << 1)
	ProtocolWS   = uint8(1 << 2)
)
View Source
const (
	ServicesNone = uint32(0)
	ServicesNano = uint32(1 << iota)
	ServicesLight
	ServicesFull
)
View Source
const (
	TxBasic    = uint8(0)
	TxExtended = uint8(1)
)
View Source
const AccountPrunedBinSize = 20 + BasicAccountBinSize
View Source
const BasicAccountBinSize = 9
View Source
const BasicTxBinSize = 138
View Source
const (
	Haze = uint32(0x42042042)
)
View Source
const InvVectorBinSize = 4 + 32
View Source
const VectorsMaxCount = 1000
View Source
const VestingContractBinSize = 52

Variables

View Source
var BlockTargetMax big.Int
View Source
var ErrUnknownMessage = errors.New("unknown message")

TODO Include message type

View Source
var GetChainProofMessage = EmptyMessageType(MessageGetChainProof)
View Source
var IBANEncoding = base32.NewEncoding("0123456789ABCDEFGHJKLMNPQRSTUVXY")

Functions

func AddressToIBAN

func AddressToIBAN(addr *[20]byte) string

Encodes an address into a user friendly string (ASCII)

func BinHash

func BinHash(bin Bin) (out [32]byte)

func DifficultyToCompact

func DifficultyToCompact(difficulty big.Int) uint32

func DifficultyToTarget

func DifficultyToTarget(difficulty big.Int) (target big.Int)

func IBANToAddress

func IBANToAddress(addr *[20]byte, ufs string) error

Decodes the IBAN into an address object. Spaces are ignored. The IBAN must have exactly 36 non-space characters.

func MarshalTx

func MarshalTx(w io.Writer, tx Tx) (err error)

func ProtocolScheme

func ProtocolScheme(proto uint8) string

func PublicKeyToAddress added in v0.0.4

func PublicKeyToAddress(addr *[20]byte, pub *[32]byte)

func TargetToCompact

func TargetToCompact(target big.Int) (compact uint32)

func UnwrapMessage

func UnwrapMessage(buf []byte) (msgType uint64, msgBody []byte, err error)

func WrapMessage

func WrapMessage(msgType uint64, msgBody []byte) []byte

Types

type Account

type Account interface {
	Bin
	Type() uint8
}

func UnmarshalAccount

func UnmarshalAccount(r io.Reader) (acc Account, err error)

type AccountPruned

type AccountPruned struct {
	Address [20]byte
	Account Account
}

func (*AccountPruned) BinSize

func (a *AccountPruned) BinSize() int

func (*AccountPruned) MarshalBin

func (a *AccountPruned) MarshalBin(w io.Writer) (err error)

func (*AccountPruned) UnmarshalBin

func (a *AccountPruned) UnmarshalBin(r io.Reader) (err error)

type AccountsProof

type AccountsProof struct {
	EmptyBinType
}

type AddrMessage

type AddrMessage struct {
	Addresses []PeerAddress
}

func (*AddrMessage) BinSize

func (m *AddrMessage) BinSize() (size int)

func (*AddrMessage) MarshalBin

func (m *AddrMessage) MarshalBin(w io.Writer) (err error)

func (*AddrMessage) Type

func (m *AddrMessage) Type() uint64

func (*AddrMessage) UnmarshalBin

func (m *AddrMessage) UnmarshalBin(r io.Reader) (err error)

type AnonContext

type AnonContext struct {
	Self Self
	Peer *PeerConnection
}

func AnonConnect

func AnonConnect(tgt string, network *GenesisConfigType) (c *AnonContext, err error)

type BasePingMessage

type BasePingMessage struct {
	Nonce uint32
	Pong  bool
}

func (*BasePingMessage) BinSize

func (m *BasePingMessage) BinSize() int

func (*BasePingMessage) MarshalBin

func (m *BasePingMessage) MarshalBin(w io.Writer) error

func (*BasePingMessage) Type

func (m *BasePingMessage) Type() uint64

func (*BasePingMessage) UnmarshalBin

func (m *BasePingMessage) UnmarshalBin(r io.Reader) (err error)

type BasicAccount

type BasicAccount struct {
	Balance uint64
}

func (*BasicAccount) BinSize

func (a *BasicAccount) BinSize() int

func (*BasicAccount) MarshalBin

func (a *BasicAccount) MarshalBin(w io.Writer) (err error)

func (*BasicAccount) Type

func (a *BasicAccount) Type() uint8

func (*BasicAccount) UnmarshalBin

func (a *BasicAccount) UnmarshalBin(r io.Reader) (err error)

type BasicTx

type BasicTx struct {
	SenderPubKey        [32]byte
	Recipient           [20]byte
	Value               uint64
	Fee                 uint64
	ValidityStartHeight uint32
	NetworkID           uint8
	Signature           [64]byte
}

func (*BasicTx) AsExtendedTx

func (t *BasicTx) AsExtendedTx() ExtendedTx

func (*BasicTx) AsTxContent added in v0.0.2

func (t *BasicTx) AsTxContent() TxContent

func (*BasicTx) BinSize

func (t *BasicTx) BinSize() int

func (*BasicTx) MarshalBin

func (t *BasicTx) MarshalBin(w io.Writer) (err error)

func (*BasicTx) Type

func (t *BasicTx) Type() uint8

func (*BasicTx) UnmarshalBin

func (t *BasicTx) UnmarshalBin(r io.Reader) (err error)

type Bin

type Bin interface {
	UnmarshalBin(r io.Reader) error
	MarshalBin(w io.Writer) error
	BinSize() int
}

type Block

type Block struct {
	Header    BlockHeader
	Interlink BlockInterlink
	Body      *BlockBody
}

func (*Block) BinSize

func (b *Block) BinSize() (size int)

func (*Block) MarshalBin

func (b *Block) MarshalBin(w io.Writer) (err error)

func (*Block) UnmarshalBin

func (b *Block) UnmarshalBin(r io.Reader) (err error)

type BlockBody

type BlockBody struct {
	MinerAddr [20]byte
	ExtraData []byte
	Txs       []Tx
	Pruned    []AccountPruned
}

func (*BlockBody) BinSize

func (b *BlockBody) BinSize() (size int)

func (*BlockBody) MarshalBin

func (b *BlockBody) MarshalBin(w io.Writer) (err error)

func (*BlockBody) UnmarshalBin

func (b *BlockBody) UnmarshalBin(r io.Reader) (err error)

type BlockHeader

type BlockHeader struct {
	PrevHash      [32]byte `json:"prev_hash"`
	InterlinkHash [32]byte `json:"interlink_hash"`
	BodyHash      [32]byte `json:"body_hash"`
	AccountsHash  [32]byte `json:"accounts_hash"`
	NBits         uint32   `json:"n_bits"`
	Height        uint32   `json:"height"`
	Timestamp     uint32   `json:"timestamp"`
	Nonce         uint32   `json:"nonce"`
}

func (*BlockHeader) BinSize

func (b *BlockHeader) BinSize() int

func (*BlockHeader) MarshalBin

func (b *BlockHeader) MarshalBin(w io.Writer) (err error)

func (*BlockHeader) UnmarshalBin

func (b *BlockHeader) UnmarshalBin(r io.Reader) (err error)
type BlockInterlink struct {
	Hashes     []*[32]byte
	PrevHash   [32]byte
	RepeatBits []byte
	Compressed [][32]byte
}

func (*BlockInterlink) BinSize

func (b *BlockInterlink) BinSize() int

func (*BlockInterlink) MarshalBin

func (b *BlockInterlink) MarshalBin(w io.Writer) (err error)

func (*BlockInterlink) UnmarshalBin

func (b *BlockInterlink) UnmarshalBin(r io.Reader) (err error)

type BlockMessage

type BlockMessage struct {
	Block
}

func (*BlockMessage) BinSize

func (m *BlockMessage) BinSize() int

func (*BlockMessage) Type

func (m *BlockMessage) Type() uint64

type Chain

type Chain struct {
	Blocks []*Block
}

type DataChannel

type DataChannel struct {
	In  <-chan Message
	Out chan<- Message

	// Thread-safe
	sync.Mutex
	// contains filtered or unexported fields
}

func NewDataChannel

func NewDataChannel(conn Transport) *DataChannel

func (*DataChannel) Closed

func (dc *DataChannel) Closed() <-chan bool

func (*DataChannel) Error

func (dc *DataChannel) Error() error

func (*DataChannel) IsOpen

func (dc *DataChannel) IsOpen() bool

type EmptyBinType

type EmptyBinType struct{}
var EmptyBin EmptyBinType

func (*EmptyBinType) BinSize

func (b *EmptyBinType) BinSize() int

func (*EmptyBinType) MarshalBin

func (b *EmptyBinType) MarshalBin(w io.Writer) error

func (*EmptyBinType) UnmarshalBin

func (b *EmptyBinType) UnmarshalBin(r io.Reader) error

type EmptyMessageType

type EmptyMessageType uint64

func (EmptyMessageType) BinSize

func (_ EmptyMessageType) BinSize() int

func (EmptyMessageType) MarshalBin

func (_ EmptyMessageType) MarshalBin(w io.Writer) error

func (EmptyMessageType) Type

func (m EmptyMessageType) Type() uint64

func (EmptyMessageType) UnmarshalBin

func (_ EmptyMessageType) UnmarshalBin(r io.Reader) error

type ExtendedTx

type ExtendedTx struct {
	Sender              [20]byte
	SenderType          uint8
	Recipient           [20]byte
	RecipientType       uint8
	Value               uint64
	Fee                 uint64
	ValidityStartHeight uint32
	Flags               uint8
	Data                []byte
	Proof               []byte
	NetworkID           uint8
}

func (*ExtendedTx) AsExtendedTx

func (t *ExtendedTx) AsExtendedTx() ExtendedTx

func (*ExtendedTx) AsTxContent added in v0.0.2

func (t *ExtendedTx) AsTxContent() TxContent

func (*ExtendedTx) BinSize

func (t *ExtendedTx) BinSize() int

func (*ExtendedTx) MarshalBin

func (t *ExtendedTx) MarshalBin(w io.Writer) (err error)

func (*ExtendedTx) Type

func (t *ExtendedTx) Type() uint8

func (*ExtendedTx) UnmarshalBin

func (t *ExtendedTx) UnmarshalBin(r io.Reader) (err error)

type GenesisConfigType

type GenesisConfigType struct {
	NetworkID   uint8
	NetworkName string
	Hash        [32]byte
	Genesis     Block
}
var GenesisConfig *GenesisConfigType

type GetAddrMessage

type GetAddrMessage struct {
	ProtocolMask uint8
	ServiceMask  uint32
	MaxResults   uint16
}

func (*GetAddrMessage) BinSize

func (m *GetAddrMessage) BinSize() int

func (*GetAddrMessage) MarshalBin

func (m *GetAddrMessage) MarshalBin(w io.Writer) (err error)

func (*GetAddrMessage) Type

func (m *GetAddrMessage) Type() uint64

func (*GetAddrMessage) UnmarshalBin

func (m *GetAddrMessage) UnmarshalBin(r io.Reader) (err error)

type GetBlocksMessage

type GetBlocksMessage struct {
	Locators   [][32]byte
	MaxInvSize uint16
	Direction  uint8
}

func (*GetBlocksMessage) BinSize

func (m *GetBlocksMessage) BinSize() int

func (*GetBlocksMessage) MarshalBin

func (m *GetBlocksMessage) MarshalBin(w io.Writer) error

func (*GetBlocksMessage) Type

func (m *GetBlocksMessage) Type() uint64

func (*GetBlocksMessage) UnmarshalBin

func (m *GetBlocksMessage) UnmarshalBin(r io.Reader) error

type GetTxProofMessage

type GetTxProofMessage struct {
	BlockHash [32]byte
	Addresses [][20]byte
}

func (*GetTxProofMessage) BinSize

func (m *GetTxProofMessage) BinSize() int

func (*GetTxProofMessage) MarshalBin

func (m *GetTxProofMessage) MarshalBin(w io.Writer) (err error)

func (*GetTxProofMessage) Type

func (m *GetTxProofMessage) Type() uint64

func (*GetTxProofMessage) UnmarshalBin

func (m *GetTxProofMessage) UnmarshalBin(r io.Reader) (err error)

type GetTxReceiptsMessage

type GetTxReceiptsMessage struct {
	Address [20]byte
	Offset  uint32
}

func (*GetTxReceiptsMessage) BinSize

func (m *GetTxReceiptsMessage) BinSize() int

func (*GetTxReceiptsMessage) MarshalBin

func (m *GetTxReceiptsMessage) MarshalBin(w io.Writer) (err error)

func (*GetTxReceiptsMessage) Type

func (m *GetTxReceiptsMessage) Type() uint64

func (*GetTxReceiptsMessage) UnmarshalBin

func (m *GetTxReceiptsMessage) UnmarshalBin(r io.Reader) (err error)

type HTLCAccount

type HTLCAccount struct {
	Balance     uint64
	Sender      [20]byte
	Recipient   [20]byte
	Hash        Hash
	Timeout     uint32
	TotalAmount uint64
}

func (*HTLCAccount) BinSize

func (c *HTLCAccount) BinSize() int

func (*HTLCAccount) MarshalBin

func (c *HTLCAccount) MarshalBin(w io.Writer) (err error)

func (*HTLCAccount) Type

func (c *HTLCAccount) Type() uint8

func (*HTLCAccount) UnmarshalBin

func (c *HTLCAccount) UnmarshalBin(r io.Reader) (err error)

type Hash

type Hash struct {
	Algorithm uint8
	Root      []byte
}

func (*Hash) BinSize

func (h *Hash) BinSize() int

func (*Hash) MarshalBin

func (h *Hash) MarshalBin(w io.Writer) (err error)

func (*Hash) UnmarshalBin

func (h *Hash) UnmarshalBin(r io.Reader) (err error)

type HeadMessage

type HeadMessage struct {
	BlockHeader
}

func (*HeadMessage) Type

func (m *HeadMessage) Type() uint64

type HeaderMessage

type HeaderMessage struct {
	BlockHeader
}

func (*HeaderMessage) Type

func (m *HeaderMessage) Type() uint64

type InvMessage

type InvMessage struct {
	MessageType uint64
	Vectors     []InvVector
}

func (*InvMessage) BinSize

func (m *InvMessage) BinSize() int

func (*InvMessage) MarshalBin

func (m *InvMessage) MarshalBin(w io.Writer) (err error)

func (*InvMessage) Type

func (m *InvMessage) Type() uint64

func (*InvMessage) UnmarshalBin

func (m *InvMessage) UnmarshalBin(r io.Reader) (err error)

type InvVector

type InvVector struct {
	Type uint32
	Hash [32]byte
}

func (*InvVector) BinSize

func (i *InvVector) BinSize() int

func (*InvVector) MarshalBin

func (i *InvVector) MarshalBin(w io.Writer) (err error)

func (*InvVector) UnmarshalBin

func (i *InvVector) UnmarshalBin(r io.Reader) (err error)

type Message

type Message interface {
	Bin
	Type() uint64
}

func UnmarshalBinMessage

func UnmarshalBinMessage(msgType uint64, msgStream io.Reader) (m Message, err error)

type NetAddress

type NetAddress struct {
	net.IP
	Type uint8
}

func (*NetAddress) BinSize

func (n *NetAddress) BinSize() int

func (*NetAddress) MarshalBin

func (n *NetAddress) MarshalBin(w io.Writer) (err error)

func (*NetAddress) UnmarshalBin

func (n *NetAddress) UnmarshalBin(r io.Reader) (err error)

type PeerAddress

type PeerAddress struct {
	Protocol   uint8
	Services   uint32
	Timestamp  uint64
	NetAddress NetAddress
	PublicKey  [32]byte
	Distance   uint8
	Signature  [64]byte
	Sub        Bin
}

func (*PeerAddress) BinSize

func (m *PeerAddress) BinSize() int

func (*PeerAddress) MarshalBin

func (m *PeerAddress) MarshalBin(w io.Writer) (err error)

func (*PeerAddress) Sign

func (m *PeerAddress) Sign(privateKey ed25519.PrivateKey)

func (*PeerAddress) UnmarshalBin

func (m *PeerAddress) UnmarshalBin(r io.Reader) (err error)

func (*PeerAddress) VerifySignature

func (m *PeerAddress) VerifySignature() bool

type PeerAddressSrv

type PeerAddressSrv struct {
	Host string
	Port uint16
	TLS  bool
}

Generic client-server type address used for describing WS/WSS and TCP/TLS service locations.

func (*PeerAddressSrv) BinSize

func (m *PeerAddressSrv) BinSize() int

func (*PeerAddressSrv) MarshalBin

func (m *PeerAddressSrv) MarshalBin(w io.Writer) (err error)

func (*PeerAddressSrv) UnmarshalBin

func (m *PeerAddressSrv) UnmarshalBin(r io.Reader) (err error)

type PeerConnection

type PeerConnection struct {
	PeerId
	Self        *Self
	DataChannel *DataChannel
	PeerAddress PeerAddress
	// contains filtered or unexported fields
}

func ConnectToPeer

func ConnectToPeer(self *Self, uri string) (*PeerConnection, error)

func (*PeerConnection) Connect

func (c *PeerConnection) Connect(uri string, network *GenesisConfigType) error

FIXME: Terminate connection if verification fails

func (*PeerConnection) State

func (c *PeerConnection) State() uint32

type PeerId

type PeerId [16]byte

func GetPeerId

func GetPeerId(pubKey ed25519.PublicKey) (p PeerId)

type Self

type Self struct {
	PeerId
	Address        PeerAddress
	PeerPublicKey  [32]byte
	PeerPrivateKey [64]byte
	Genesis        *GenesisConfigType
}

func (*Self) Version

func (s *Self) Version() VersionMessage

type StakingTxData added in v0.0.5

type StakingTxData struct {
	ValidatorKey     [96]byte
	RewardAddress    *[20]byte // optional
	ProofOfKnowledge [48]byte
}

func (*StakingTxData) BinSize added in v0.0.5

func (d *StakingTxData) BinSize() int

func (*StakingTxData) MarshalBin added in v0.0.5

func (d *StakingTxData) MarshalBin(w io.Writer) (err error)

func (*StakingTxData) UnmarshalBin added in v0.0.5

func (d *StakingTxData) UnmarshalBin(r io.Reader) (err error)

type Transport

type Transport interface {
	Write(m Message) error
	Read() (m Message, err error)
	Close() error
}

type TransportWS

type TransportWS struct {
	Conn *websocket.Conn
	// contains filtered or unexported fields
}

func ConnectToWS

func ConnectToWS(address PeerAddressSrv) (*TransportWS, error)

func (*TransportWS) Close

func (t *TransportWS) Close() error

func (*TransportWS) Read

func (t *TransportWS) Read() (m Message, err error)

func (*TransportWS) Write

func (t *TransportWS) Write(m Message) (err error)

type Tx

type Tx interface {
	Bin
	Type() uint8
	AsTxContent() TxContent
	AsExtendedTx() ExtendedTx
}

func UnmarshalTx

func UnmarshalTx(r io.Reader) (tx Tx, err error)

type TxContent added in v0.0.2

type TxContent struct {
	Data                []byte
	Sender              [20]byte
	SenderType          uint8
	Recipient           [20]byte
	RecipientType       uint8
	Value               uint64
	Fee                 uint64
	ValidityStartHeight uint32
	NetworkID           uint8
	Flags               uint8
}

func (*TxContent) BinSize added in v0.0.2

func (t *TxContent) BinSize() int

func (*TxContent) MarshalBin added in v0.0.2

func (t *TxContent) MarshalBin(w io.Writer) (err error)

func (*TxContent) UnmarshalBin added in v0.0.2

func (t *TxContent) UnmarshalBin(r io.Reader) (err error)

type TxMessage

type TxMessage struct {
	Tx    Tx
	Proof *AccountsProof
}

func (*TxMessage) BinSize

func (m *TxMessage) BinSize() (size int)

func (*TxMessage) MarshalBin

func (m *TxMessage) MarshalBin(w io.Writer) (err error)

func (*TxMessage) Type

func (m *TxMessage) Type() uint64

func (*TxMessage) UnmarshalBin

func (m *TxMessage) UnmarshalBin(r io.Reader) (err error)

type VerAckMessage

type VerAckMessage struct {
	PublicKey [32]byte
	Signature [64]byte
}

func (*VerAckMessage) BinSize

func (m *VerAckMessage) BinSize() int

func (*VerAckMessage) MarshalBin

func (m *VerAckMessage) MarshalBin(w io.Writer) (err error)

func (*VerAckMessage) Type

func (m *VerAckMessage) Type() uint64

func (*VerAckMessage) UnmarshalBin

func (m *VerAckMessage) UnmarshalBin(r io.Reader) (err error)

type VersionMessage

type VersionMessage struct {
	Version        uint32
	PeerAddress    PeerAddress
	GenesisHash    [32]byte
	HeadHash       [32]byte
	ChallengeNonce [32]byte
	UserAgent      string
}

func (*VersionMessage) BinSize

func (m *VersionMessage) BinSize() int

func (*VersionMessage) MarshalBin

func (m *VersionMessage) MarshalBin(w io.Writer) (err error)

func (*VersionMessage) Type

func (m *VersionMessage) Type() uint64

func (*VersionMessage) UnmarshalBin

func (m *VersionMessage) UnmarshalBin(r io.Reader) (err error)

type VestingAccount

type VestingAccount struct {
	Balance            uint64
	Owner              [20]byte
	VestingStart       uint32
	VestingStepBlocks  uint32
	VestingStepAmount  uint64
	VestingTotalAmount uint64
}

func (*VestingAccount) BinSize

func (c *VestingAccount) BinSize() int

func (*VestingAccount) MarshalBin

func (c *VestingAccount) MarshalBin(w io.Writer) (err error)

func (*VestingAccount) Type

func (c *VestingAccount) Type() uint8

func (*VestingAccount) UnmarshalBin

func (c *VestingAccount) UnmarshalBin(r io.Reader) (err error)

type Wallet added in v0.0.4

type Wallet struct {
	PrivateKey ed25519.PrivateKey
	PublicKey  ed25519.PublicKey
}

func (*Wallet) GetAddress added in v0.0.4

func (w *Wallet) GetAddress(addr *[20]byte)

func (*Wallet) GetPrivateKey added in v0.0.4

func (w *Wallet) GetPrivateKey(priv *[32]byte)

func (*Wallet) GetPublicKey added in v0.0.4

func (w *Wallet) GetPublicKey(pub *[32]byte)

func (*Wallet) SetPrivateKey added in v0.0.4

func (w *Wallet) SetPrivateKey(priv *[32]byte)

func (*Wallet) SignBasicTx added in v0.0.4

func (w *Wallet) SignBasicTx(tx *BasicTx)

func (*Wallet) SignExtendedTx added in v0.0.4

func (w *Wallet) SignExtendedTx(tx *ExtendedTx)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL