continuum

package module
v0.0.0-...-7d53c9d Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2022 License: GPL-3.0 Imports: 15 Imported by: 0

README

continuum-go-sdk

Golang SDK for working with Continuum node

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SignatureFunc

func SignatureFunc(account *types.Account, hash types.Hash) (types.Signature, error)

Types

type APIAccount

type APIAccount struct {
	Address        types.Address   `json:"account"`
	CoinBalance    *types.Balance  `json:"coinBalance,omitempty"`
	CoinVote       *types.Balance  `json:"vote,omitempty"`
	CoinNetwork    *types.Balance  `json:"network,omitempty"`
	CoinStorage    *types.Balance  `json:"storage,omitempty"`
	CoinOracle     *types.Balance  `json:"oracle,omitempty"`
	Representative *types.Address  `json:"representative,omitempty"`
	Tokens         []*APITokenMeta `json:"tokens"`
}

type APIAccountBalance

type APIAccountBalance struct {
	Address types.Address `json:"address"`
	Balance types.Balance `json:"balance"`
}

type APIAccountsBalance

type APIAccountsBalance struct {
	Balance types.Balance  `json:"balance"`
	Vote    *types.Balance `json:"vote,omitempty"`
	Network *types.Balance `json:"network,omitempty"`
	Storage *types.Balance `json:"storage,omitempty"`
	Oracle  *types.Balance `json:"oracle,omitempty"`
	Pending types.Balance  `json:"pending"`
}

type APIBalance

type APIBalance struct {
	*big.Float
}

func (*APIBalance) MarshalText

func (b *APIBalance) MarshalText() ([]byte, error)

func (*APIBalance) String

func (b *APIBalance) String() string

type APIBlock

type APIBlock struct {
	*types.StateBlock
	TokenName string        `json:"tokenName"`
	Amount    types.Balance `json:"amount"`
	Hash      types.Hash    `json:"hash"`

	PovConfirmHeight uint64 `json:"povConfirmHeight"`
	PovConfirmCount  uint64 `json:"povConfirmCount"`
}

type APIDestroyInfo

type APIDestroyInfo struct {
	Owner     types.Address `json:"owner"`
	Previous  types.Hash    `json:"previous"`
	Token     types.Hash    `json:"token"`
	Amount    *big.Int      `json:"amount"`
	TimeStamp int64         `json:"timestamp"`
}

type APIDestroyParam

type APIDestroyParam struct {
	Owner    types.Address   `json:"owner"`
	Previous types.Hash      `json:"previous"`
	Token    types.Hash      `json:"token"`
	Amount   *big.Int        `json:"amount"`
	Sign     types.Signature `json:"signature"`
}

func (*APIDestroyParam) Signature

func (param *APIDestroyParam) Signature(acc *types.Account) (types.Signature, error)

func (*APIDestroyParam) Verify

func (param *APIDestroyParam) Verify(c *rpc.Client) (bool, error)

Verify destroy params

type APIPending

type APIPending struct {
	*types.PendingKey
	*types.PendingInfo
	TokenName string          `json:"tokenName"`
	Timestamp int64           `json:"timestamp"`
	BlockType types.BlockType `json:"blockType"`
}

type APIRepresentative

type APIRepresentative struct {
	Address types.Address `json:"address"`
	Balance types.Balance `json:"balance"`
	Vote    types.Balance `json:"vote"`
	Network types.Balance `json:"network"`
	Storage types.Balance `json:"storage"`
	Oracle  types.Balance `json:"oracle"`
	Total   types.Balance `json:"total"`
}

type APISendBlockPara

type APISendBlockPara struct {
	From      types.Address `json:"from"`
	TokenName string        `json:"tokenName"`
	To        types.Address `json:"to"`
	Amount    types.Balance `json:"amount"`
	Sender    string        `json:"sender"`
	Receiver  string        `json:"receiver"`
	Message   types.Hash    `json:"message"`
}

type APITokenMeta

type APITokenMeta struct {
	*types.TokenMeta
	TokenName string        `json:"tokenName"`
	Pending   types.Balance `json:"pending"`
}

type AccountApi

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

func NewAccountAPI

func NewAccountAPI(c *Client) *AccountApi

NewAccountAPI creates account module for client

func (*AccountApi) Create

func (a *AccountApi) Create(seedStr string, index uint32) (map[string]string, error)

Create gets account by index from seed

func (*AccountApi) ForPublicKey

func (a *AccountApi) ForPublicKey(pubStr string) (types.Address, error)

ForPublicKey returns address for public key

func (*AccountApi) NewSeed

func (a *AccountApi) NewSeed() (string, error)

NewSeed generates new seed

func (*AccountApi) PublicKey

func (a *AccountApi) PublicKey(addr types.Address) string

PublicKey returns public key for address

func (*AccountApi) Validate

func (a *AccountApi) Validate(addr string) bool

Validate accepts a address string and checks if it's valid.

type ApiTokenInfo

type ApiTokenInfo struct {
	types.TokenInfo
}

type BlockSubscription

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

type Client

type Client struct {
	Account  *AccountApi
	Contract *ContractApi
	Ledger   *LedgerApi
	Mintage  *MintageApi
	Pledge   *PledgeApi
	Rewards  *RewardsApi
	Network  *NetApi
	Util     *UtilApi
	Destroy  *DestroyApi
	Debug    *DebugApi
	Pov      *PovApi
	Miner    *MinerApi
	Rep      *RepApi
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint string) (*Client, error)

NewClient creates a new client

func (*Client) Close

func (c *Client) Close() error

type ContractApi

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

func NewContractAPI

func NewContractAPI(c *Client) *ContractApi

NewContractAPI creates contract module for client

func (*ContractApi) ContractAddressList

func (c *ContractApi) ContractAddressList() []types.Address

ContractAddressList return all contract addresses

func (*ContractApi) GenerateRewardBlock

func (c *ContractApi) GenerateRewardBlock(para *ContractRewardBlockPara) (*types.StateBlock, error)

GenerateRewardBlock return new generated ContractReward block

func (*ContractApi) GenerateSendBlock

func (c *ContractApi) GenerateSendBlock(para *ContractSendBlockPara) (*types.StateBlock, error)

