types

package
v0.0.0-...-dd31ef9 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2018 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package types EOS types

Index

Constants

View Source
const (
	GoAwayNoReason = uint8(iota)
	GoAwaySelfConnect
	GoAwayDuplicate
	GoAwayWrongChain
	GoAwayWrongVersion
	GoAwayForked
	GoAwayUnlinkable
	GoAwayBadTransaction
	GoAwayValidation
	GoAwayAuthentication
	GoAwayFatalOther
	GoAwayBenignOther
	GoAwayCrazy
)
View Source
const (
	CompressionNone = CompressionType(iota)
	CompressionZlib
)
View Source
const BlockTimestampFormat = "2006-01-02T15:04:05"
View Source
const JSONTimeFormat = "2006-01-02T15:04:05"

Variables

View Source
var Debug bool
View Source
var EOSSymbol = Symbol{Precision: 4, Symbol: "EOS"}

EOSSymbol represents the standard EOS symbol on the chain. It's here just to speed up things.

View Source
var ErrNotFound = errors.New("resource not found")
View Source
var ErrUnknownMessageType = errors.New("unknown type")
View Source
var ErrVarIntBufferSize = errors.New("varint: invalid buffer size")
View Source
var RegisteredActions = map[AccountName]map[ActionName]reflect.Type{}
View Source
var TypeSize = struct {
	Byte           int
	Int8           int
	UInt16         int
	Int16          int
	UInt32         int
	UInt64         int
	SHA256Bytes    int
	PublicKey      int
	Signature      int
	Tstamp         int
	BlockTimestamp int
	CurrencyName   int
	Bool           int
}{
	Byte:           1,
	Int8:           1,
	UInt16:         2,
	Int16:          2,
	UInt32:         4,
	UInt64:         8,
	SHA256Bytes:    32,
	PublicKey:      34,
	Signature:      66,
	Tstamp:         8,
	BlockTimestamp: 4,
	CurrencyName:   7,
	Bool:           1,
}

Functions

func MarshalBinary

func MarshalBinary(v interface{}) ([]byte, error)

func NameToString

func NameToString(in uint64) string

func RegisterAction

func RegisterAction(accountName AccountName, actionName ActionName, obj interface{})

Registers Action objects..

func SigDigest

func SigDigest(chainID, payload, contextFreeData []byte) []byte

func StringToName

func StringToName(s string) (val uint64, err error)

func UnmarshalBinary

func UnmarshalBinary(data []byte, v interface{}) (err error)

func UnmarshalBinaryReader

func UnmarshalBinaryReader(reader io.Reader, v interface{}) (err error)

Types

type ABI

type ABI struct {
	Version          string            `json:"version"`
	Types            []ABIType         `json:"types,omitempty"`
	Structs          []StructDef       `json:"structs,omitempty"`
	Actions          []ActionDef       `json:"actions,omitempty"`
	Tables           []TableDef        `json:"tables,omitempty"`
	RicardianClauses []ClausePair      `json:"ricardian_clauses,omitempty"`
	ErrorMessages    []ABIErrorMessage `json:"error_messages,omitempty"`
	Extensions       []*Extension      `json:"abi_extensions,omitempty"`
}

see: libraries/chain/contracts/abi_serializer.cpp:53... see: libraries/chain/include/eosio/chain/contracts/types.hpp:100

type ABIErrorMessage

type ABIErrorMessage struct {
	Code    uint64 `json:"error_code"`
	Message string `json:"error_msg"`
}

type ABIType

type ABIType struct {
	NewTypeName string `json:"new_type_name"`
	Type        string `json:"type"`
}

type API

type API struct {
	HttpClient              *http.Client
	BaseURL                 string
	Signer                  Signer
	Debug                   bool
	Compress                CompressionType
	DefaultMaxCPUUsageMS    uint8
	DefaultMaxNetUsageWords uint32 // in 8-bytes words
	// contains filtered or unexported fields
}

func New

func New(baseURL string) *API

func (*API) EnableKeepAlives

func (api *API) EnableKeepAlives() bool

func (*API) FixKeepAlives

func (api *API) FixKeepAlives() bool

