Documentation ¶
Overview ¶
Package api implements the general Ethereum API functions.
Index ¶
- Variables
- func GetAPIs(apiBackend Backend) []rpc.API
- func RPCMarshalBlock(chainID *big.Int, b *types.Block, inclTx bool, fullTx bool) map[string]interface{}
- type AccountAPI
- func (aapi *AccountAPI) AccountIsExist(ctx context.Context, acctName common.Name) (bool, error)
- func (aapi *AccountAPI) GetAccountBalanceByID(ctx context.Context, accountName common.Name, assetID uint64) (*big.Int, error)
- func (aapi *AccountAPI) GetAccountByName(ctx context.Context, accountName common.Name) (*accountmanager.Account, error)
- func (aapi *AccountAPI) GetAssetInfoByID(ctx context.Context, assetID uint64) (*asset.AssetObject, error)
- func (aapi *AccountAPI) GetAssetInfoByName(ctx context.Context, assetName string) (*asset.AssetObject, error)
- func (aapi *AccountAPI) GetCode(ctx context.Context, accountName common.Name) (hexutil.Bytes, error)
- func (aapi *AccountAPI) GetNonce(ctx context.Context, accountName common.Name) (uint64, error)
- type AddrLocker
- type Backend
- type CallArgs
- type NotifyEvent
- type PrivateKeyStoreAPI
- func (api *PrivateKeyStoreAPI) Delete(ctx context.Context, addr common.Address, passphrase string) error
- func (api *PrivateKeyStoreAPI) ExportRawKey(ctx context.Context, addr common.Address, passphrase string) (hexutil.Bytes, error)
- func (api *PrivateKeyStoreAPI) ImportRawKey(ctx context.Context, privkey string, passphrase string) (map[string]interface{}, error)
- func (api *PrivateKeyStoreAPI) ListAccount(ctx context.Context) ([]map[string]interface{}, error)
- func (api *PrivateKeyStoreAPI) NewAccount(ctx context.Context, passphrase string) (map[string]interface{}, error)
- func (api *PrivateKeyStoreAPI) SignData(ctx context.Context, addr common.Address, passphrase string, ...) (hexutil.Bytes, error)
- func (api *PrivateKeyStoreAPI) SignTransaction(ctx context.Context, addr common.Address, passphrase string, ...) (hexutil.Bytes, error)
- func (api *PrivateKeyStoreAPI) Update(ctx context.Context, addr common.Address, passphrase, newPassphrase string) error
- type PrivateP2pAPI
- func (api *PrivateP2pAPI) AddPeer(url string) (bool, error)
- func (api *PrivateP2pAPI) AddTrustedPeer(url string) (bool, error)
- func (api *PrivateP2pAPI) PeerCount() int
- func (api *PrivateP2pAPI) PeerEvents(ctx context.Context) (*rpc.Subscription, error)
- func (api *PrivateP2pAPI) Peers() []string
- func (api *PrivateP2pAPI) RemovePeer(url string) (bool, error)
- func (api *PrivateP2pAPI) RemoveTrustedPeer(url string) (bool, error)
- func (api *PrivateP2pAPI) SelfNode() string
- type PublicBlockChainAPI
- func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNr rpc.BlockNumber) (hexutil.Bytes, error)
- func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs) (hexutil.Uint64, error)
- func (s *PublicBlockChainAPI) GetBlockByHash(ctx context.Context, blockHash common.Hash, fullTx bool) (map[string]interface{}, error)
- func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, blockNr rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)
- func (s *PublicBlockChainAPI) GetCurrentBlock(fullTx bool) map[string]interface{}
- func (s *PublicBlockChainAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) *types.RPCTransaction
- func (s *PublicBlockChainAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (*types.RPCReceipt, error)
- type PublicFractalAPI
- type PublicTxPoolAPI
- type SendArgs
Constants ¶
This section is empty.
Variables ¶
var (
ErrGetAccounManagerErr = errors.New("get account manager failure")
)
Functions ¶
func RPCMarshalBlock ¶
func RPCMarshalBlock(chainID *big.Int, b *types.Block, inclTx bool, fullTx bool) map[string]interface{}
RPCMarshalBlock converts the given block to the RPC output which depends on fullTx. If inclTx is true transactions are returned. When fullTx is true the returned block contains full transaction details, otherwise it will only contain transaction hashes.
Types ¶
type AccountAPI ¶
type AccountAPI struct {
// contains filtered or unexported fields
}
func NewAccountAPI ¶
func NewAccountAPI(b Backend) *AccountAPI
func (*AccountAPI) AccountIsExist ¶
AccountIsExist
func (*AccountAPI) GetAccountBalanceByID ¶
func (aapi *AccountAPI) GetAccountBalanceByID(ctx context.Context, accountName common.Name, assetID uint64) (*big.Int, error)
GetAccountBalanceByID
func (*AccountAPI) GetAccountByName ¶
func (aapi *AccountAPI) GetAccountByName(ctx context.Context, accountName common.Name) (*accountmanager.Account, error)
GetAccountByName
func (*AccountAPI) GetAssetInfoByID ¶
func (aapi *AccountAPI) GetAssetInfoByID(ctx context.Context, assetID uint64) (*asset.AssetObject, error)
GetAssetInfoByID
func (*AccountAPI) GetAssetInfoByName ¶
func (aapi *AccountAPI) GetAssetInfoByName(ctx context.Context, assetName string) (*asset.AssetObject, error)
GetAssetInfoByName
type AddrLocker ¶
type AddrLocker struct {
// contains filtered or unexported fields
}
func (*AddrLocker) LockAddr ¶
func (l *AddrLocker) LockAddr(address common.Address)
LockAddr locks an account's mutex. This is used to prevent another tx getting the same nonce until the lock is released. The mutex prevents the (an identical nonce) from being read again during the time that the first transaction is being signed.
func (*AddrLocker) UnlockAddr ¶
func (l *AddrLocker) UnlockAddr(address common.Address)
UnlockAddr unlocks the mutex of the given account.
type Backend ¶
type Backend interface { // ftservice API ChainDb() fdb.Database ChainConfig() *params.ChainConfig SuggestPrice(ctx context.Context) (*big.Int, error) // BlockChain API CurrentBlock() *types.Block HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error) BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Block, error) StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*state.StateDB, *types.Header, error) GetBlock(ctx context.Context, blockHash common.Hash) (*types.Block, error) GetReceipts(ctx context.Context, blockHash common.Hash) ([]*types.Receipt, error) GetTd(blockHash common.Hash) *big.Int GetEVM(ctx context.Context, account *accountmanager.AccountManager, state *state.StateDB, from common.Name, assetID uint64, gasPrice *big.Int, header *types.Header, vmCfg vm.Config) (*vm.EVM, func() error, error) // TxPool API SendTx(ctx context.Context, signedTx *types.Transaction) error GetPoolTransactions() ([]*types.Transaction, error) GetPoolTransaction(txHash common.Hash) *types.Transaction Stats() (pending int, queued int) TxPoolContent() (map[common.Name][]*types.Transaction, map[common.Name][]*types.Transaction) //Account API GetAccountManager() (*accountmanager.AccountManager, error) SetGasPrice(gasPrice *big.Int) bool //Wallet Wallet() *wallet.Wallet // P2P AddPeer(url string) error RemovePeer(url string) error AddTrustedPeer(url string) error RemoveTrustedPeer(url string) error PeerCount() int Peers() []string SelfNode() string Engine() consensus.IEngine APIs() []rpc.API }
Backend interface provides the common API services (that are provided by both full and light clients) with access to necessary functions.
type PrivateKeyStoreAPI ¶
type PrivateKeyStoreAPI struct {
// contains filtered or unexported fields
}
func NewPrivateKeyStoreAPI ¶
func NewPrivateKeyStoreAPI(b Backend) *PrivateKeyStoreAPI
func (*PrivateKeyStoreAPI) Delete ¶
func (api *PrivateKeyStoreAPI) Delete(ctx context.Context, addr common.Address, passphrase string) error
Delete deletes a account by passsphrase.
func (*PrivateKeyStoreAPI) ExportRawKey ¶
func (api *PrivateKeyStoreAPI) ExportRawKey(ctx context.Context, addr common.Address, passphrase string) (hexutil.Bytes, error)
ExportRawKey export account private key .
func (*PrivateKeyStoreAPI) ImportRawKey ¶
func (api *PrivateKeyStoreAPI) ImportRawKey(ctx context.Context, privkey string, passphrase string) (map[string]interface{}, error)
ImportRawKey stores the given key into the key directory, encrypting it with the passphrase.
func (*PrivateKeyStoreAPI) ListAccount ¶
func (api *PrivateKeyStoreAPI) ListAccount(ctx context.Context) ([]map[string]interface{}, error)
ListAccount returns all key files
func (*PrivateKeyStoreAPI) NewAccount ¶
func (api *PrivateKeyStoreAPI) NewAccount(ctx context.Context, passphrase string) (map[string]interface{}, error)
NewAccount generates a new key and stores it into the key directory.
func (*PrivateKeyStoreAPI) SignData ¶
func (api *PrivateKeyStoreAPI) SignData(ctx context.Context, addr common.Address, passphrase string, data hexutil.Bytes) (hexutil.Bytes, error)
SignData sign data and return raw hex
func (*PrivateKeyStoreAPI) SignTransaction ¶
func (api *PrivateKeyStoreAPI) SignTransaction(ctx context.Context, addr common.Address, passphrase string, tx *types.Transaction) (hexutil.Bytes, error)
SignTransaction sign transaction and return raw hex .
type PrivateP2pAPI ¶
type PrivateP2pAPI struct {
// contains filtered or unexported fields
}
PrivateP2pAPI offers and API for p2p networking.
func NewPrivateP2pAPI ¶
func NewPrivateP2pAPI(b Backend) *PrivateP2pAPI
NewPrivateP2pAPI creates a new p2p service that gives information about p2p networking.
func (*PrivateP2pAPI) AddPeer ¶
func (api *PrivateP2pAPI) AddPeer(url string) (bool, error)
AddPeer requests connecting to a remote node, and also maintaining the new connection at all times, even reconnecting if it is lost.
func (*PrivateP2pAPI) AddTrustedPeer ¶
func (api *PrivateP2pAPI) AddTrustedPeer(url string) (bool, error)
AddTrustedPeer allows a remote node to always connect, even if slots are full
func (*PrivateP2pAPI) PeerCount ¶
func (api *PrivateP2pAPI) PeerCount() int
PeerCount return number of connected peers
func (*PrivateP2pAPI) PeerEvents ¶
func (api *PrivateP2pAPI) PeerEvents(ctx context.Context) (*rpc.Subscription, error)
PeerEvents creates an RPC subscription which receives peer events from the node's p2p.Server
func (*PrivateP2pAPI) Peers ¶
func (api *PrivateP2pAPI) Peers() []string
Peers return connected peers
func (*PrivateP2pAPI) RemovePeer ¶
func (api *PrivateP2pAPI) RemovePeer(url string) (bool, error)
RemovePeer disconnects from a remote node if the connection exists
func (*PrivateP2pAPI) RemoveTrustedPeer ¶
func (api *PrivateP2pAPI) RemoveTrustedPeer(url string) (bool, error)
RemoveTrustedPeer removes a remote node from the trusted peer set, but it does not disconnect it automatically.
func (*PrivateP2pAPI) SelfNode ¶
func (api *PrivateP2pAPI) SelfNode() string
SelfNode return self enode url
type PublicBlockChainAPI ¶
type PublicBlockChainAPI struct {
// contains filtered or unexported fields
}
func NewPublicBlockChainAPI ¶
func NewPublicBlockChainAPI(b Backend) *PublicBlockChainAPI
NewPublicBlockChainAPI creates a new Ethereum blockchain API.
func (*PublicBlockChainAPI) Call ¶
func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNr rpc.BlockNumber) (hexutil.Bytes, error)
Call executes the given transaction on the state for the given block number. It doesn't make and changes in the state/blockchain and is useful to execute and retrieve values.
func (*PublicBlockChainAPI) EstimateGas ¶
func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs) (hexutil.Uint64, error)
EstimateGas returns an estimate of the amount of gas needed to execute the given transaction against the current pending block.
func (*PublicBlockChainAPI) GetBlockByHash ¶
func (s *PublicBlockChainAPI) GetBlockByHash(ctx context.Context, blockHash common.Hash, fullTx bool) (map[string]interface{}, error)
GetBlockByHash returns the requested block. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.
func (*PublicBlockChainAPI) GetBlockByNumber ¶
func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, blockNr rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)
GetBlockByNumber returns the requested block. When blockNr is -1 the chain head is returned. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.
func (*PublicBlockChainAPI) GetCurrentBlock ¶
func (s *PublicBlockChainAPI) GetCurrentBlock(fullTx bool) map[string]interface{}
GetCurrentBlock returns cureent block.
func (*PublicBlockChainAPI) GetTransactionByHash ¶
func (s *PublicBlockChainAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) *types.RPCTransaction
GetTransactionByHash returns the transaction for the given hash
func (*PublicBlockChainAPI) GetTransactionReceipt ¶
func (s *PublicBlockChainAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (*types.RPCReceipt, error)
GetTransactionReceipt returns the transaction receipt for the given transaction hash.
type PublicFractalAPI ¶
type PublicFractalAPI struct {
// contains filtered or unexported fields
}
PublicFractalAPI offers and API for the transaction pool. It only operates on data that is non confidential.
func NewPublicFractalAPI ¶
func NewPublicFractalAPI(b Backend) *PublicFractalAPI
NewPublicFractalAPI creates a new tx pool service that gives information about the transaction pool.
func (*PublicFractalAPI) SendRawTransaction ¶
func (s *PublicFractalAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error)
SendRawTransaction will add the signed transaction to the transaction pool. The sender is responsible for signing the transaction and using the correct nonce.
func (*PublicFractalAPI) SendTransaction ¶
type PublicTxPoolAPI ¶
type PublicTxPoolAPI struct {
// contains filtered or unexported fields
}
PublicTxPoolAPI offers and API for the transaction pool. It only operates on data that is non confidential.
func NewPublicTxPoolAPI ¶
func NewPublicTxPoolAPI(b Backend) *PublicTxPoolAPI
NewPublicTxPoolAPI creates a new tx pool service that gives information about the transaction pool.
func (*PublicTxPoolAPI) Content ¶
func (s *PublicTxPoolAPI) Content() map[string]map[string]map[string]*types.RPCTransaction
Content returns the transactions contained within the transaction pool.
func (*PublicTxPoolAPI) SetGasPrice ¶
func (s *PublicTxPoolAPI) SetGasPrice(gasprice *big.Int) bool
SetGasPrice set gas price limit
func (*PublicTxPoolAPI) Status ¶
func (s *PublicTxPoolAPI) Status() map[string]int
Status returns the number of pending and queued transaction in the pool.
type SendArgs ¶
type SendArgs struct { ChainID *big.Int `json:"chainID"` ActionType types.ActionType `json:"actionType"` GasAssetID uint64 `json:"gasAssetId"` From common.Name `json:"from"` To common.Name `json:"to"` Nonce uint64 `json:"nonce"` AssetID uint64 `json:"assetId"` Gas uint64 `json:"gas"` GasPrice *big.Int `json:"gasPrice"` Value *big.Int `json:"value"` Data hexutil.Bytes `json:"data"` Passphrase string `json:"password"` }