GenerateSendBlock return new generated ContractSend block

func (*ContractApi) GetAbiByContractAddress

func (c *ContractApi) GetAbiByContractAddress(address types.Address) (string, error)

GetAbiByContractAddress return contract abi by contract address

func (*ContractApi) PackChainContractData

func (c *ContractApi) PackChainContractData(contractAddress types.Address, methodName string, params []string) ([]byte, error)

PackChainContractData pack the given method name to conform the ABI for chain contract.

func (*ContractApi) PackContractData

func (c *ContractApi) PackContractData(abiStr string, methodName string, params []string) ([]byte, error)

PackContractData parse a ABI interface and pack the given method name to conform the ABI.

type ContractRewardBlockPara

type ContractRewardBlockPara struct {
	SendHash types.Hash `json:"sendHash"`
}

type ContractSendBlockPara

type ContractSendBlockPara struct {
	Address   types.Address `json:"address"`
	TokenName string        `json:"tokenName"`
	To        types.Address `json:"to"`
	Amount    types.Balance `json:"amount"`
	Data      []byte        `json:"data"`

	PrivateFrom    string   `json:"privateFrom,omitempty"`
	PrivateFor     []string `json:"privateFor,omitempty"`
	PrivateGroupID string   `json:"privateGroupID,omitempty"`
	EnclaveKey     []byte   `json:"enclaveKey,omitempty"`
}

type DebugApi

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

func NewDebugAPI

func NewDebugAPI(c *Client) *DebugApi

func (*DebugApi) BlockCacheCount

func (l *DebugApi) BlockCacheCount() (map[string]uint64, error)
func (l *DebugApi) BlockLink(hash types.Hash) (map[string]types.Hash, error)

type DestroyApi

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

func NewDestroyAPI

func NewDestroyAPI(c *Client) *DestroyApi

NewDestroyAPI creates destroy module for client

func (*DestroyApi) GetDestroyInfoDetail

func (b *DestroyApi) GetDestroyInfoDetail(addr *types.Address) ([]*APIDestroyInfo, error)

GetDestroyInfoDetail returns detail info of qgas destroyed

func (*DestroyApi) GetRewardsBlock

func (b *DestroyApi) GetRewardsBlock(send *types.Hash) (*types.StateBlock, error)

GetRewardBlock returns contract reward block by destory contract send

func (*DestroyApi) GetSendBlock

func (b *DestroyApi) GetSendBlock(param *APIDestroyParam, sign SignatureParam) (*types.StateBlock, error)

GetSendBlock returns destory contract send block by destory parameters

func (*DestroyApi) GetTotalDestroyInfo

func (b *DestroyApi) GetTotalDestroyInfo(addr *types.Address) (types.Balance, error)

GetTotalDestroyInfo returns total amount of qgas destroyed

type LedgerApi

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

func NewLedgerAPI

func NewLedgerAPI(url string, c *Client) *LedgerApi

NewLedgerAPI creates ledger module for client

func (*LedgerApi) AccountBlocksCount

func (l *LedgerApi) AccountBlocksCount(address types.Address) (int64, error)

AccountBlocksCount returns number of blocks for a specific account of chain

func (*LedgerApi) AccountHistoryTopn

func (l *LedgerApi) AccountHistoryTopn(address types.Address, count int, offset int) ([]*APIBlock, error)

AccountHistoryTopn returns blocks list for a specific account of chain count is number of blocks to return, and offset is index of block where to start

func (*LedgerApi) AccountInfo

func (l *LedgerApi) AccountInfo(address types.Address) (*APIAccount, error)

AccountInfo returns account detail info, include each token meta for the account If account not found, will return error

func (*LedgerApi) AccountRepresentative

func (l *LedgerApi) AccountRepresentative(address types.Address) (types.Address, error)

AccountRepresentative returns the representative address for account If account not found, will return error

func (*LedgerApi) AccountVotingWeight

func (l *LedgerApi) AccountVotingWeight(address types.Address) (types.Balance, error)

AccountVotingWeight returns the voting weight for account If account not found, will return error

func (*LedgerApi) Accounts

func (l *LedgerApi) Accounts(count int, offset int) ([]types.Address, error)

Accounts returns accounts list of chain count is number of accounts to return, and offset is index of account where to start

func (*LedgerApi) AccountsBalance

func (l *LedgerApi) AccountsBalance(addresses []types.Address) (map[types.Address]map[string]*APIAccountsBalance, error)

AccountsBalance returns balance and pending(amount that has not yet been received) for each account

func (*LedgerApi) AccountsCount

func (l *LedgerApi) AccountsCount() (uint64, error)

AccountsCount returns total number of accounts of chain

func (*LedgerApi) AccountsFrontiers

func (l *LedgerApi) AccountsFrontiers(addresses []types.Address) (map[types.Address]map[string]types.Hash, error)

AccountsFrontiers returns frontier info for each token of account

func (*LedgerApi) AccountsPending

func (l *LedgerApi) AccountsPending(addresses []types.Address, n int) (map[types.Address][]*APIPending, error)

AccountsPending returns pending info list for each account maximum number of pending for each account return is n, and if n set to -1, will return all pending for each account

func (*LedgerApi) AllGenesisBlocks

func (l *LedgerApi) AllGenesisBlocks() ([]*types.StateBlock, error)

func (*LedgerApi) BalanceChange

func (l *LedgerApi) BalanceChange(ch chan *types.AccountMeta, address types.Address) (*Subscribe, error)

BalanceChange support publish/subscription, ch is AccountMeta channel, once the balance of a account change, set the newest account info to channel

func (*LedgerApi) BlockAccount

func (l *LedgerApi) BlockAccount(hash types.Hash) (types.Address, error)

BlockAccount accepts a block hash, and returns account of block owner

func (*LedgerApi) BlockConfirmedStatus

func (l *LedgerApi) BlockConfirmedStatus(hash types.Hash) (bool, error)

Return block confirmed status, if block confirmed,return `true`,otherwise return `false`

func (*LedgerApi) BlockHash

func (l *LedgerApi) BlockHash(block types.StateBlock) types.Hash

BlockHash return hash of block