FixKeepAlives tests the remote server for keepalive support (the main `nodeos` software doesn't in the version from March 22nd 2018). Some endpoints front their node with a keep-alive supporting web server. Adjust the `KeepAlive` support of the client accordingly.

func (*API) GetABI

func (api *API) GetABI(account AccountName) (out *GetABIResp, err error)

func (*API) GetAccount

func (api *API) GetAccount(name AccountName) (out *AccountResp, err error)

func (*API) GetBlockByID

func (api *API) GetBlockByID(id string) (out *BlockResp, err error)

func (*API) GetBlockByNum

func (api *API) GetBlockByNum(num uint32) (out *BlockResp, err error)

func (*API) GetBlockByNumOrID

func (api *API) GetBlockByNumOrID(query string) (out *SignedBlock, err error)

func (*API) GetBlockByNumOrIDRaw

func (api *API) GetBlockByNumOrIDRaw(query string) (out interface{}, err error)

func (*API) GetCode

func (api *API) GetCode(account AccountName) (out *GetCodeResp, err error)

func (*API) GetCurrencyBalance

func (api *API) GetCurrencyBalance(account AccountName, symbol string, code AccountName) (out []Asset, err error)

func (*API) GetInfo

func (api *API) GetInfo() (out *InfoResp, err error)

func (*API) GetNetConnections

func (api *API) GetNetConnections() (out []*NetConnectionsResp, err error)

func (*API) GetNetStatus

func (api *API) GetNetStatus(host string) (out *NetStatusResp, err error)

func (*API) GetProducers

func (api *API) GetProducers() (out *ProducersResp, err error)

func (*API) GetRequiredKeys

func (api *API) GetRequiredKeys(tx *Transaction) (out *GetRequiredKeysResp, err error)

func (*API) GetTableRows

func (api *API) GetTableRows(params GetTableRowsRequest) (out *GetTableRowsResp, err error)

func (*API) GetTransaction

func (api *API) GetTransaction(id string) (out *TransactionResp, err error)

func (*API) GetTransactions

func (api *API) GetTransactions(name AccountName) (out *TransactionsResp, err error)

func (*API) IsProducerPaused

func (api *API) IsProducerPaused() (out bool, err error)

IsProducerPaused queries the blockchain for the pause statement of block production.

func (*API) ListKeys

func (api *API) ListKeys() (out []*ecc.PrivateKey, err error)

func (*API) NetConnect

func (api *API) NetConnect(host string) (out NetConnectResp, err error)

func (*API) NetDisconnect

func (api *API) NetDisconnect(host string) (out NetDisconnectResp, err error)

func (*API) ProducerPause

func (api *API) ProducerPause() error

ProducerPause will pause block production on a nodeos with `producer_api` plugin loaded.

func (*API) ProducerResume

func (api *API) ProducerResume() error

ProducerResume will resume block production on a nodeos with `producer_api` plugin loaded. Obviously, this needs to be a producing node on the producers schedule for it to do anything.

func (*API) PushTransaction

func (api *API) PushTransaction(tx *PackedTransaction) (out *PushTransactionFullResp, err error)

PushTransaction submits a properly filled (tapos), packed and signed transaction to the blockchain.

func (*API) SetCustomGetRequiredKeys

func (api *API) SetCustomGetRequiredKeys(f func(tx *Transaction) ([]ecc.PublicKey, error))

func (*API) SetSigner

func (api *API) SetSigner(s Signer)

func (*API) SignPushActions

func (api *API) SignPushActions(a ...*Action) (out *PushTransactionFullResp, err error)

SignPushActions will create a transaction, fill it with default values, sign it and submit it to the chain. It is the highest level function on top of the `/v1/chain/push_transaction` endpoint.

func (*API) SignPushActionsWithOpts

func (api *API) SignPushActionsWithOpts(actions []*Action, opts *TxOptions) (out *PushTransactionFullResp, err error)

func (*API) SignPushTransaction

func (api *API) SignPushTransaction(tx *Transaction, chainID SHA256Bytes, compression CompressionType) (out *PushTransactionFullResp, err error)

SignPushTransaction will sign a transaction and submit it to the chain.

func (*API) SignTransaction

func (api *API) SignTransaction(tx *Transaction, chainID SHA256Bytes, compression CompressionType) (*SignedTransaction, *PackedTransaction, error)

SignTransaction will sign and pack a transaction, but not submit to the chain. It lives on the `api` object because it might query the blockchain to learn which keys are required to sign this particular transaction.

You can override the way we request keys (which defaults to `api.GetRequiredKeys()`) with SetCustomGetRequiredKeys().

To sign a transaction, you need a Signer defined on the `API` object. See SetSigner.

func (*API) WalletImportKey

func (api *API) WalletImportKey(walletName, wifPrivKey string) (err error)

WalletImportKey loads a new WIF-encoded key into the wallet.

func (*API) WalletPublicKeys

func (api *API) WalletPublicKeys() (out []ecc.PublicKey, err error)

func (*API) WalletSignTransaction

func (api *API) WalletSignTransaction(tx *SignedTransaction, chainID []byte, pubKeys ...ecc.PublicKey) (out *WalletSignTransactionResp, err error)

type AccountName

type AccountName Name

func AN

func AN(in string) AccountName

type AccountResourceLimit

type AccountResourceLimit struct {
	Used      JSONInt64 `json:"used"`
	Available JSONInt64 `json:"available"`
	Max       JSONInt64 `json:"max"`
}

type AccountResp

type AccountResp struct {
	AccountName        AccountName          `json:"account_name"`
	Privileged         bool                 `json:"privileged"`
	LastCodeUpdate     JSONTime             `json:"last_code_update"`
	Created            JSONTime             `json:"created"`
	RAMQuota           int64                `json:"ram_quota"`
	RAMUsage           int64                `json:"ram_usage"`
	NetWeight          JSONInt64            `json:"net_weight"`
	CPUWeight          JSONInt64            `json:"cpu_weight"`
	NetLimit           AccountResourceLimit `json:"net_limit"`
	CPULimit           AccountResourceLimit `json:"cpu_limit"`
	Permissions        []Permission         `json:"permissions"`
	TotalResources     TotalResources       `json:"total_resources"`
	DelegatedBandwidth DelegatedBandwidth   `json:"delegated_bandwidth"`
	VoterInfo          VoterInfo            `json:"voter_info"`
}

type Action

type Action struct {
	Account       AccountName       `json:"account"`
	Name          ActionName        `json:"name"`
	Authorization []PermissionLevel `json:"authorization,omitempty"`
	ActionData
}

Action

func (Action) Digest

func (a Action) Digest() SHA256Bytes

func (*Action) MapToRegisteredAction

func (a *Action) MapToRegisteredAction() error

func (*Action) MarshalJSON

func (a *Action) MarshalJSON() ([]byte, error)

type ActionData

type ActionData struct {
	HexData HexBytes    `json:"hex_data,omitempty"`
	Data    interface{} `json:"data,omitempty" eos:"-"`
	// contains filtered or unexported fields
}

func NewActionData

func NewActionData(obj interface{}) ActionData

func (*ActionData) SetToServer

func (a *ActionData) SetToServer(toServer bool)

type ActionDef

type ActionDef struct {
	Name              ActionName `json:"name"`
	Type              string     `json:"type"`
	RicardianContract string     `json:"ricardian_contract"`
}

type ActionName

type ActionName Name

func ActN

func ActN(in string) ActionName

type ActionTrace

type ActionTrace struct {
	Receiver AccountName `json:"receiver"`
	// Action     Action       `json:"act"` // FIXME: how do we unpack that ? what's on the other side anyway?
	Console    string       `json:"console"`
	DataAccess []DataAccess `json:"data_access"`
}

type Asset

type Asset struct {
	Amount int64
	Symbol
}

NOTE: there's also ExtendedAsset which is a quantity with the attached contract (AccountName)

func NewAsset

func NewAsset(in string) (out Asset, err error)

NewAsset parses a string like `1000.0000 EOS` into a properly setup Asset

func NewEOSAsset

func NewEOSAsset(amount int64) Asset

func NewEOSAssetFromString

func NewEOSAssetFromString(amount string) (out Asset, err error)

func (Asset) Add

func (a Asset) Add(other Asset) Asset

func (Asset) MarshalJSON

func (a Asset) MarshalJSON() (data []byte, err error)

func (Asset) String

func (a Asset) String() string

func (Asset) Sub

func (a Asset) Sub(other Asset) Asset

func (*Asset) UnmarshalJSON

func (a *Asset) UnmarshalJSON(data []byte) error

type Authority

type Authority struct {
	Threshold uint32                  `json:"threshold"`
	Keys      []KeyWeight             `json:"keys,omitempty"`
	Accounts  []PermissionLevelWeight `json:"accounts,omitempty"`
	Waits     []WaitWeight            `json:"waits,omitempty"`
}

type BlockHeader

type BlockHeader struct {
	Timestamp        BlockTimestamp            `json:"timestamp"`
	Producer         AccountName               `json:"producer"`
	Confirmed        uint16                    `json:"confirmed"`
	Previous         SHA256Bytes               `json:"previous"`
	TransactionMRoot SHA256Bytes               `json:"transaction_mroot"`
	ActionMRoot      SHA256Bytes               `json:"action_mroot"`
	ScheduleVersion  uint32                    `json:"schedule_version"`
	NewProducers     *OptionalProducerSchedule `json:"new_producers" eos:"optional"`
	HeaderExtensions []*Extension              `json:"header_extensions"`
}

func (*BlockHeader) BlockID

func (b *BlockHeader) BlockID() (SHA256Bytes, error)

func (*BlockHeader) BlockNumber

func (b *BlockHeader) BlockNumber() uint32

type BlockResp

type BlockResp struct {
	SignedBlock
	ID              SHA256Bytes  `json:"id"`
	BlockNum        uint32       `json:"block_num"`
	RefBlockPrefix  uint32       `json:"ref_block_prefix"`
	BlockExtensions []*Extension `json:"block_extensions"`
}

type BlockTimestamp

type BlockTimestamp struct {
	time.Time
}

func (BlockTimestamp) MarshalJSON

func (t BlockTimestamp) MarshalJSON() ([]byte, error)

func (*BlockTimestamp) UnmarshalJSON

func (t *BlockTimestamp) UnmarshalJSON(data []byte) (err error)

type Bool

type Bool bool

func (*Bool) UnmarshalJSON

func (b *Bool) UnmarshalJSON(data []byte) error

type ChainSizeMessage

type ChainSizeMessage struct {
	LastIrreversibleBlockNum uint32      `json:"last_irreversible_block_num"`
	LastIrreversibleBlockID  SHA256Bytes `json:"last_irreversible_block_id"`
	HeadNum                  uint32      `json:"head_num"`
	HeadID                   SHA256Bytes `json:"head_id"`
}

func (*ChainSizeMessage) GetType

func (m *ChainSizeMessage) GetType() P2PMessageType

type ClausePair

type ClausePair struct {
	ID   string `json:"id"`
	Body string `json:"body"`
}

ClausePair represents clauses, related to Ricardian Contracts.

type CompressionType

type CompressionType uint8

func (CompressionType) MarshalJSON

func (c CompressionType) MarshalJSON() ([]byte, error)

func (CompressionType) String

func (c CompressionType) String() string

func (*CompressionType) UnmarshalJSON

func (c *CompressionType) UnmarshalJSON(data []byte) error

type Currency

type Currency struct {
	Precision uint8
	Name      CurrencyName
}

type CurrencyBalanceResp

type CurrencyBalanceResp struct {
	EOSBalance        Asset    `json:"eos_balance"`
	StakedBalance     Asset    `json:"staked_balance"`
	UnstakingBalance  Asset    `json:"unstaking_balance"`
	LastUnstakingTime JSONTime `json:"last_unstaking_time"`
}

type CurrencyName

type CurrencyName string

type Cycles

type Cycles []ShardSummary

type DataAccess

type DataAccess struct {
	Type     string      `json:"type"` // "write", "read"?
	Code     AccountName `json:"code"`
	Scope    AccountName `json:"scope"`
	Sequence int         `json:"sequence"`
}

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder implements the EOS unpacking, similar to FC_BUFFER

func NewDecoder

func NewDecoder(data []byte) *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode(v interface{}) (err error)

func (*Decoder) DecodeActions

func (d *Decoder) DecodeActions(decode bool)

func (*Decoder) DecodeP2PMessage

func (d *Decoder) DecodeP2PMessage(decode bool)

func (*Decoder) ReadBlockTimestamp

func (d *Decoder) ReadBlockTimestamp() (out BlockTimestamp, err error)

func (*Decoder) ReadBool

func (d *Decoder) ReadBool() (out bool, err error)

func (*Decoder) ReadByte

func (d *Decoder) ReadByte() (out byte, err error)

func (*Decoder) ReadByteArray

func (d *Decoder) ReadByteArray() (out []byte, err error)

func (*Decoder) ReadInt16

func (d *Decoder) ReadInt16() (out int16, err error)

func (*Decoder) ReadPublicKey

func (d *Decoder) ReadPublicKey() (out ecc.PublicKey, err error)

func (*Decoder) ReadSHA256Bytes

func (d *Decoder) ReadSHA256Bytes() (out SHA256Bytes, err error)

func (*Decoder) ReadSignature

func (d *Decoder) ReadSignature() (out ecc.Signature, err error)

func (*Decoder) ReadString

func (d *Decoder) ReadString() (out string, err error)

func (*Decoder) ReadTstamp

func (d *Decoder) ReadTstamp() (out Tstamp, err error)

func (*Decoder) ReadUint16

func (d *Decoder) ReadUint16() (out uint16, err error)

func (*Decoder) ReadUint32

func (d *Decoder) ReadUint32() (out uint32, err error)

func (*Decoder) ReadUint64

func (d *Decoder) ReadUint64() (out uint64, err error)

func (*Decoder) ReadUvarint

func (d *Decoder) ReadUvarint() (uint64, error)

func (*Decoder) Remaining

func (d *Decoder) Remaining() int

type DeferredTransaction

type DeferredTransaction struct {
	*Transaction

	SenderID   uint32      `json:"sender_id"`
	Sender     AccountName `json:"sender"`
	DelayUntil JSONTime    `json:"delay_until"`
}

type DelegatedBandwidth

type DelegatedBandwidth struct {
	From      AccountName `json:"from"`
	To        AccountName `json:"to"`
	NetWeight Asset       `json:"net_weight"`
	CPUWeight Asset       `json:"cpu_weight"`
}

type Encoder

type Encoder struct {
	Order binary.ByteOrder
	// contains filtered or unexported fields
}

-------------------------------------------------------------- Encoder implements the EOS packing, similar to FC_BUFFER --------------------------------------------------------------

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(v interface{}) (err error)

func (*Encoder) WriteBlockP2PMessageEnvelope

func (e *Encoder) WriteBlockP2PMessageEnvelope(envelope P2PMessageEnvelope) (err error)

func (*Encoder) WriteBlockTimestamp

func (e *Encoder) WriteBlockTimestamp(bt BlockTimestamp) (err error)

func (*Encoder) WriteBool

func (e *Encoder) WriteBool(b bool) (err error)

func (*Encoder) WriteByte

func (e *Encoder) WriteByte(b byte) (err error)

func (*Encoder) WriteByteArray

func (e *Encoder) WriteByteArray(b []byte) error

func (*Encoder) WriteInt16

func (e *Encoder) WriteInt16(i int16) (err error)

func (*Encoder) WriteName

func (e *Encoder) WriteName(name Name) error

func (*Encoder) WritePublicKey

func (e *Encoder) WritePublicKey(pk ecc.PublicKey) (err error)

func (*Encoder) WriteSHA256Bytes

func (e *Encoder) WriteSHA256Bytes(s SHA256Bytes) error

func (*Encoder) WriteSignature

func (e *Encoder) WriteSignature(s ecc.Signature) (err error)

func (*Encoder) WriteString

func (e *Encoder) WriteString(s string) (err error)

func (*Encoder) WriteTstamp

func (e *Encoder) WriteTstamp(t Tstamp) (err error)

func (*Encoder) WriteUVarInt

func (e *Encoder) WriteUVarInt(v int) (err error)

func (*Encoder) WriteUint16

func (e *Encoder) WriteUint16(i uint16) (err error)

func (*Encoder) WriteUint32

func (e *Encoder) WriteUint32(i uint32) (err error)

func (*Encoder) WriteUint64

func (e *Encoder) WriteUint64(i uint64) (err error)

type Extension

type Extension struct {
	Type uint16   `json:"type"`
	Data HexBytes `json:"data"`
}

type FieldDef

type FieldDef struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type GetABIResp

type GetABIResp struct {
	AccountName AccountName `json:"account_name"`
	ABI         ABI         `json:"abi"`
}

type GetCodeResp

type GetCodeResp struct {
	AccountName AccountName `json:"account_name"`
	CodeHash    string      `json:"code_hash"`
	WASM        string      `json:"wasm"`
	ABI         ABI         `json:"abi"`
}

type GetRequiredKeysResp

type GetRequiredKeysResp struct {
	RequiredKeys []ecc.PublicKey `json:"required_keys"`
}

type GetTableRowsRequest

type GetTableRowsRequest struct {
	JSON       bool   `json:"json"`
	Scope      string `json:"scope"`
	Code       string `json:"code"`
	Table      string `json:"table"`
	TableKey   string `json:"table_key"`
	LowerBound string `json:"lower_bound"`
	UpperBound string `json:"upper_bound"`
	Limit      uint32 `json:"limit,omitempty"` // defaults to 10 => chain_plugin.hpp:struct get_table_rows_params
}

type GetTableRowsResp

type GetTableRowsResp struct {
	More bool            `json:"more"`
	Rows json.RawMessage `json:"rows"` // defer loading, as it depends on `JSON` being true/false.
}

func (*GetTableRowsResp) BinaryToStructs

func (resp *GetTableRowsResp) BinaryToStructs(v interface{}) error

func (*GetTableRowsResp) JSONToStructs

func (resp *GetTableRowsResp) JSONToStructs(v interface{}) error

type Global

type Global struct {
	MaxBlockNetUsage               int       `json:"max_block_net_usage"`
	TargetBlockNetUsagePct         int       `json:"target_block_net_usage_pct"`
	MaxTransactionNetUsage         int       `json:"max_transaction_net_usage"`
	BasePerTransactionNetUsage     int       `json:"base_per_transaction_net_usage"`
	NetUsageLeeway                 int       `json:"net_usage_leeway"`
	ContextFreeDiscountNetUsageNum int       `json:"context_free_discount_net_usage_num"`
	ContextFreeDiscountNetUsageDen int       `json:"context_free_discount_net_usage_den"`
	MaxBlockCPUUsage               int       `json:"max_block_cpu_usage"`
	TargetBlockCPUUsagePct         int       `json:"target_block_cpu_usage_pct"`
	MaxTransactionCPUUsage         int       `json:"max_transaction_cpu_usage"`
	MinTransactionCPUUsage         int       `json:"min_transaction_cpu_usage"`
	MaxTransactionLifetime         int       `json:"max_transaction_lifetime"`
	DeferredTrxExpirationWindow    int       `json:"deferred_trx_expiration_window"`
	MaxTransactionDelay            int       `json:"max_transaction_delay"`
	MaxInlineActionSize            int       `json:"max_inline_action_size"`
	MaxInlineActionDepth           int       `json:"max_inline_action_depth"`
	MaxAuthorityDepth              int       `json:"max_authority_depth"`
	MaxRAMSize                     string    `json:"max_ram_size"`
	TotalRAMBytesReserved          JSONInt64 `json:"total_ram_bytes_reserved"`
	TotalRAMStake                  JSONInt64 `json:"total_ram_stake"`
	LastProducerScheduleUpdate     string    `json:"last_producer_schedule_update"`
	LastPervoteBucketFill          int64     `json:"last_pervote_bucket_fill,string"`
	PervoteBucket                  int       `json:"pervote_bucket"`
	PerblockBucket                 int       `json:"perblock_bucket"`
	TotalUnpaidBlocks              int       `json:"total_unpaid_blocks"`
	TotalActivatedStake            float64   `json:"total_activated_stake,string"`
	ThreshActivatedStakeTime       int64     `json:"thresh_activated_stake_time,string"`
	LastProducerScheduleSize       int       `json:"last_producer_schedule_size"`
	TotalProducerVoteWeight        float64   `json:"total_producer_vote_weight,string"`
	LastNameClose                  string    `json:"last_name_close"`
}

type GoAwayMessage

type GoAwayMessage struct {
	Reason GoAwayReason `json:"reason"`
	NodeID SHA256Bytes  `json:"node_id"`
}

func (*GoAwayMessage) GetType

func (m *GoAwayMessage) GetType() P2PMessageType

type GoAwayReason

type GoAwayReason uint8

type HandshakeMessage

type HandshakeMessage struct {
	// net_plugin/protocol.hpp handshake_message
	NetworkVersion           uint16        `json:"network_version"`
	ChainID                  SHA256Bytes   `json:"chain_id"`
	NodeID                   SHA256Bytes   `json:"node_id"` // sha256
	Key                      ecc.PublicKey `json:"key"`     // can be empty, producer key, or peer key
	Time                     Tstamp        `json:"time"`    // time?!
	Token                    SHA256Bytes   `json:"token"`   // digest of time to prove we own the private `key`
	Signature                ecc.Signature `json:"sig"`     // can be empty if no key, signature of the digest above
	P2PAddress               string        `json:"p2p_address"`
	LastIrreversibleBlockNum uint32        `json:"last_irreversible_block_num"`
	LastIrreversibleBlockID  SHA256Bytes   `json:"last_irreversible_block_id"`
	HeadNum                  uint32        `json:"head_num"`
	HeadID                   SHA256Bytes   `json:"head_id"`
	OS                       string        `json:"os"`
	Agent                    string        `json:"agent"`
	Generation               int16         `json:"generation"`
}

func (*HandshakeMessage) GetType

func (m *HandshakeMessage) GetType() P2PMessageType

func (*HandshakeMessage) String

func (m *HandshakeMessage) String() string

type HexBytes

type HexBytes []byte

func (HexBytes) MarshalJSON

func (t HexBytes) MarshalJSON() ([]byte, error)

func (*HexBytes) UnmarshalJSON

func (t *HexBytes) UnmarshalJSON(data []byte) (err error)

type IDListMode

type IDListMode byte

type InfoResp

type InfoResp struct {
	ServerVersion            string      `json:"server_version"` // "2cc40a4e"
	ChainID                  SHA256Bytes `json:"chain_id"`
	HeadBlockNum             uint32      `json:"head_block_num"`              // 2465669,
	LastIrreversibleBlockNum uint32      `json:"last_irreversible_block_num"` // 2465655
	LastIrreversibleBlockID  SHA256Bytes `json:"last_irreversible_block_id"`  // "00000008f98f0580d7efe7abc60abaaf8a865c9428a4267df30ff7d1937a1084"
	HeadBlockID              SHA256Bytes `json:"head_block_id"`               // "00259f856bfa142d1d60aff77e70f0c4f3eab30789e9539d2684f9f8758f1b88",
	HeadBlockTime            JSONTime    `json:"head_block_time"`             //  "2018-02-02T04:19:32"
	HeadBlockProducer        AccountName `json:"head_block_producer"`         // "inita"

	VirtualBlockCPULimit uint64 `json:"virtual_block_cpu_limit"`
	VirtualBlockNetLimit uint64 `json:"virtual_block_net_limit"`
	BlockCPULimit        uint64 `json:"block_cpu_limit"`
	BlockNetLimit        uint64 `json:"block_net_limit"`
}

type JSONFloat64

type JSONFloat64 float64

func (*JSONFloat64) UnmarshalJSON

func (f *JSONFloat64) UnmarshalJSON(data []byte) error

type JSONInt64

type JSONInt64 int64

func (*JSONInt64) UnmarshalJSON

func (i *JSONInt64) UnmarshalJSON(data []byte) error

type JSONTime

type JSONTime struct {
	time.Time
}

func (JSONTime) MarshalJSON

func (t JSONTime) MarshalJSON() ([]byte, error)

func (*JSONTime) UnmarshalJSON

func (t *JSONTime) UnmarshalJSON(data []byte) (err error)

type KeyBag

type KeyBag struct {
	Keys []*ecc.PrivateKey `json:"keys"`
}

KeyBag holds private keys in memory, for signing transactions.

func NewKeyBag

func NewKeyBag() *KeyBag

func (*KeyBag) Add

func (b *KeyBag) Add(wifKey string) error

func (*KeyBag) AvailableKeys

func (b *KeyBag) AvailableKeys() (out []ecc.PublicKey, err error)

func (*KeyBag) ImportFromFile

func (b *KeyBag) ImportFromFile(path string) error

func (*KeyBag) ImportPrivateKey

func (b *KeyBag) ImportPrivateKey(wifPrivKey string) (err error)

func (*KeyBag) Sign

func (b *KeyBag) Sign(tx *SignedTransaction, chainID []byte, requiredKeys ...ecc.PublicKey) (*SignedTransaction, error)

func (*KeyBag) SignDigest

func (b *KeyBag) SignDigest(digest []byte, requiredKey ecc.PublicKey) (ecc.Signature, error)

type KeyWeight

type KeyWeight struct {
	PublicKey ecc.PublicKey `json:"key"`
	Weight    uint16        `json:"weight"` // weight_type
}

type M

type M map[string]interface{}

type MessageReflectTypes

type MessageReflectTypes struct {
	Name        string
	ReflectType reflect.Type
}

type MyStruct

type MyStruct struct {
	Currency
	Balance uint64
}

type Name

type Name string

type NetConnectResp

type NetConnectResp string

type NetConnectionsResp

type NetConnectionsResp struct {
	Peer          string           `json:"peer"`
	Connecting    bool             `json:"connecting"`
	Syncing       bool             `json:"syncing"`
	LastHandshake HandshakeMessage `json:"last_handshake"`
}

NetConnectionResp

type NetDisconnectResp

type NetDisconnectResp string

type NetStatusResp

type NetStatusResp struct {
}

type NoticeMessage

type NoticeMessage struct {
	KnownTrx    OrderedBlockIDs `json:"known_trx"`
	KnownBlocks OrderedBlockIDs `json:"known_blocks"`
}

func (*NoticeMessage) GetType

func (m *NoticeMessage) GetType() P2PMessageType

type OptionalProducerSchedule

type OptionalProducerSchedule struct {
	ProducerSchedule
}

type OrderedBlockIDs

type OrderedBlockIDs struct {
	Unknown [3]byte       `json:"-"` ///// wuuttzthat?
	Mode    IDListMode    `json:"mode"`
	Pending uint32        `json:"pending"`
	IDs     []SHA256Bytes `json:"ids"`
}

type OrderedTransactionIDs

type OrderedTransactionIDs struct {
	Unknown [3]byte       `json:"-"` ///// WWUUuuuuuuuuuuuutzthat ?
	Mode    IDListMode    `json:"mode"`
	Pending uint32        `json:"pending"`
	IDs     []SHA256Bytes `json:"ids"`
}

type P2PMessage

type P2PMessage interface {
	GetType() P2PMessageType
}

type P2PMessageEnvelope

type P2PMessageEnvelope struct {
	Length     uint32         `json:"length"`
	Type       P2PMessageType `json:"type"`
	Payload    []byte         `json:"-"`
	P2PMessage P2PMessage     `json:"message" eos:"-"`
	Raw        []byte         `json:"-"`
}

func ReadP2PMessageData

func ReadP2PMessageData(r io.Reader) (envelope *P2PMessageEnvelope, err error)

type P2PMessageType

type P2PMessageType byte
const (
	HandshakeMessageType P2PMessageType = iota // 0
	ChainSizeType
	GoAwayMessageType // 2
	TimeMessageType
	NoticeMessageType // 4
	RequestMessageType
	SyncRequestMessageType       // 6
	SignedBlockType              // 7
	PackedTransactionMessageType // 8
)

func NewMessageType

func NewMessageType(aType byte) (t P2PMessageType, err error)

func (P2PMessageType) Name

func (t P2PMessageType) Name() (string, bool)

type PackedTransaction

type PackedTransaction struct {
	Signatures            []ecc.Signature `json:"signatures"`
	Compression           CompressionType `json:"compression"` // in C++, it's an enum, not sure how it Binary-marshals..
	PackedContextFreeData HexBytes        `json:"packed_context_free_data"`
	PackedTransaction     HexBytes        `json:"packed_trx"`
}

PackedTransaction represents a fully packed transaction, with signatures, and all. They circulate like that on the P2P net, and that's how they are stored.

func (*PackedTransaction) ID

func (*PackedTransaction) Unpack

func (p *PackedTransaction) Unpack() (signedTx *SignedTransaction, err error)

type PackedTransactionMessage

type PackedTransactionMessage struct {
	PackedTransaction
}

func (*PackedTransactionMessage) GetType

type Permission

type Permission struct {
	PermName     string    `json:"perm_name"`
	Parent       string    `json:"parent"`
	RequiredAuth Authority `json:"required_auth"`
}

type PermissionLevel

type PermissionLevel struct {
	Actor      AccountName    `json:"actor"`
	Permission PermissionName `json:"permission"`
}

func NewPermissionLevel

func NewPermissionLevel(in string) (out PermissionLevel, err error)

NewPermissionLevel parses strings like `account@active`, `otheraccount@owner` and builds a PermissionLevel struct. It validates that there is a single optional @ (where permission defaults to 'active'), and validates length of account and permission names.

type PermissionLevelWeight

type PermissionLevelWeight struct {
	Permission PermissionLevel `json:"permission"`
	Weight     uint16          `json:"weight"` // weight_type
}

type PermissionName

type PermissionName Name

func PN

func PN(in string) PermissionName

type ProcessedTransaction

type ProcessedTransaction struct {
	Transaction SignedTransaction `json:"trx"`
}

type Producer

type Producer struct {
	Owner         string      `json:"owner"`
	TotalVotes    float64     `json:"total_votes,string"`
	ProducerKey   string      `json:"producer_key"`
	IsActive      int         `json:"is_active"`
	URL           string      `json:"url"`
	UnpaidBlocks  int         `json:"unpaid_blocks"`
	LastClaimTime JSONFloat64 `json:"last_claim_time"`
	Location      int         `json:"location"`
}

type ProducerChange

type ProducerChange struct {
}

type ProducerKey

type ProducerKey struct {
	AccountName     AccountName   `json:"account_name"`
	BlockSigningKey ecc.PublicKey `json:"block_signing_key"`
}

type ProducerSchedule

type ProducerSchedule struct {
	Version   uint32        `json:"version"`
	Producers []ProducerKey `json:"producers"`
}

type ProducersResp

type ProducersResp struct {
	Producers []Producer `json:"producers"`
}

type PushTransactionFullResp

type PushTransactionFullResp struct {
	StatusCode    string
	TransactionID string               `json:"transaction_id"`
	Processed     TransactionProcessed `json:"processed"` // WARN: is an `fc::variant` in server..
}

PushTransactionFullResp unwraps the responses from a successful `push_transaction`. FIXME: REVIEW the actual output, things have moved here.

type PushTransactionShortResp

type PushTransactionShortResp struct {
	TransactionID string `json:"transaction_id"`
	Processed     bool   `json:"processed"` // WARN: is an `fc::variant` in server..
}

type RegionSummary

type RegionSummary struct {
	Region        uint16   `json:"region"`
	CyclesSummary []Cycles `json:"cycles_summary"`
}

type RequestMessage

type RequestMessage struct {
	ReqTrx    OrderedBlockIDs `json:"req_trx"`
	ReqBlocks OrderedBlockIDs `json:"req_blocks"`
}

func (*RequestMessage) GetType

func (m *RequestMessage) GetType() P2PMessageType

type SHA256Bytes

type SHA256Bytes []byte // should always be 32 bytes

func (SHA256Bytes) MarshalJSON

func (t SHA256Bytes) MarshalJSON() ([]byte, error)

func (*SHA256Bytes) UnmarshalJSON

func (t *SHA256Bytes) UnmarshalJSON(data []byte) (err error)

type ScopeName

type ScopeName Name

type SequencedTransactionResp

type SequencedTransactionResp struct {
	SeqNum int `json:"seq_num"`
	TransactionResp
}

type SetABI

type SetABI struct {
	Account AccountName `json:"account"`
	ABI     ABI         `json:"abi"`
}

SetABI represents the hard-coded `setabi` action.

type SetCode

type SetCode struct {
	Account   AccountName `json:"account"`
	VMType    byte        `json:"vmtype"`
	VMVersion byte        `json:"vmversion"`
	Code      HexBytes    `json:"bytes"`
}

SetCode represents the hard-coded `setcode` action.

type ShardLock

type ShardLock struct {
	AccountName AccountName `json:"account_name"`
	ScopeName   ScopeName   `json:"scope_name"`
}

type ShardSummary

type ShardSummary struct {
	ReadLocks    []ShardLock          `json:"read_locks"`
	WriteLocks   []ShardLock          `json:"write_locks"`
	Transactions []TransactionReceipt `json:"transactions"`
}

type SignedBlock

type SignedBlock struct {
	SignedBlockHeader
	Transactions    []TransactionReceipt `json:"transactions"`
	BlockExtensions []*Extension         `json:"block_extensions"`
}

func (*SignedBlock) GetType

func (m *SignedBlock) GetType() P2PMessageType

func (*SignedBlock) String

func (m *SignedBlock) String() string

type SignedBlockHeader

type SignedBlockHeader struct {
	BlockHeader
	ProducerSignature ecc.Signature `json:"producer_signature"`
}

type SignedTransaction

type SignedTransaction struct {
	*Transaction

	Signatures      []ecc.Signature `json:"signatures"`
	ContextFreeData []HexBytes      `json:"context_free_data"`
	// contains filtered or unexported fields
}

func NewSignedTransaction

func NewSignedTransaction(tx *Transaction) *SignedTransaction

func (*SignedTransaction) Pack

func (s *SignedTransaction) Pack(compression CompressionType) (*PackedTransaction, error)

func (*SignedTransaction) PackedTransactionAndCFD

func (s *SignedTransaction) PackedTransactionAndCFD() ([]byte, []byte, error)

func (*SignedTransaction) SignedByKeys

func (s *SignedTransaction) SignedByKeys(chainID SHA256Bytes) (out []ecc.PublicKey, err error)

func (*SignedTransaction) String

func (s *SignedTransaction) String() string

type SignedTransactionMessage

type SignedTransactionMessage struct {
	Signatures      []ecc.Signature `json:"signatures"`
	ContextFreeData []byte          `json:"context_free_data"`
}

type Signer

type Signer interface {
	AvailableKeys() (out []ecc.PublicKey, err error)

	// Sign signs a `tx` transaction. It gets passed a
	// SignedTransaction because it is possible that it holds a few
	// signatures and requests this wallet only to add one or more
	// signatures it requires.
	Sign(tx *SignedTransaction, chainID []byte, requiredKeys ...ecc.PublicKey) (*SignedTransaction, error)

	ImportPrivateKey(wifPrivKey string) error
}

type StructDef

type StructDef struct {
	Name   string     `json:"name"`
	Base   string     `json:"base"`
	Fields []FieldDef `json:"fields,omitempty"`
}

type Symbol

type Symbol struct {
	Precision uint8
	Symbol    string
}

NOTE: there's also a new ExtendedSymbol (which includes the contract (as AccountName) on which it is)

type SyncRequestMessage

type SyncRequestMessage struct {
	StartBlock uint32 `json:"start_block"`
	EndBlock   uint32 `json:"end_block"`
}

func (*SyncRequestMessage) GetType

func (m *SyncRequestMessage) GetType() P2PMessageType

func (*SyncRequestMessage) String

func (m *SyncRequestMessage) String() string

type TableDef

type TableDef struct {
	Name      TableName `json:"name"`
	IndexType string    `json:"index_type"`
	KeyNames  []string  `json:"key_names,omitempty"`
	KeyTypes  []string  `json:"key_types,omitempty"`
	Type      string    `json:"type"`
}

TableDef defines a table. See libraries/chain/include/eosio/chain/contracts/types.hpp:78

type TableName

type TableName Name

type TimeMessage

type TimeMessage struct {
	Origin      Tstamp `json:"org"`
	Receive     Tstamp `json:"rec"`
	Transmit    Tstamp `json:"xmt"`
	Destination Tstamp `json:"dst"`
}

func (*TimeMessage) GetType

func (m *TimeMessage) GetType() P2PMessageType

func (*TimeMessage) String

func (t *TimeMessage) String() string

type TotalResources

type TotalResources struct {
	Owner     AccountName `json:"owner"`
	NetWeight Asset       `json:"net_weight"`
	CPUWeight Asset       `json:"cpu_weight"`
	RAMBytes  JSONInt64   `json:"ram_bytes"`
}

type Transaction

type Transaction struct {
	TransactionHeader

	ContextFreeActions []*Action    `json:"context_free_actions"`
	Actions            []*Action    `json:"actions"`
	Extensions         []*Extension `json:"transaction_extensions"`
}

func NewTransaction

func NewTransaction(actions []*Action, opts *TxOptions) *Transaction

NewTransaction creates a transaction. Unless you plan on adding HeadBlockID later, to be complete, opts should contain it. Sign

func (*Transaction) Fill

func (tx *Transaction) Fill(headBlockID SHA256Bytes, delaySecs, maxNetUsageWords uint32, maxCPUUsageMS uint8)

Fill sets the fields on a transaction. If you pass `headBlockID`, then `api` can be nil. If you don't pass `headBlockID`, then the `api` is going to be called to fetch

func (*Transaction) ID

func (tx *Transaction) ID() string

func (*Transaction) SetRefBlock

func (tx *Transaction) SetRefBlock(blockID []byte)

type TransactionHeader

type TransactionHeader struct {
	Expiration     JSONTime `json:"expiration"`
	RefBlockNum    uint16   `json:"ref_block_num"`
	RefBlockPrefix uint32   `json:"ref_block_prefix"`

	MaxNetUsageWords Varuint32 `json:"max_net_usage_words"`
	MaxCPUUsageMS    uint8     `json:"max_cpu_usage_ms"`
	DelaySec         Varuint32 `json:"delay_sec"` // number of secs to delay, making it cancellable for that duration
}

type TransactionProcessed

type TransactionProcessed struct {
	Status               string        `json:"status"`
	ID                   SHA256Bytes   `json:"id"`
	ActionTraces         []ActionTrace `json:"action_traces"`
	DeferredTransactions []string      `json:"deferred_transactions"` // that's not right... dig to find what's there..
}

type TransactionReceipt

type TransactionReceipt struct {
	TransactionReceiptHeader
	Transaction TransactionWithID `json:"trx"`
}

type TransactionReceiptHeader

type TransactionReceiptHeader struct {
	Status               TransactionStatus `json:"status"`
	CPUUsageMicroSeconds uint32            `json:"cpu_usage_us"`
	NetUsageWords        Varuint32         `json:"net_usage_words"`
}

type TransactionResp

type TransactionResp struct {
	ID      SHA256Bytes `json:"id"`
	Receipt struct {
		Status            TransactionStatus `json:"status"`
		CPUUsageMicrosec  int               `json:"cpu_usage_us"`
		NetUsageWords     int               `json:"net_usage_words"`
		PackedTransaction TransactionWithID `json:"trx"`
	} `json:"receipt"`
	Transaction           ProcessedTransaction `json:"trx"`
	BlockTime             JSONTime             `json:"block_time"`
	BlockNum              uint32               `json:"block_num"`
	LastIrreversibleBlock uint32               `json:"last_irreversible_block"`
	Traces                []TransactionTrace   `json:"traces"`
}

type TransactionStatus

type TransactionStatus uint8
const (
	TransactionStatusExecuted TransactionStatus = iota ///< succeed, no error handler executed
	TransactionStatusSoftFail                          ///< objectively failed (not executed), error handler executed
	TransactionStatusHardFail                          ///< objectively failed and error handler objectively failed thus no state change
	TransactionStatusDelayed                           ///< transaction delayed
	TransactionStatusUnknown  = TransactionStatus(255)
)

func (TransactionStatus) MarshalJSON

func (s TransactionStatus) MarshalJSON() (data []byte, err error)

func (TransactionStatus) String

func (s TransactionStatus) String() string

func (*TransactionStatus) UnmarshalJSON

func (s *TransactionStatus) UnmarshalJSON(data []byte) error

type TransactionTrace

type TransactionTrace struct {
	Receipt struct {
		Receiver        AccountName                    `json:"receiver"`
		ActionDigest    string                         `json:"act_digest"`
		GlobalSequence  int64                          `json:"global_sequence"`
		ReceiveSequence int64                          `json:"recv_sequence"`
		AuthSequence    []TransactionTraceAuthSequence `json:"auth_sequence"` // [["account", sequence], ["account", sequence]]
		CodeSequence    int64                          `json:"code_sequence"`
		ABISequence     int64                          `json:"abi_sequence"`
	} `json:"receipt"`
	Action        *Action             `json:"act"`
	Elapsed       int                 `json:"elapsed"`
	CPUUsage      int                 `json:"cpu_usage"`
	Console       string              `json:"console"`
	TotalCPUUsage int                 `json:"total_cpu_usage"`
	TransactionID SHA256Bytes         `json:"trx_id"`
	InlineTraces  []*TransactionTrace `json:"inline_traces"`
}

type TransactionTraceAuthSequence

type TransactionTraceAuthSequence struct {
	Account  AccountName
	Sequence int64
}

func (TransactionTraceAuthSequence) MarshalJSON

func (auth TransactionTraceAuthSequence) MarshalJSON() (data []byte, err error)

func (*TransactionTraceAuthSequence) UnmarshalJSON

func (auth *TransactionTraceAuthSequence) UnmarshalJSON(data []byte) error

[ ["account", 123123], ["account2", 345] ]

type TransactionWithID

type TransactionWithID struct {
	ID     SHA256Bytes
	Packed *PackedTransaction
}

func (TransactionWithID) MarshalJSON

func (t TransactionWithID) MarshalJSON() ([]byte, error)

func (*TransactionWithID) UnmarshalJSON

func (t *TransactionWithID) UnmarshalJSON(data []byte) error

type TransactionsResp

type TransactionsResp struct {
	Transactions []SequencedTransactionResp
}

type Tstamp

type Tstamp struct {
	time.Time
}

func (Tstamp) MarshalJSON

func (t Tstamp) MarshalJSON() ([]byte, error)

func (*Tstamp) UnmarshalJSON

func (t *Tstamp) UnmarshalJSON(data []byte) (err error)

type TxOptions

type TxOptions struct {
	ChainID          SHA256Bytes // If specified, we won't hit the API to fetch it
	HeadBlockID      SHA256Bytes // If provided, don't hit API to fetch it.  This allows offline transaction signing.
	MaxNetUsageWords uint32
	DelaySecs        uint32
	MaxCPUUsageMS    uint8 // If you want to override the CPU usage (in counts of 1024)
	//ExtraKCPUUsage uint32 // If you want to *add* some CPU usage to the estimated amount (in counts of 1024)
	Compress CompressionType
}

TxOptions represents options you want to pass to the transaction you're sending.

func (*TxOptions) FillFromChain

func (opts *TxOptions) FillFromChain(api *API) error

FillFromChain will load ChainID (for signing transactions) and HeadBlockID (to fill transaction with TaPoS data).

type Varuint32

type Varuint32 uint32

type VoterInfo

type VoterInfo struct {
	Owner             AccountName    `json:"owner"`
	Proxy             AccountName    `json:"proxy"`
	Producers         []AccountName  `json:"producers"`
	Staked            JSONInt64      `json:"staked"`
	LastVoteWeight    JSONFloat64    `json:"last_vote_weight"`
	ProxiedVoteWeight JSONFloat64    `json:"proxied_vote_weight"`
	IsProxy           byte           `json:"is_proxy"`
	DeferredTrxID     uint32         `json:"deferred_trx_id"`
	LastUnstakeTime   BlockTimestamp `json:"last_unstake_time"`
	Unstaking         Asset          `json:"unstaking"`
}

type WaitWeight

type WaitWeight struct {
	WaitSec uint32 `json:"wait_sec"`
	Weight  uint16 `json:"weight"` // weight_type
}

type WalletSignTransactionResp

type WalletSignTransactionResp struct {
	Signatures []ecc.Signature `json:"signatures"`
}

type WalletSigner

type WalletSigner struct {
	// contains filtered or unexported fields
}

`eosiowd` wallet-based signer

func NewWalletSigner

func NewWalletSigner(api *API, walletName string) *WalletSigner

NewWalletSigner takes an `api`, because often the wallet will be a second endpoint, and not the server node with whom you're pushing transactions to.

func (*WalletSigner) AvailableKeys

func (s *WalletSigner) AvailableKeys() (out []ecc.PublicKey, err error)

func (*WalletSigner) ImportPrivateKey

func (s *WalletSigner) ImportPrivateKey(wifKey string) (err error)

func (*WalletSigner) Sign

func (s *WalletSigner) Sign(tx *SignedTransaction, chainID []byte, requiredKeys ...ecc.PublicKey) (*SignedTransaction, error)

Jump to

Keyboard shortcuts

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