api

package
v0.0.3-chain-bsopt Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2018 License: GPL-3.0 Imports: 25 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotSupport = errors.New("not support this method")

	ErrBalanceNotEnough = JsonRpc2Error{
		Message: vm.ErrInsufficientBalance.Error(),
		Code:    -35001,
	}

	ErrDecryptKey = JsonRpc2Error{
		Message: walleterrors.ErrDecryptKey.Error(),
		Code:    -34001,
	}

	AddressAlreadyUnLocked = JsonRpc2Error{
		Message: walleterrors.ErrAlreadyLocked.Error(),
		Code:    -34002,
	}
)
View Source
var (
	ErrStrToBigInt = errors.New("convert to big.Int failed")
)

Functions

func TryMakeConcernedError

func TryMakeConcernedError(err error) (newerr error, concerned bool)

Types

type AccountBlock

type AccountBlock struct {
	*ledger.AccountBlock

	FromAddress types.Address `json:"fromAddress"`

	Height string `json:"height"`
	Quota  string `json:"quota"`

	Amount string `json:"amount"`
	Fee    string `json:"fee"`

	ConfirmedTimes string        `json:"confirmedTimes"`
	TokenInfo      *RpcTokenInfo `json:"tokenInfo"`
}

func (*AccountBlock) LedgerAccountBlock

func (ab *AccountBlock) LedgerAccountBlock() (*ledger.AccountBlock, error)

type CommonApi

type CommonApi struct {
}

func (CommonApi) LogDir

func (CommonApi) LogDir() string

func (CommonApi) String

func (CommonApi) String() string

type ContractsApi

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

func NewContractsApi

func NewContractsApi(vite *vite.Vite) *ContractsApi

func (*ContractsApi) GetCancelConsensusGroupData

func (c *ContractsApi) GetCancelConsensusGroupData(gid types.Gid) (string, error)

func (*ContractsApi) GetCancelPledgeData

func (c *ContractsApi) GetCancelPledgeData(beneficialAddr types.Address, amount *big.Int) (string, error)

func (*ContractsApi) GetCancelRegisterData

func (c *ContractsApi) GetCancelRegisterData(gid types.Gid, name string) (string, error)

func (*ContractsApi) GetCancelVoteData

func (c *ContractsApi) GetCancelVoteData(gid types.Gid) (string, error)

func (*ContractsApi) GetConditionRegisterOfPledge

func (c *ContractsApi) GetConditionRegisterOfPledge(amount *big.Int, tokenId types.TokenTypeId, height uint64) (string, error)

func (*ContractsApi) GetConditionVoteOfDefault

func (c *ContractsApi) GetConditionVoteOfDefault() (string, error)

func (*ContractsApi) GetConditionVoteOfKeepToken

func (c *ContractsApi) GetConditionVoteOfKeepToken(amount *big.Int, tokenId types.TokenTypeId) (string, error)

func (*ContractsApi) GetCreateConsensusGroupData

func (c *ContractsApi) GetCreateConsensusGroupData(param CreateConsensusGroupParam) (string, error)

func (*ContractsApi) GetCreateContractToAddress

func (c *ContractsApi) GetCreateContractToAddress(selfAddr types.Address, height uint64, prevHash types.Hash, snapshotHash types.Hash) types.Address

func (*ContractsApi) GetMintageCancelPledgeData

func (c *ContractsApi) GetMintageCancelPledgeData(tokenId types.TokenTypeId) (string, error)

func (*ContractsApi) GetMintageData

func (c *ContractsApi) GetMintageData(param MintageParams) (string, error)

func (*ContractsApi) GetPledgeData

func (c *ContractsApi) GetPledgeData(beneficialAddr types.Address) (string, error)

func (*ContractsApi) GetReCreateConsensusGroupData

func (c *ContractsApi) GetReCreateConsensusGroupData(gid types.Gid) (string, error)

func (*ContractsApi) GetRegisterData

func (c *ContractsApi) GetRegisterData(gid types.Gid, name string, nodeAddr types.Address, beneficialAddr types.Address) (string, error)

func (*ContractsApi) GetRewardData

func (c *ContractsApi) GetRewardData(gid types.Gid, name string, endHeight uint64, startHeight uint64, rewardAmount *big.Int) (string, error)

func (*ContractsApi) GetUpdateRegistrationData

func (c *ContractsApi) GetUpdateRegistrationData(gid types.Gid, name string, nodeAddr types.Address, beneficialAddr types.Address) (string, error)

func (*ContractsApi) GetVoteData

func (c *ContractsApi) GetVoteData(gid types.Gid, name string) (string, error)