func (*LedgerApi) BlockInfo

func (l *LedgerApi) BlockInfo(hash types.Hash) (*APIBlock, error)

BlockInfo accepts a block hash, and returns block info for the hash

func (*LedgerApi) BlockSubscription

func (l *LedgerApi) BlockSubscription(address types.Address) (*BlockSubscription, error)

func (*LedgerApi) Blocks

func (l *LedgerApi) Blocks(count int, offset int) ([]*APIBlock, error)

Blocks returns blocks list of chain count is number of blocks to return, and offset is index of block where to start

func (*LedgerApi) BlocksCount

func (l *LedgerApi) BlocksCount() (map[string]uint64, error)

BlocksCount returns the number of blocks(include smartcontract block) and unchecked blocks of chain

func (*LedgerApi) BlocksCountByType

func (l *LedgerApi) BlocksCountByType() (map[string]uint64, error)

BlocksCountByType returns number of blocks by type of chain

func (*LedgerApi) BlocksInfo

func (l *LedgerApi) BlocksInfo(hash []types.Hash) ([]*APIBlock, error)

BlocksInfo accepts blocks hash list, and returns block info for each hash

func (*LedgerApi) Chain

func (l *LedgerApi) Chain(hash types.Hash, n int) ([]types.Hash, error)

Chain returns a consecutive block hash list for a specific hash maximum number of blocks hash to return is n, and if n set to -1, will return blocks hash to the open block

func (*LedgerApi) ChainToken

func (l *LedgerApi) ChainToken() (*types.Hash, error)

func (*LedgerApi) ConfirmedAccountInfo

func (l *LedgerApi) ConfirmedAccountInfo(address types.Address) (*APIAccount, error)

Return confirmed account detail info , include each token in the account

func (*LedgerApi) Delegators

func (l *LedgerApi) Delegators(hash types.Address) ([]*APIAccountBalance, error)

Delegators accepts a representative account, and returns its delegator and each delegator's balance

func (*LedgerApi) DelegatorsCount

func (l *LedgerApi) DelegatorsCount(hash types.Address) (int64, error)

DelegatorsCount gets number of delegators for specific representative account

func (*LedgerApi) GasAddress

func (l *LedgerApi) GasAddress() (*types.Address, error)

func (*LedgerApi) GasBlock

func (l *LedgerApi) GasBlock() (*types.StateBlock, error)

func (*LedgerApi) GasBlockHash

func (l *LedgerApi) GasBlockHash() (*types.Hash, error)

func (*LedgerApi) GasMintageBlock

func (l *LedgerApi) GasMintageBlock() (*types.StateBlock, error)

func (*LedgerApi) GasToken

func (l *LedgerApi) GasToken() (*types.Hash, error)

func (*LedgerApi) GenerateAndProcessChangeBlock

func (l *LedgerApi) GenerateAndProcessChangeBlock(account, representative types.Address, sign Signature) (types.Hash, error)

func (*LedgerApi) GenerateAndProcessReceiveBlock

func (l *LedgerApi) GenerateAndProcessReceiveBlock(txBlock *types.StateBlock, sign Signature) (types.Hash, error)

func (*LedgerApi) GenerateAndProcessReceiveBlockByHash

func (l *LedgerApi) GenerateAndProcessReceiveBlockByHash(txHash types.Hash, sign Signature) (types.Hash, error)

func (*LedgerApi) GenerateAndProcessSendBlock

func (l *LedgerApi) GenerateAndProcessSendBlock(para *APISendBlockPara, sign Signature) (types.Hash, error)

func (*LedgerApi) GenerateChangeBlock

func (l *LedgerApi) GenerateChangeBlock(account, representative types.Address, sign Signature) (*types.StateBlock, error)

GenerateChangeBlock returns change block by account and new representative address, sign is a function to sign the block

func (*LedgerApi) GenerateReceiveBlock

func (l *LedgerApi) GenerateReceiveBlock(txBlock *types.StateBlock, sign Signature) (*types.StateBlock, error)

GenerateReceiveBlock returns receive block by send block, sign is a function to sign the block

func (*LedgerApi) GenerateReceiveBlockByHash

func (l *LedgerApi) GenerateReceiveBlockByHash(txHash types.Hash, sign Signature) (*types.StateBlock, error)

GenerateReceiveBlockByHash returns receive block by send block hash, sign is a function to sign the block

func (*LedgerApi) GenerateSendBlock

func (l *LedgerApi) GenerateSendBlock(para *APISendBlockPara, sign Signature) (*types.StateBlock, error)

GenerateSendBlock returns send block by transaction parameter, sign is a function to sign the block

func (*LedgerApi) GenesisAddress

func (l *LedgerApi) GenesisAddress() (*types.Address, error)

func (*LedgerApi) GenesisBlock

func (l *LedgerApi) GenesisBlock() (*types.StateBlock, error)

func (*LedgerApi) GenesisBlockHash

func (l *LedgerApi) GenesisBlockHash() (*types.Hash, error)

func (*LedgerApi) GenesisMintageBlock

func (l *LedgerApi) GenesisMintageBlock() (*types.StateBlock, error)

func (*LedgerApi) GenesisMintageHash

func (l *LedgerApi) GenesisMintageHash() (*types.Hash, error)

func (*LedgerApi) IsGenesisBlock

func (l *LedgerApi) IsGenesisBlock() (*bool, error)

func (*LedgerApi) IsGenesisToken

func (l *LedgerApi) IsGenesisToken() (*bool, error)

func (*LedgerApi) NewAccountBlock

func (l *LedgerApi) NewAccountBlock(ch chan *types.StateBlock, address types.Address) (*Subscribe, error)

NewAccountBlock support publish/subscription, ch is StateBlock channel, once there is new account block stored to the chain, set the block to channel

func (*LedgerApi) NewBlock

func (l *LedgerApi) NewBlock(ch chan *types.StateBlock) (*Subscribe, error)

NewBlock support publish/subscription, ch is StateBlock channel, once there is new block stored to the chain, set the block to channel

func (*LedgerApi) NewPending

func (l *LedgerApi) NewPending(ch chan *APIPending, address types.Address) (*Subscribe, error)

NewPending support publish/subscription, ch is APIPending channel, once there is a pending transaction of a account, set the pending info to channel

func (*LedgerApi) Pending

func (l *LedgerApi) Pending(address types.Address, hash types.Hash) (*APIPending, error)

Pending return pending info by account and token hash, if pending not found, return error

func (*LedgerApi) Pendings

func (l *LedgerApi) Pendings() ([]*APIPending, error)

Pendings returns pending transaction list on chain

func (*LedgerApi) Performance

func (l *LedgerApi) Performance() ([]*types.PerformanceTime, error)

Performance returns performance time

func (*LedgerApi) Process

func (l *LedgerApi) Process(block *types.StateBlock) (types.Hash, error)

Process checks block base info , updates info of chain for the block ,and broadcasts block

func (*LedgerApi) Representatives

func (l *LedgerApi) Representatives(sorting bool) ([]*APIRepresentative, error)

Representatives returns pairs of representative and its voting weight of chain if set sorting false , will return representatives randomly, if set true, will sorting representative balance in descending order

func (*LedgerApi) Stop

func (l *LedgerApi) Stop()

func (*LedgerApi) TokenInfoById

func (l *LedgerApi) TokenInfoById(tokenId types.Hash) (*ApiTokenInfo, error)

TokenInfoById returns token info by token id

func (*LedgerApi) TokenInfoByName

func (l *LedgerApi) TokenInfoByName(tokenName string) (*ApiTokenInfo, error)

TokenInfoById returns token info by token name

func (*LedgerApi) TokenMeta

func (l *LedgerApi) TokenMeta(hash types.Hash, address types.Address) (*APITokenMeta, error)

TokenMeta return tokenmeta info by account and token hash

func (*LedgerApi) Tokens

func (l *LedgerApi) Tokens() ([]*types.TokenInfo, error)

Tokens return all token info of chain

func (*LedgerApi) TransactionsCount

func (l *LedgerApi) TransactionsCount() (map[string]uint64, error)

TransactionsCount returns the number of blocks(not include smartcontract block) and unchecked blocks of chain

func (*LedgerApi) Unsubscribe

func (l *LedgerApi) Unsubscribe(subscribe *Subscribe) error

Unsubscribe close a pub-sub connection

type MinerApi

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

func NewMinerAPI

func NewMinerAPI(c *Client) *MinerApi

NewMinerAPI creates miner module for client

func (*MinerApi) GetAvailRewardInfo

func (m *MinerApi) GetAvailRewardInfo(coinbase types.Address) (*MinerAvailRewardInfo, error)

MinerAvailRewardInfo returns miner available reward info

func (*MinerApi) GetRewardData

func (m *MinerApi) GetRewardData(param *RewardParam) ([]byte, error)

func (*MinerApi) GetRewardHistory

func (m *MinerApi) GetRewardHistory(coinbase types.Address) (*MinerHistoryRewardInfo, error)

GetRewardHistory returns miner history reward info

func (*MinerApi) GetRewardRecvBlock

func (m *MinerApi) GetRewardRecvBlock(input *types.StateBlock) (*types.StateBlock, error)

GetRewardSendBlock returns miner contract reward block

func (*MinerApi) GetRewardRecvBlockBySendHash

func (m *MinerApi) GetRewardRecvBlockBySendHash(sendHash types.Hash) (*types.StateBlock, error)

GetRewardRecvBlockBySendHash returns miner contract reward block

func (*MinerApi) GetRewardSendBlock

func (m *MinerApi) GetRewardSendBlock(param *RewardParam) (*types.StateBlock, error)

GetRewardSendBlock returns miner contract send block

func (*MinerApi) UnpackRewardData

func (m *MinerApi) UnpackRewardData(data []byte) (*RewardParam, error)

type MinerAvailRewardInfo

type MinerAvailRewardInfo struct {
	LastEndHeight     uint64        `json:"lastEndHeight"`
	LatestBlockHeight uint64        `json:"latestBlockHeight"`
	NodeRewardHeight  uint64        `json:"nodeRewardHeight"`
	AvailStartHeight  uint64        `json:"availStartHeight"`
	AvailEndHeight    uint64        `json:"availEndHeight"`
	AvailRewardBlocks uint64        `json:"availRewardBlocks"`
	AvailRewardAmount types.Balance `json:"availRewardAmount"`
	NeedCallReward    bool          `json:"needCallReward"`
}

type MinerHistoryRewardInfo

type MinerHistoryRewardInfo struct {
	LastEndHeight  uint64        `json:"lastEndHeight"`
	RewardBlocks   uint64        `json:"rewardBlocks"`
	RewardAmount   types.Balance `json:"rewardAmount"`
	LastRewardTime int64         `json:"lastRewardTime"`
}

type MintageApi

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

func NewMintageAPI

func NewMintageAPI(c *Client) *MintageApi

NewMintageAPI creates mintage module for client

func (*MintageApi) GetMintageBlock

func (m *MintageApi) GetMintageBlock(param *MintageParams) (*types.StateBlock, error)

GetMintageBlock returns mintage block by mintage parameters

func (*MintageApi) GetMintageData

func (m *MintageApi) GetMintageData(param *MintageParams) ([]byte, error)

GetMintageData returns mintage data by mintage parameters

func (*MintageApi) GetRewardBlock

func (m *MintageApi) GetRewardBlock(input *types.StateBlock) (*types.StateBlock, error)

GetRewardBlock returns reward block by mintage block

func (*MintageApi) GetWithdrawMintageBlock

func (m *MintageApi) GetWithdrawMintageBlock(param *WithdrawParams) (*types.StateBlock, error)

GetWithdrawMintageBlock returns withdraw mintage block by withdraw parameters

func (*MintageApi) GetWithdrawMintageData

func (m *MintageApi) GetWithdrawMintageData(tokenId types.Hash) ([]byte, error)

GetWithdrawMintageData returns withdraw mintage data by token id

func (*MintageApi) GetWithdrawRewardBlock

func (m *MintageApi) GetWithdrawRewardBlock(input *types.StateBlock) (*types.StateBlock, error)

GetWithdrawRewardBlock returns withdraw mintage block by mintage block