func (ContractsApi) String

func (c ContractsApi) String() string

type CreateConsensusGroupParam

type CreateConsensusGroupParam struct {
	SelfAddr               types.Address
	Height                 uint64
	PrevHash               types.Hash
	SnapshotHash           types.Hash
	NodeCount              uint8
	Interval               int64
	PerCount               int64
	RandCount              uint8
	RandRank               uint8
	CountingTokenId        types.TokenTypeId
	RegisterConditionId    uint8
	RegisterConditionParam []byte
	VoteConditionId        uint8
	VoteConditionParam     []byte
}

type CreateTransferTxParms

type CreateTransferTxParms struct {
	SelfAddr    types.Address
	ToAddr      types.Address
	TokenTypeId types.TokenTypeId
	Passphrase  string
	Amount      string
	Data        []byte
}

type HexSignedTuple

type HexSignedTuple struct {
	Message    string `json:"message"`
	SignedData string `json:"signedData"`
	Pubkey     string `json:"pubkey"`
}

type IsMayValidKeystoreFileResponse

type IsMayValidKeystoreFileResponse struct {
	Maybe      bool
	MayAddress types.Address
}

type JsonRpc2Error

type JsonRpc2Error struct {
	Message string
	Code    int
}

func (JsonRpc2Error) Error

func (e JsonRpc2Error) Error() string

func (JsonRpc2Error) ErrorCode

func (e JsonRpc2Error) ErrorCode() int

type LedgerApi

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

func NewLedgerApi

func NewLedgerApi(vite *vite.Vite) *LedgerApi

func (*LedgerApi) GetAccountByAccAddr

func (l *LedgerApi) GetAccountByAccAddr(addr types.Address) (*RpcAccountInfo, error)

func (*LedgerApi) GetBlocksByAccAddr

func (l *LedgerApi) GetBlocksByAccAddr(addr types.Address, index int, count int, needTokenInfo *bool) ([]*AccountBlock, error)

func (*LedgerApi) GetBlocksByHash

func (l *LedgerApi) GetBlocksByHash(addr types.Address, originBlockHash *types.Hash, count uint64) ([]*AccountBlock, error)

func (*LedgerApi) GetLatestBlock

func (l *LedgerApi) GetLatestBlock(addr types.Address) (*AccountBlock, error)

func (*LedgerApi) GetLatestSnapshotChainHash

func (l *LedgerApi) GetLatestSnapshotChainHash() *types.Hash

func (*LedgerApi) GetSnapshotChainHeight

func (l *LedgerApi) GetSnapshotChainHeight() string

func (*LedgerApi) GetTokenMintage

func (l *LedgerApi) GetTokenMintage(tti types.TokenTypeId) (*RpcTokenInfo, error)

func (LedgerApi) String

func (l LedgerApi) String() string

type MintageParams

type MintageParams struct {
	SelfAddr     types.Address
	Height       uint64
	PrevHash     types.Hash
	SnapshotHash types.Hash
	TokenName    string
	TokenSymbol  string
	TotalSupply  *big.Int
	Decimals     uint8
}

type NetApi

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

func NewNetApi

func NewNetApi(vite *vite.Vite) *NetApi

func (*NetApi) SyncInfo

func (n *NetApi) SyncInfo() *SyncInfo

type P2PApi

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

func NewP2PApi

func NewP2PApi(p2p *p2p.Server) P2PApi

func (P2PApi) NetworkAvailable

func (p P2PApi) NetworkAvailable() bool

func (P2PApi) PeersCount

func (p P2PApi) PeersCount() int

func (P2PApi) String

func (p P2PApi) String() string

type PrivateOnroadApi

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

func NewPrivateOnroadApi

func NewPrivateOnroadApi(manager *onroad.Manager) *PrivateOnroadApi

func (PrivateOnroadApi) GetAccountOnroadInfo

func (o PrivateOnroadApi) GetAccountOnroadInfo(address types.Address) (*RpcAccountInfo, error)

func (PrivateOnroadApi) GetOnroadBlocksByAddress

func (o PrivateOnroadApi) GetOnroadBlocksByAddress(address types.Address, index int, count int) ([]*AccountBlock, error)

func (PrivateOnroadApi) ListWorkingAutoReceiveWorker

func (o PrivateOnroadApi) ListWorkingAutoReceiveWorker() []types.Address

func (PrivateOnroadApi) StartAutoReceive

func (o PrivateOnroadApi) StartAutoReceive(addr types.Address, filter map[types.TokenTypeId]string) error

func (PrivateOnroadApi) StopAutoReceive

func (o PrivateOnroadApi) StopAutoReceive(addr types.Address) error