func (*MintageApi) ParseTokenInfo

func (m *MintageApi) ParseTokenInfo(data []byte) (*types.TokenInfo, error)

type MintageParams

type MintageParams struct {
	SelfAddr    types.Address `json:"selfAddr"`
	PrevHash    types.Hash    `json:"prevHash"`
	TokenName   string        `json:"tokenName"`
	TokenSymbol string        `json:"tokenSymbol"`
	TotalSupply string        `json:"totalSupply"`
	Decimals    uint8         `json:"decimals"`
	Beneficial  types.Address `json:"beneficial"`
	NEP5TxId    string        `json:"nep5TxId"`
}

type NEP5PledgeInfo

type NEP5PledgeInfo struct {
	PType         string
	Amount        *big.Int
	WithdrawTime  string
	Beneficial    types.Address
	PledgeAddress types.Address
	NEP5TxId      string
}

type NetApi

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

func NewNetAPI

func NewNetAPI(c *Client) *NetApi

NewNetAPI creates net module for client

func (*NetApi) OnlineRepresentatives

func (q *NetApi) OnlineRepresentatives() ([]types.Address, error)

OnlineRepresentatives returns representatives that online at this moment

type PledgeApi

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

func NewPledgeAPI

func NewPledgeAPI(c *Client) *PledgeApi

NewPledgeAPI creates pledge module for client

func (*PledgeApi) GetPledgeBlock

func (p *PledgeApi) GetPledgeBlock(param *PledgeParam) (*types.StateBlock, error)

GetPledgeBlock returns pledge block by pledge parameters

func (*PledgeApi) GetPledgeData

func (p *PledgeApi) GetPledgeData(param *PledgeParam) ([]byte, error)

GetMintageData returns pledge data by pledge parameters

func (*PledgeApi) GetPledgeInfoWithNEP5TxId

func (p *PledgeApi) GetPledgeInfoWithNEP5TxId(param *WithdrawPledgeParam) (*NEP5PledgeInfo, error)

func (*PledgeApi) GetPledgeRewordBlock

func (p *PledgeApi) GetPledgeRewordBlock(input *types.StateBlock) (*types.StateBlock, error)

GetPledgeRewordBlock returns pledge reward block by pledge block

func (*PledgeApi) GetTotalPledgeAmount

func (p *PledgeApi) GetTotalPledgeAmount() (*big.Int, error)

func (*PledgeApi) GetWithdrawPledgeBlock

func (p *PledgeApi) GetWithdrawPledgeBlock(param *WithdrawPledgeParam) (*types.StateBlock, error)

GetWithdrawPledgeBlock returns withdraw pledge block by withdraw parameters

func (*PledgeApi) GetWithdrawPledgeData

func (p *PledgeApi) GetWithdrawPledgeData(param *WithdrawPledgeParam) ([]byte, error)

GetWithdrawPledgeData returns withdraw pledge data by withdraw parameters

func (*PledgeApi) GetWithdrawRewardBlock

func (p *PledgeApi) GetWithdrawRewardBlock(input *types.StateBlock) (*types.StateBlock, error)

GetWithdrawRewardBlock returns withdraw reward block by pledge block

func (*PledgeApi) ParsePledgeInfo

func (p *PledgeApi) ParsePledgeInfo(data []byte) (*PledgeInfo, error)

func (*PledgeApi) SearchAllPledgeInfo

func (p *PledgeApi) SearchAllPledgeInfo() ([]*NEP5PledgeInfo, error)

func (*PledgeApi) SearchPledgeInfo

func (p *PledgeApi) SearchPledgeInfo(param *WithdrawPledgeParam) ([]*NEP5PledgeInfo, error)

type PledgeInfo

type PledgeInfo struct {
	PType         uint8
	Amount        *big.Int
	WithdrawTime  int64
	Beneficial    types.Address
	PledgeAddress types.Address
	NEP5TxId      string
}

type PledgeParam

type PledgeParam struct {
	Beneficial    types.Address
	PledgeAddress types.Address
	Amount        types.Balance
	PType         string
	NEP5TxId      string
}

type PovApi

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

func NewPovAPI

func NewPovAPI(url string, c *Client) *PovApi

NewPovAPI creates pov module for client

func (*PovApi) BatchGetHeadersByHeight

func (p *PovApi) BatchGetHeadersByHeight(height uint64, count uint64, asc bool) (*PovApiBatchHeader, error)

BatchGetHeadersByHeight returns a lots of pov headers info by range

func (*PovApi) GetAccountStateByBlockHash

func (p *PovApi) GetAccountStateByBlockHash(address types.Address, blockHash types.Hash) (*PovApiState, error)

GetAccountStateByBlockHash returns pov account state by block hash

func (*PovApi) GetAccountStateByBlockHeight

func (p *PovApi) GetAccountStateByBlockHeight(address types.Address, height uint64) (*PovApiState, error)

GetAccountStateByBlockHeight returns pov account state by block height

func (*PovApi) GetBlockByHash

func (p *PovApi) GetBlockByHash(blockHash types.Hash, txOffset uint32, txLimit uint32) (*PovApiBlock, error)

GetBlockByHash returns pov block info by hash

func (*PovApi) GetBlockByHeight

func (p *PovApi) GetBlockByHeight(height uint64, txOffset uint32, txLimit uint32) (*PovApiBlock, error)

GetBlockByHeight returns pov block info by height

func (*PovApi) GetDiffDayStat

func (p *PovApi) GetDiffDayStat(dayIndex int) (*types.PovDiffDayStat, error)

GetDiffDayStat returns pov difficulty day statistic

func (*PovApi) GetDiffDayStatByHeight

func (p *PovApi) GetDiffDayStatByHeight(height uint64) (*types.PovDiffDayStat, error)

GetDiffDayStatByHeight returns pov difficulty day statistic

func (*PovApi) GetFittestHeader

func (p *PovApi) GetFittestHeader(gap uint64) (*PovApiHeader, error)

GetFittestHeader returns fittest pov header info If node is in pov syncing, will return error

func (*PovApi) GetHashInfo

func (p *PovApi) GetHashInfo(height uint64, lookup uint64) (*PovApiHashInfo, error)

GetHashInfo returns pov network hash info

func (*PovApi) GetHeaderByHash

func (p *PovApi) GetHeaderByHash(blockHash types.Hash) (*PovApiHeader, error)

GetHeaderByHash returns pov header info by hash

func (*PovApi) GetHeaderByHeight

func (p *PovApi) GetHeaderByHeight(height uint64) (*PovApiHeader, error)

GetHeaderByHeight returns pov header info by height

func (*PovApi) GetLastNHourInfo

func (p *PovApi) GetLastNHourInfo(endHeight uint64, timeSpan uint32) (*PovApiGetLastNHourInfo, error)

GetLastNHourInfo returns pov last n hour statistic

func (*PovApi) GetLatestAccountState

func (p *PovApi) GetLatestAccountState(address types.Address) (*PovApiState, error)

GetLatestAccountState returns pov account state in latest block

func (*PovApi) GetLatestBlock

func (p *PovApi) GetLatestBlock(txOffset uint32, txLimit uint32) (*PovApiBlock, error)

GetLatestBlock returns latest pov block info

func (*PovApi) GetLatestHeader

func (p *PovApi) GetLatestHeader() (*PovApiHeader, error)

GetLatestHeader returns latest pov header info

func (*PovApi) GetMinerDayStat

func (p *PovApi) GetMinerDayStat(dayIndex int) (*types.PovMinerDayStat, error)

GetMinerDayStat returns pov miner day statistic

func (*PovApi) GetMinerDayStatByHeight

func (p *PovApi) GetMinerDayStatByHeight(height uint64) (*types.PovMinerDayStat, error)

GetMinerDayStatByHeight returns pov miner day statistic

func (*PovApi) GetMinerStats

func (p *PovApi) GetMinerStats(addrs []types.Address) (*PovMinerStats, error)

GetMinerStats returns pov miner statistic

func (*PovApi) GetMiningInfo

func (p *PovApi) GetMiningInfo() (*PovApiGetMiningInfo, error)

GetMiningInfo returns pov mining info

func (*PovApi) GetPovStatus

func (p *PovApi) GetPovStatus() (*PovApiStatus, error)

GetFittestHeader returns fittest pov header info If node is in pov syncing, will return error

func (*PovApi) GetRepStats

func (p *PovApi) GetRepStats(addrs []types.Address) (*PovRepStats, error)

GetRepStats returns pov rep statistic

func (*PovApi) GetTransaction

func (p *PovApi) GetTransaction(txHash types.Hash) (*PovApiTxLookup, error)

GetTransaction returns pov tx lookup info by tx hash

func (*PovApi) GetTransactionByBlockHashAndIndex

func (p *PovApi) GetTransactionByBlockHashAndIndex(blockHash types.Hash, index uint32) (*PovApiTxLookup, error)

GetTransactionByBlockHashAndIndex returns pov tx lookup info by block hash and tx index

func (*PovApi) GetTransactionByBlockHeightAndIndex

func (p *PovApi) GetTransactionByBlockHeightAndIndex(height uint64, index uint32) (*PovApiTxLookup, error)

GetTransactionByBlockHeightAndIndex returns pov tx lookup info by block height and tx index

func (*PovApi) GetWork

func (p *PovApi) GetWork(minerAddr types.Address, algoName string) (*PovApiGetWork, error)

GetWork returns pov next block work info If node is in pov syncing, will return error

func (*PovApi) SubmitWork

func (p *PovApi) SubmitWork(work *PovApiSubmitWork) error

SubmitWork sumbits new block work to node If node is in pov syncing, will return error

func (*PovApi) SubscribeNewBlock

func (p *PovApi) SubscribeNewBlock(ch chan *PovApiHeader) (*Subscribe, error)

NewBlock support publish/subscription, ch is PovApiHeader channel, once there is new block stored to the chain, set the block to channel

func (*PovApi) Unsubscribe

func (p *PovApi) Unsubscribe(subscribe *Subscribe) error

Unsubscribe close a pub-sub connection

type PovApiBatchHeader

type PovApiBatchHeader struct {
	Count   int             `json:"count"`
	Headers []*PovApiHeader `json:"headers"`
}

type PovApiBlock

type PovApiBlock struct {
	*types.PovBlock
	AlgoName       string  `json:"algoName"`
	AlgoEfficiency uint    `json:"algoEfficiency"`
	NormBits       uint32  `json:"normBits"`
	NormDifficulty float64 `json:"normDifficulty"`
	AlgoDifficulty float64 `json:"algoDifficulty"`
}

type PovApiGetLastNHourInfo

type PovApiGetLastNHourInfo struct {
	MaxTxPerBlock uint32
	MinTxPerBlock uint32
	AvgTxPerBlock uint32

	MaxTxPerHour uint32
	MinTxPerHour uint32
	AvgTxPerHour uint32

	MaxBlockPerHour uint32
	MinBlockPerHour uint32
	AvgBlockPerHour uint32

	AllBlockNum uint32
	AllTxNum    uint32

	Sha256dBlockNum uint32
	X11BlockNum     uint32
	ScryptBlockNum  uint32
	AuxBlockNum     uint32

	HourItemList []*PovApiGetLastNHourItem
}

type PovApiGetLastNHourItem

type PovApiGetLastNHourItem struct {
	Hour uint32

	AllBlockNum    uint32
	AllTxNum       uint32
	AllMinerReward types.Balance
	AllRepReward   types.Balance

	Sha256dBlockNum uint32
	X11BlockNum     uint32
	ScryptBlockNum  uint32
	AuxBlockNum     uint32

	MaxTxPerBlock uint32
	MinTxPerBlock uint32
	AvgTxPerBlock uint32
}

type PovApiGetMiningInfo

type PovApiGetMiningInfo struct {
	SyncState          int               `json:"syncState"`
	CurrentBlockHeight uint64            `json:"currentBlockHeight"`
	CurrentBlockHash   types.Hash        `json:"currentBlockHash"`
	CurrentBlockSize   uint32            `json:"currentBlockSize"`
	CurrentBlockTx     uint32            `json:"currentBlockTx"`
	CurrentBlockAlgo   types.PovAlgoType `json:"currentBlockAlgo"`
	PooledTx           uint32            `json:"pooledTx"`
	Difficulty         float64           `json:"difficulty"`
	HashInfo           *PovApiHashInfo   `json:"hashInfo"`
}