func (PrivateOnroadApi) String

func (o PrivateOnroadApi) String() string

type PublicOnroadApi

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

func NewPublicOnroadApi

func NewPublicOnroadApi(manager *onroad.Manager) *PublicOnroadApi

func (PublicOnroadApi) GetAccountOnroadInfo

func (o PublicOnroadApi) GetAccountOnroadInfo(address types.Address) (*RpcAccountInfo, error)

func (PublicOnroadApi) GetOnroadBlocksByAddress

func (o PublicOnroadApi) GetOnroadBlocksByAddress(address types.Address, index int, count int) ([]*AccountBlock, error)

func (PublicOnroadApi) String

func (o PublicOnroadApi) String() string

type RpcAccountInfo

type RpcAccountInfo struct {
	AccountAddress      types.Address                              `json:"accountAddress"`
	TotalNumber         string                                     `json:"totalNumber"` // uint64
	TokenBalanceInfoMap map[types.TokenTypeId]*RpcTokenBalanceInfo `json:"tokenBalanceInfoMap,omitempty"`
}

type RpcTokenBalanceInfo

type RpcTokenBalanceInfo struct {
	TokenInfo   *RpcTokenInfo `json:"tokenInfo,omitempty"`
	TotalAmount string        `json:"totalAmount"`      // big int
	Number      *string       `json:"number,omitempty"` // uint64
}

type RpcTokenInfo

type RpcTokenInfo struct {
	TokenName      string        `json:"tokenName"`
	TokenSymbol    string        `json:"tokenSymbol"`
	TotalSupply    *string       `json:"totalSupply,omitempty"` // *big.Int
	Decimals       uint8         `json:"decimals"`
	Owner          types.Address `json:"owner"`
	PledgeAmount   *string       `json:"pledgeAmount,omitempty"` // *big.Int
	WithdrawHeight string        `json:"withdrawHeight"`         // uint64
}

func RawTokenInfoToRpc

func RawTokenInfoToRpc(tinfo *contracts.TokenInfo) *RpcTokenInfo

type SyncInfo

type SyncInfo struct {
	StartHeight      string `json:"startHeight"`
	TargetHeight     string `json:"targetHeight"`
	CurrentHeight    string `json:"currentHeight"`
	IsFirstSyncDone  bool   `json:"isFirstSyncDone"`
	IsStartFirstSync bool   `json:"isStartFirstSync"`
}

type TypesApi

type TypesApi struct {
}

func (TypesApi) IsValidHexAddress

func (TypesApi) IsValidHexAddress(addr string) bool

func (TypesApi) IsValidHexTokenTypeId

func (TypesApi) IsValidHexTokenTypeId(tti string) bool

func (TypesApi) String

func (TypesApi) String() string

type WalletApi

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

func NewWalletApi

func NewWalletApi(vite *vite.Vite) *WalletApi

func (*WalletApi) CreateTxWithPassphrase

func (m *WalletApi) CreateTxWithPassphrase(params CreateTransferTxParms) error

func (*WalletApi) ExportPriv

func (m *WalletApi) ExportPriv(address types.Address, password string) (string, error)

func (WalletApi) GetDataDir

func (m WalletApi) GetDataDir() string

func (*WalletApi) ImportPriv

func (m *WalletApi) ImportPriv(privkey string, newpassword string) (types.Address, error)

func (*WalletApi) IsMayValidKeystoreFile

func (m *WalletApi) IsMayValidKeystoreFile(path string) IsMayValidKeystoreFileResponse

func (WalletApi) ListAddress

func (m WalletApi) ListAddress() []types.Address

func (*WalletApi) LockAddress

func (m *WalletApi) LockAddress(addr types.Address) error

func (*WalletApi) NewAddress

func (m *WalletApi) NewAddress(passphrase string) (types.Address, error)

func (*WalletApi) ReloadAndFixAddressFile

func (m *WalletApi) ReloadAndFixAddressFile() error

func (*WalletApi) SignData

func (m *WalletApi) SignData(addr types.Address, hexMsg string) (HexSignedTuple, error)

func (*WalletApi) SignDataWithPassphrase

func (m *WalletApi) SignDataWithPassphrase(addr types.Address, hexMsg string, password string) (HexSignedTuple, error)

func (WalletApi) Status

func (m WalletApi) Status() map[types.Address]string

func (WalletApi) String

func (m WalletApi) String() string

func (*WalletApi) UnlockAddress

func (m *WalletApi) UnlockAddress(addr types.Address, password string, duration *uint64) (bool, error)

Jump to

Keyboard shortcuts

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