type PovApiGetWork

type PovApiGetWork struct {
	WorkHash      types.Hash     `json:"workHash"`
	Version       uint32         `json:"version"`
	Previous      types.Hash     `json:"previous"`
	Bits          uint32         `json:"bits"`
	Height        uint64         `json:"height"`
	MinTime       uint32         `json:"minTime"`
	MerkleBranch  []*types.Hash  `json:"merkleBranch"`
	CoinBaseData1 types.HexBytes `json:"coinbaseData1"`
	CoinBaseData2 types.HexBytes `json:"coinbaseData2"`
}

type PovApiHashInfo

type PovApiHashInfo struct {
	ChainHashPS   uint64 `json:"chainHashPS"`
	Sha256dHashPS uint64 `json:"sha256dHashPS"`
	ScryptHashPS  uint64 `json:"scryptHashPS"`
	X11HashPS     uint64 `json:"x11HashPS"`
}

type PovApiHeader

type PovApiHeader struct {
	*types.PovHeader
	AlgoName       string  `json:"algoName"`
	AlgoEfficiency uint    `json:"algoEfficiency"`
	NormBits       uint32  `json:"normBits"`
	NormDifficulty float64 `json:"normDifficulty"`
	AlgoDifficulty float64 `json:"algoDifficulty"`
}

type PovApiState

type PovApiState struct {
	AccountState *types.PovAccountState `json:"accountState"`
	RepState     *types.PovRepState     `json:"repState"`
}

type PovApiStatus

type PovApiStatus struct {
	PovEnabled   bool   `json:"povEnabled"`
	SyncState    int    `json:"syncState"`
	SyncStateStr string `json:"syncStateStr"`
}

type PovApiSubmitWork

type PovApiSubmitWork struct {
	WorkHash  types.Hash `json:"workHash"`
	BlockHash types.Hash `json:"blockHash"`

	MerkleRoot    types.Hash     `json:"merkleRoot"`
	Timestamp     uint32         `json:"timestamp"`
	Nonce         uint32         `json:"nonce"`
	CoinbaseExtra types.HexBytes `json:"coinbaseExtra"`
	CoinbaseHash  types.Hash     `json:"coinbaseHash"`

	AuxPow *types.PovAuxHeader `json:"auxPow"`
}

type PovApiTxLookup

type PovApiTxLookup struct {
	TxHash   types.Hash         `json:"txHash"`
	TxLookup *types.PovTxLookup `json:"txLookup"`

	CoinbaseTx *types.PovCoinBaseTx `json:"coinbaseTx"`
	AccountTx  *types.StateBlock    `json:"accountTx"`
}

type PovMinerStatItem

type PovMinerStatItem struct {
	MainBlockNum       uint32        `json:"mainBlockNum"`
	MainRewardAmount   types.Balance `json:"mainRewardAmount"`
	StableBlockNum     uint32        `json:"stableBlockNum"`
	StableRewardAmount types.Balance `json:"stableRewardAmount"`
	FirstBlockTime     time.Time     `json:"firstBlockTime"`
	LastBlockTime      time.Time     `json:"lastBlockTime"`
	FirstBlockHeight   uint64        `json:"firstBlockHeight"`
	LastBlockHeight    uint64        `json:"lastBlockHeight"`
	IsHourOnline       bool          `json:"isHourOnline"`
	IsDayOnline        bool          `json:"isDayOnline"`
}

type PovMinerStats

type PovMinerStats struct {
	MinerCount      int `json:"minerCount"`
	HourOnlineCount int `json:"hourOnlineCount"`
	DayOnlineCount  int `json:"dayOnlineCount"`

	MinerStats map[types.Address]*PovMinerStatItem `json:"minerStats"`

	TotalBlockNum     uint32 `json:"totalBlockNum"`
	LatestBlockHeight uint64 `json:"latestBlockHeight"`
}

type PovRepStatItem

type PovRepStatItem struct {
	MainBlockNum       uint32        `json:"mainBlockNum"`
	MainRewardAmount   types.Balance `json:"mainRewardAmount"`
	MainOnlinePeriod   uint32        `json:"mainOnlinePeriod"`
	StableBlockNum     uint32        `json:"stableBlockNum"`
	StableRewardAmount types.Balance `json:"stableRewardAmount"`
	StableOnlinePeriod uint32        `json:"stableOnlinePeriod"`
	LastOnlineTime     time.Time     `json:"lastOnlineTime"`
	LastOnlineHeight   uint64        `json:"lastOnlineHeight"`
	IsOnline           bool          `json:"isOnline"`
}

type PovRepStats

type PovRepStats struct {
	RepCount          uint32                            `json:"repCount"`
	RepStats          map[types.Address]*PovRepStatItem `json:"repStats"`
	TotalBlockNum     uint32                            `json:"totalBlockNum"`
	TotalPeriod       uint32                            `json:"totalPeriod"`
	TotalRewardAmount types.Balance                     `json:"totalRewardAmount"`
	LatestBlockHeight uint64                            `json:"latestBlockHeight"`
}

type RepApi

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

func NewRepAPI

func NewRepAPI(c *Client) *RepApi

NewRepAPI creates representative module for client

func (*RepApi) GetAvailRewardInfo

func (r *RepApi) GetAvailRewardInfo(account types.Address) (*RepAvailRewardInfo, error)

GetAvailRewardInfo returns representative available reward info

func (*RepApi) GetRewardHistory

func (r *RepApi) GetRewardHistory(account types.Address) (*RepHistoryRewardInfo, error)

GetRewardHistory returns representative history reward info

func (*RepApi) GetRewardRecvBlock

func (r *RepApi) GetRewardRecvBlock(input *types.StateBlock) (*types.StateBlock, error)

GetRewardSendBlock returns representative contract reward block

func (*RepApi) GetRewardRecvBlockBySendHash

func (r *RepApi) GetRewardRecvBlockBySendHash(sendHash types.Hash) (*types.StateBlock, error)

GetRewardRecvBlockBySendHash returns representative contract reward block

func (*RepApi) GetRewardSendBlock

func (r *RepApi) GetRewardSendBlock(param *RepRewardParam) (*types.StateBlock, error)

GetRewardSendBlock returns representative contract send block

type RepAvailRewardInfo

type RepAvailRewardInfo struct {
	LastEndHeight     uint64        `json:"lastEndHeight"`
	LatestBlockHeight uint64        `json:"latestBlockHeight"`
	NodeRewardHeight  uint64        `json:"nodeRewardHeight"`
	AvailStartHeight  uint64        `json:"availStartHeight"`
	AvailEndHeight    uint64        `json:"availEndHeight"`
	AvailRewardBlocks uint64        `json:"availRewardBlocks"`
	AvailRewardAmount types.Balance `json:"availRewardAmount"`
	NeedCallReward    bool          `json:"needCallReward"`
}

type RepHistoryRewardInfo

type RepHistoryRewardInfo struct {
	LastEndHeight  uint64        `json:"lastEndHeight"`
	RewardBlocks   uint64        `json:"rewardBlocks"`
	RewardAmount   types.Balance `json:"rewardAmount"`
	LastRewardTime int64         `json:"lastRewardTime"`
}

type RepRewardParam

type RepRewardParam struct {
	Account      types.Address `json:"account"`
	Beneficial   types.Address `json:"beneficial"`
	StartHeight  uint64        `json:"startHeight"`
	EndHeight    uint64        `json:"endHeight"`
	RewardBlocks uint64        `json:"rewardBlocks"`
	RewardAmount *big.Int      `json:"rewardAmount"`
}

type RewardParam

type RewardParam struct {
	Coinbase     types.Address `json:"coinbase"`
	Beneficial   types.Address `json:"beneficial"`
	StartHeight  uint64        `json:"startHeight"`
	EndHeight    uint64        `json:"endHeight"`
	RewardBlocks uint64        `json:"rewardBlocks"`
	RewardAmount *big.Int      `json:"rewardAmount"`
}

type RewardsApi

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

func NewRewardAPI

func NewRewardAPI(c *Client) *RewardsApi

NewRewardAPI creates reward module for client

func (*RewardsApi) GetConfidantRewords

func (r *RewardsApi) GetConfidantRewords(confidant types.Address) (map[string]*big.Int, error)

func (*RewardsApi) GetReceiveRewardBlock

func (r *RewardsApi) GetReceiveRewardBlock(send *types.Hash) (*types.StateBlock, error)

func (*RewardsApi) GetSendConfidantBlock

func (r *RewardsApi) GetSendConfidantBlock(param *RewardsParam, sign *types.Signature) (*types.StateBlock, error)

func (*RewardsApi) GetSendRewardBlock

func (r *RewardsApi) GetSendRewardBlock(param *RewardsParam, sign *types.Signature) (*types.StateBlock, error)

func (*RewardsApi) GetTotalRewards

func (r *RewardsApi) GetTotalRewards(txId string) (*big.Int, error)

func (*RewardsApi) GetUnsignedConfidantData

func (r *RewardsApi) GetUnsignedConfidantData(param *RewardsParam) (types.Hash, error)

func (*RewardsApi) GetUnsignedRewardData

func (r *RewardsApi) GetUnsignedRewardData(param *RewardsParam) (types.Hash, error)

type RewardsParam

type RewardsParam struct {
	Id     string        `json:"Id"`
	Amount types.Balance `json:"amount"`
	Self   types.Address `json:"self"`
	To     types.Address `json:"to"`
}

type Signature

type Signature func(hash types.Hash) (types.Signature, error)

type SignatureParam

type SignatureParam func() (types.Signature, error)

type Subscribe

type Subscribe struct {
	Stopped chan bool
	// contains filtered or unexported fields
}

func NewSubscribe

func NewSubscribe(url string) *Subscribe

func (*Subscribe) Close

func (s *Subscribe) Close() error

func (*Subscribe) Unsubscribe

func (s *Subscribe) Unsubscribe(request string) error

type UtilApi

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

func NewUtilAPI

func NewUtilAPI(c *Client) *UtilApi

NewUtilAPI creates unit module for client

func (*UtilApi) BalanceToRaw

func (u *UtilApi) BalanceToRaw(balance types.Balance, unit string) (types.Balance, error)

RawToBalance transforms Q amount from unit to raw

func (*UtilApi) BalanceToRawForToken

func (u *UtilApi) BalanceToRawForToken(balance types.Balance, tokenName string) (types.Balance, error)

RawToBalance transforms token (not Q) amount to raw

func (*UtilApi) Decrypt

func (u *UtilApi) Decrypt(cryptograph string, passphrase string) (string, error)

Decrypt decrypts cryptograph to raw by passphrase

func (*UtilApi) Encrypt

func (u *UtilApi) Encrypt(raw string, passphrase string) (string, error)

Encrypt encrypts raw to cryptograph by passphrase

func (*UtilApi) RawToBalance

func (u *UtilApi) RawToBalance(balance types.Balance, unit string) (APIBalance, error)

RawToBalance transforms Q amount from raw to unit

func (*UtilApi) RawToBalanceForToken

func (u *UtilApi) RawToBalanceForToken(balance types.Balance, tokenName string) (APIBalance, error)

RawToBalance transforms token (not Q) amount from raw

type WithdrawParams

type WithdrawParams struct {
	SelfAddr types.Address `json:"selfAddr"`
	TokenId  types.Hash    `json:"tokenId"`
}

type WithdrawPledgeParam

type WithdrawPledgeParam struct {
	Beneficial types.Address `json:"beneficial"`
	Amount     types.Balance `json:"amount"`
	PType      string        `json:"pType"`
	NEP5TxId   string        `json:"nep5TxId"`
}

Directories

Path Synopsis
pkg
ed25519
Package ed25519 implements the Ed25519 signature algorithm.
Package ed25519 implements the Ed25519 signature algorithm.
util/hexutil
Package hexutil implements hex encoding with 0x prefix.
Package hexutil implements hex encoding with 0x prefix.

Jump to

Keyboard shortcuts

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