ethapi

package
v1.0.0-rc2-dev Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2019 License: GPL-3.0 Imports: 57 Imported by: 0

Documentation

Overview

Package ethapi implements the general Ethereum API functions.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyString   = &decError{"empty input string"}
	ErrSyntax        = &decError{"invalid hex string"}
	ErrMissingPrefix = &decError{"hex string without 0x prefix"}
	ErrOddLength     = &decError{"hex string of odd length"}
	ErrUint64Range   = &decError{"hex number > 64 bits"}
)

Functions

func GetAPIs

func GetAPIs(apiBackend Backend) []rpc.API

func GetBlockReward

func GetBlockReward(block *types.Block) [3]*big.Int

*

[0] block reward
[1] community reward
[2] team reward

func IsBase58Str

func IsBase58Str(s string) bool

func MixAdrressToPkr

func MixAdrressToPkr(addr MixAdrress) keys.PKr

func RPCMarshalBlock

func RPCMarshalBlock(b *types.Block, inclTx bool, fullTx bool) (map[string]interface{}, error)

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 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 {
	// General Ethereum API
	Downloader() *downloader.Downloader
	ProtocolVersion() int
	PeerCount() uint
	SuggestPrice(ctx context.Context) (*big.Int, error)
	ChainDb() serodb.Database
	EventMux() *event.TypeMux
	AccountManager() *accounts.Manager

	// BlockChain API
	SetHead(number uint64)
	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.Receipts, error)
	GetTd(blockHash common.Hash) *big.Int
	GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.Header, vmCfg vm.Config) (*vm.EVM, func() error, error)
	SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription
	SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription
	SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription

	// TxPool API
	SendTx(ctx context.Context, signedTx *types.Transaction) error
	GetPoolTransactions() (types.Transactions, error)
	GetPoolTransaction(txHash common.Hash) *types.Transaction
	//GetPoolNonce(ctx context.Context, addr common.Data) (uint64, error)
	Stats() (pending int, queued int)
	TxPoolContent() (types.Transactions, types.Transactions)
	SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription

	ChainConfig() *params.ChainConfig
	CurrentBlock() *types.Block
	GetEngin() consensus.Engine
	GetMiner() *miner.Miner

	GetBlocksInfo(start uint64, count uint64) ([]txtool.Block, error)
	GetAnchor(roots []keys.Uint256) ([]txtool.Witness, error)
	CommitTx(tx *txtool.GTx) error

	GetPkNumber(pk keys.Uint512) (number uint64, e error)
	GetPkr(address *keys.Uint512, index *keys.Uint256) (keys.PKr, error)
	GetBalances(address keys.Uint512) (balances map[string]*big.Int)
	GenTx(param prepare.PreTxParam) (*txtool.GTxParam, error)
	GetRecordsByPk(pk *keys.Uint512, begin, end uint64) (records []exchange.Utxo, err error)
	GetRecordsByPkr(pkr keys.PKr, begin, end uint64) (records []exchange.Utxo, err error)
	GetLockedBalances(address keys.Uint512) (balances map[string]*big.Int)
	GetMaxAvailable(pk keys.Uint512, currency string) (amount *big.Int)
	GetRecordsByTxHash(txHash keys.Uint256) (records []exchange.Utxo, err error)

	//Light node api
	GetOutByPKr(pkrs []keys.PKr, start, end uint64) (br light.BlockOutResp, e error)
	CheckNil(Nils []keys.Uint256) (nilResps []light.NilValue, e error)
}

Backend interface provides the common API services (that are provided by both full and light clients) with access to necessary functions.

type Balance

type Balance struct {
	Tkn map[string]*hexutil.Big   `json:"tkn"`
	Tkt map[string][]*common.Hash `json:"tkt"`
}

func GetBalanceFromAccounts

func GetBalanceFromAccounts(tk *keys.Uint512) (result Balance)

func GetBalanceFromExchange

func GetBalanceFromExchange(tkns map[string]*big.Int) (result Balance)

type Big

type Big big.Int

func (Big) MarshalJSON

func (b Big) MarshalJSON() ([]byte, error)

func (*Big) ToInt

func (b *Big) ToInt() *big.Int

func (*Big) UnmarshalJSON

func (b *Big) UnmarshalJSON(input []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Block

type Block struct {
	BlockNumber uint64
	BlockHash   keys.Uint256
	Ins         []keys.Uint256
	Outs        []Record
	TxHashes    []common.Hash
	Timestamp   uint64
}

type BuyShareTxArg

type BuyShareTxArg struct {
	From     address.AccountAddress `json:"from"`
	Vote     *common.Address        `json:"vote"`
	Pool     *hexutil.Bytes         `json:"pool"`
	Gas      *hexutil.Uint64        `json:"gas"`
	GasPrice *hexutil.Big           `json:"gasPrice"`
	Value    *hexutil.Big           `json:"value"`
}

type CallArgs

type CallArgs struct {
	From        address.AccountAddress `json:"from"`
	To          *common.Address        `json:"to"`
	GasCurrency Smbol                  `json:"gasCy"` //default SERO
	Gas         hexutil.Uint64         `json:"gas"`
	GasPrice    hexutil.Big            `json:"gasPrice"`
	Value       hexutil.Big            `json:"value"`
	Data        hexutil.Bytes          `json:"data"`
	Currency    Smbol                  `json:"cy"`
	Dynamic     bool                   `json:"dy"` //contract address parameters are dynamically generated.
	Category    Smbol                  `json:"catg"`
	Tkt         *common.Hash           `json:"tkt"`
}

CallArgs represents the arguments for a call.

type ClosePkgArgs

type ClosePkgArgs struct {
	From     *address.AccountAddress `json:"from"`
	Gas      *hexutil.Uint64         `json:"gas"`
	GasPrice *hexutil.Big            `json:"gasPrice"`
	PkgId    *keys.Uint256           `json:"id"`
	Key      *keys.Uint256           `json:"key"`
}

*

func (s *PublicTransactionPoolAPI) CreatePkg(ctx context.Context, args SendTxArgs) (common.Hash, error) {
	s.nonceLock.mu.Lock()
	defer s.nonceLock.mu.Unlock()
	// Look up the wallet containing the requested abi
	account := accounts.Account{Address: args.From}

	wallet, err := s.b.AccountManager().Find(account)
	if err != nil {
		return common.Hash{}, err
	}

	if args.To == nil {
		return common.Hash{}, errors.New("to can not be nil")
	}

	// Set some sanity defaults and terminate on failure
	if err := args.setDefaults(ctx, s.b); err != nil {
		return common.Hash{}, err
	}

	if args.GasCurrency.IsNotSero() {
		return common.Hash{}, errors.New("create pkg gasCurrency must be sero")
	}

	state, _, err := s.b.StateAndHeaderByNumber(ctx, -1)

	if err != nil {
		return common.Hash{}, err
	}

	if seroparam.IsExchange() {
		txParam := args.toCreatePkg(state)
		pretx, gtx, err := exchange.CurrentExchange().GenTxWithSign(txParam)
		if err != nil {
			return common.Hash{}, err
		}
		err = s.b.CommitTx(gtx)
		if err != nil {
			exchange.CurrentExchange().ClearTxParam(pretx)
			return common.Hash{}, err
		}
		return common.BytesToHash(gtx.Hash[:]), nil
	} else {
		// Assemble the transaction and sign with the wallet
		tx, txt := args.toPkg(state)
		encrypted, err := wallet.EncryptTx(account, tx, txt, state)
		if err != nil {
			return common.Hash{}, err
		}
		return submitTransaction(ctx, s.b, encrypted, args.To)
	}

} *

type ConvertAddress

type ConvertAddress struct {
	Addr      map[address.AccountAddress]common.Address `json:"addr"`
	ShortAddr map[common.Address]common.ContractAddress `json:"shortAddr"`
	Rand      *keys.Uint128                             `json:"rand"`
}

type EncryptTransactionResult

type EncryptTransactionResult struct {
	Raw hexutil.Bytes      `json:"raw"`
	Tx  *types.Transaction `json:"tx"`
}

EncryptTransactionResult represents a RLP encoded signed transaction.

type ExecutionResult

type ExecutionResult struct {
	Gas         uint64         `json:"gas"`
	Failed      bool           `json:"failed"`
	ReturnValue string         `json:"returnValue"`
	StructLogs  []StructLogRes `json:"structLogs"`
}

ExecutionResult groups all structured logs emitted by the EVM while replaying a transaction in debug mode as well as transaction execution status, the amount of gas used and the return value

type GenTxArgs

type GenTxArgs struct {
	From       PKAddress
	RefundTo   *PKrAddress
	Receptions []ReceptionArgs
	Gas        uint64
	GasPrice   *Big
	Roots      []keys.Uint256
}

type MergeArgs

type MergeArgs struct {
	From     PKAddress
	To       *PKrAddress
	Currency Smbol
	Zcount   uint64
	Left     uint64
}

func (MergeArgs) Check

func (args MergeArgs) Check() error

func (MergeArgs) ToMergParam

func (args MergeArgs) ToMergParam() *exchange.MergeParam

type MixAdrress

type MixAdrress []byte

func (MixAdrress) MarshalText

func (b MixAdrress) MarshalText() ([]byte, error)

func (*MixAdrress) UnmarshalText

func (b *MixAdrress) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type MixBase58Adrress

type MixBase58Adrress []byte

func (MixBase58Adrress) MarshalText

func (b MixBase58Adrress) MarshalText() ([]byte, error)

func (*MixBase58Adrress) UnmarshalText

func (b *MixBase58Adrress) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type PKAddress

type PKAddress [64]byte

func (PKAddress) MarshalText

func (b PKAddress) MarshalText() ([]byte, error)

func (PKAddress) ToUint512

func (b PKAddress) ToUint512() keys.Uint512

func (*PKAddress) UnmarshalText

func (b *PKAddress) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type PKrAddress

type PKrAddress [96]byte

func (PKrAddress) MarshalText

func (b PKrAddress) MarshalText() ([]byte, error)

func (PKrAddress) ToPKr

func (b PKrAddress) ToPKr() *keys.PKr

func (*PKrAddress) UnmarshalText

func (b *PKrAddress) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type PrivateAccountAPI

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

PrivateAccountAPI provides an API to access accounts managed by this node. It offers methods to create, (un)lock en list accounts. Some methods accept passwords and are therefore considered private by default.

func NewPrivateAccountAPI

func NewPrivateAccountAPI(b Backend, nonceLock *AddrLocker) *PrivateAccountAPI

NewPrivateAccountAPI create a new PrivateAccountAPI.

func (*PrivateAccountAPI) DeriveAccount

func (s *PrivateAccountAPI) DeriveAccount(url string, path string, pin *bool) (accounts.Account, error)

DeriveAccount requests a HD wallet to derive a new account, optionally pinning it for later reuse.

func (*PrivateAccountAPI) ExportMnemonic

func (s *PrivateAccountAPI) ExportMnemonic(addr address.AccountAddress, password string) (string, error)

func (*PrivateAccountAPI) ExportRawKey

func (s *PrivateAccountAPI) ExportRawKey(addr address.AccountAddress, password string) (hexutil.Bytes, error)

func (*PrivateAccountAPI) GenSeed

func (s *PrivateAccountAPI) GenSeed() (hexutil.Bytes, error)

func (*PrivateAccountAPI) ImportMnemonic

func (s *PrivateAccountAPI) ImportMnemonic(mnemonic string, password string) (address.AccountAddress, error)

func (*PrivateAccountAPI) ImportRawKey

func (s *PrivateAccountAPI) ImportRawKey(privkey string, password string) (address.AccountAddress, error)

ImportRawKey stores the given hex encoded ECDSA key into the key directory, encrypting it with the passphrase.

func (*PrivateAccountAPI) ImportTk

func (*PrivateAccountAPI) ListAccounts

func (s *PrivateAccountAPI) ListAccounts() []address.AccountAddress

ListAccounts will return a list of addresses for accounts this node manages.

func (*PrivateAccountAPI) ListWallets

func (s *PrivateAccountAPI) ListWallets() []rawWallet

ListWallets will return a list of wallets this node manages.

func (*PrivateAccountAPI) LockAccount

func (s *PrivateAccountAPI) LockAccount(addr address.AccountAddress) bool

LockAccount will lock the account associated with the given address when it's unlocked.

func (*PrivateAccountAPI) NewAccount

func (s *PrivateAccountAPI) NewAccount(password string) (address.AccountAddress, error)

NewAccount will create a new account and returns the address for the new account.

func (*PrivateAccountAPI) NewAccountWithMnemonic

func (s *PrivateAccountAPI) NewAccountWithMnemonic(password string) (map[string]string, error)

NewAccount will create a new account and returns the mnemonic 、address for the new account.

func (*PrivateAccountAPI) OpenWallet

func (s *PrivateAccountAPI) OpenWallet(url string, passphrase *string) error

OpenWallet initiates a hardware wallet opening procedure, establishing a USB connection and attempting to authenticate via the provided passphrase. Note, the method may return an extra challenge requiring a second open (e.g. the Trezor PIN matrix challenge).

func (*PrivateAccountAPI) SendTransaction

func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error)

SendTransaction will create a transaction from the given arguments and tries to sign it with the key associated with args.To. If the given passwd isn't able to decrypt the key it fails.

func (*PrivateAccountAPI) SignAndSendTransaction

func (s *PrivateAccountAPI) SignAndSendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error)

SignAndSendTransaction was renamed to SendTransaction. This method is deprecated and will be removed in the future. It primary goal is to give clients time to update.

func (*PrivateAccountAPI) UnlockAccount

func (s *PrivateAccountAPI) UnlockAccount(addr address.AccountAddress, password string, duration *uint64) (bool, error)

UnlockAccount will unlock the account associated with the given address with the given password for duration seconds. If duration is nil it will use a default of 300 seconds. It returns an indication if the account was unlocked.

type PrivateDebugAPI

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

PrivateDebugAPI is the collection of Ethereum APIs exposed over the private debugging endpoint.

func NewPrivateDebugAPI

func NewPrivateDebugAPI(b Backend) *PrivateDebugAPI

NewPrivateDebugAPI creates a new API definition for the private debug methods of the Ethereum service.

func (*PrivateDebugAPI) ChaindbCompact

func (api *PrivateDebugAPI) ChaindbCompact() error

func (*PrivateDebugAPI) ChaindbProperty

func (api *PrivateDebugAPI) ChaindbProperty(property string) (string, error)

ChaindbProperty returns leveldb properties of the chain database.

func (*PrivateDebugAPI) SetHead

func (api *PrivateDebugAPI) SetHead(number hexutil.Uint64)

SetHead rewinds the head of the blockchain to a previous block.

type PublicAccountAPI

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

PublicAccountAPI provides an API to access accounts managed by this node. It offers only methods that can retrieve accounts.

func NewPublicAccountAPI

func NewPublicAccountAPI(am *accounts.Manager) *PublicAccountAPI

NewPublicAccountAPI creates a new PublicAccountAPI.

func (*PublicAccountAPI) Accounts

func (s *PublicAccountAPI) Accounts() []address.AccountAddress

Accounts returns the collection of accounts this node manages

func (*PublicAccountAPI) GetTk

func (*PublicAccountAPI) IsMinePKr

type PublicBlockChainAPI

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

PublicBlockChainAPI provides an API to access the Ethereum blockchain. It offers only methods that operate on public data that is freely available to anyone.

func NewPublicBlockChainAPI

func NewPublicBlockChainAPI(b Backend) *PublicBlockChainAPI

NewPublicBlockChainAPI creates a new Ethereum blockchain API.

func (*PublicBlockChainAPI) BlockNumber

func (s *PublicBlockChainAPI) BlockNumber() hexutil.Uint64

BlockNumber returns the block number of the chain head.

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) ConvertAddressParams

func (s *PublicBlockChainAPI) ConvertAddressParams(ctx context.Context, rand *keys.Uint128, addresses []address.AccountAddress, dy bool) (*ConvertAddress, error)

func (*PublicBlockChainAPI) CurrencyToContractAddress

func (s *PublicBlockChainAPI) CurrencyToContractAddress(ctx context.Context, cy string) (*address.AccountAddress, error)

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) GenPKr

func (*PublicBlockChainAPI) GetAnchor

func (s *PublicBlockChainAPI) GetAnchor(ctx context.Context, roots []keys.Uint256) ([]txtool.Witness, error)

func (*PublicBlockChainAPI) GetBalance

func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, addr common.Address, blockNr rpc.BlockNumber) (Balance, error)

GetBalance returns the amount of wei for the given address in the state of the given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.

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) GetBlockInfo

func (s *PublicBlockChainAPI) GetBlockInfo(ctx context.Context, start hexutil.Uint64, count hexutil.Uint64) ([]txtool.Block, error)

func (*PublicBlockChainAPI) GetBlockRewardByNumber

func (s *PublicBlockChainAPI) GetBlockRewardByNumber(ctx context.Context, blockNr rpc.BlockNumber) [3]hexutil.Big

func (*PublicBlockChainAPI) GetCode

func (s *PublicBlockChainAPI) GetCode(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (hexutil.Bytes, error)

GetCode returns the code stored at the given address in the state for the given block number.

func (*PublicBlockChainAPI) GetDecimal

func (s *PublicBlockChainAPI) GetDecimal(ctx context.Context, tokenName string) (*hexutil.Uint, error)

func (*PublicBlockChainAPI) GetFullAddress

func (s *PublicBlockChainAPI) GetFullAddress(ctx context.Context, shortAddresses []common.ContractAddress) (map[common.ContractAddress]common.Address, error)

func (*PublicBlockChainAPI) GetStorageAt

func (s *PublicBlockChainAPI) GetStorageAt(ctx context.Context, address common.Address, key string, blockNr rpc.BlockNumber) (hexutil.Bytes, error)

GetStorageAt returns the storage from the state at the given address, key and block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.

func (*PublicBlockChainAPI) WatchPkg

func (s *PublicBlockChainAPI) WatchPkg(ctx context.Context, id keys.Uint256, key keys.Uint256) (map[string]interface{}, error)

* func (s *PublicBlockChainAPI) GetPkg(ctx context.Context, addr common.Address, packed bool, id *keys.Uint256) (interface{}, error) {

	state, _, err := s.b.StateAndHeaderByNumber(ctx, -1)
	if err != nil {
		return nil, err
	}
	wallets := s.b.AccountManager().Wallets()
	accountAddress := getAccountAddress(addr, s.b)
	if accountAddress == nil {
		return nil, nil
	}

	if state.IsContract(common.BytesToAddress(accountAddress[:])) {
		return nil, errors.New("does not support contract address!")
	}
	// Look up the wallet containing the requested abi
	account := accounts.Account{Address: *accountAddress}
	wallet, err := s.b.AccountManager().Find(account)
	if err != nil {
		return nil, err
	}
	seed := wallet.Accounts()[0].Tk
	pkgs := lstate.CurrentLState().GetPkgs(seed.ToUint512(), packed)
	if len(pkgs) > 0 {
		result := []map[string]interface{}{}
		for _, p := range pkgs {
			pkg := map[string]interface{}{}

			pkg["id"] = p.Pkg.Z.Pack.Id
			pkg["packed"] = packed
			to := getLocalAccountAddressByPkr(wallets, common.BytesToAddress(p.Pkg.Z.Pack.PKr[:]))
			if to != nil {
				pkg["to_addr"] = to
			} else {
				pkg["to"] = common.BytesToAddress(p.Pkg.Z.Pack.PKr[:]).String()
			}
			if (p.Key != keys.Uint256{}) {
				pkg["key"] = p.Key
				asset := map[string]interface{}{}
				if p.Pkg.O.Asset.Tkn != nil {
					tkn := map[string]interface{}{}
					tkn["currency"] = strings.Trim(string(p.Pkg.O.Asset.Tkn.Currency[:]), zerobyte)
					tkn["value"] = p.Pkg.O.Asset.Tkn.Value
					asset["tkn"] = tkn
				}
				if p.Pkg.O.Asset.Tkt != nil {
					tkt := map[string]interface{}{}
					tkt["category"] = strings.Trim(string(p.Pkg.O.Asset.Tkt.Category[:]), zerobyte)
					tkt["value"] = p.Pkg.O.Asset.Tkt.Value
					asset["tkt"] = tkt
				}

				pkg["asset"] = asset

			}
			if id != nil {
				if p.Pkg.Z.Pack.Id == *id {
					return pkg, nil
				} else {
					continue
				}
			} else {
				result = append(result, pkg)
			}

		}
		return result, nil
	}
	return nil, nil
}

*

type PublicDebugAPI

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

PublicDebugAPI is the collection of Ethereum APIs exposed over the public debugging endpoint.

func NewPublicDebugAPI

func NewPublicDebugAPI(b Backend) *PublicDebugAPI

NewPublicDebugAPI creates a new API definition for the public debug methods of the Ethereum service.

func (*PublicDebugAPI) GetBlockRlp

func (api *PublicDebugAPI) GetBlockRlp(ctx context.Context, number uint64) (string, error)

GetBlockRlp retrieves the RLP encoded for of a single block.

func (*PublicDebugAPI) PrintBlock

func (api *PublicDebugAPI) PrintBlock(ctx context.Context, number uint64) (string, error)

PrintBlock retrieves a block and returns its pretty printed form.

func (*PublicDebugAPI) SeedHash

func (api *PublicDebugAPI) SeedHash(ctx context.Context, number uint64) (string, error)

SeedHash retrieves the seed hash of a block.

type PublicEthereumAPI

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

PublicEthereumAPI provides an API to access Ethereum related information. It offers only methods that operate on public data that is freely available to anyone.

func NewPublicEthereumAPI

func NewPublicEthereumAPI(b Backend) *PublicEthereumAPI

NewPublicEthereumAPI creates a new Ethereum protocol API.

func (*PublicEthereumAPI) GasPrice

func (s *PublicEthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error)

GasPrice returns a suggestion for a gas price.

func (*PublicEthereumAPI) ProtocolVersion

func (s *PublicEthereumAPI) ProtocolVersion() hexutil.Uint

ProtocolVersion returns the current Ethereum protocol version this node supports

func (*PublicEthereumAPI) Syncing

func (s *PublicEthereumAPI) Syncing() (interface{}, error)

Syncing returns false in case the node is currently not syncing with the network. It can be up to date or has not yet received the latest block headers from its pears. In case it is synchronizing: - startingBlock: block number this node started to synchronise from - currentBlock: block number this node is currently importing - highestBlock: block number of the highest block header this node has received from peers - pulledStates: number of state entries processed until now - knownStates: number of known state entries that still need to be pulled

type PublicExchangeAPI

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

func (*PublicExchangeAPI) ClearUsedFlag

func (s *PublicExchangeAPI) ClearUsedFlag(ctx context.Context, pkaddress PKAddress) (count int, e error)

func (*PublicExchangeAPI) ClearUsedFlagForRoot

func (s *PublicExchangeAPI) ClearUsedFlagForRoot(ctx context.Context, roots []keys.Uint256) (count int, e error)

func (*PublicExchangeAPI) CommitTx

func (s *PublicExchangeAPI) CommitTx(ctx context.Context, args *txtool.GTx) error

func (*PublicExchangeAPI) GenMergeTx

func (s *PublicExchangeAPI) GenMergeTx(ctx context.Context, args MergeArgs) (txParam *txtool.GTxParam, e error)

func (*PublicExchangeAPI) GenTx

func (s *PublicExchangeAPI) GenTx(ctx context.Context, param GenTxArgs) (*txtool.GTxParam, error)

func (*PublicExchangeAPI) GenTxWithSign

func (s *PublicExchangeAPI) GenTxWithSign(ctx context.Context, param GenTxArgs) (*txtool.GTx, error)

func (*PublicExchangeAPI) GetBalances

func (s *PublicExchangeAPI) GetBalances(ctx context.Context, address PKAddress) map[string]*Big

func (*PublicExchangeAPI) GetBlockByNumber

func (s *PublicExchangeAPI) GetBlockByNumber(ctx context.Context, blockNum *int64) (map[string]interface{}, error)

func (*PublicExchangeAPI) GetBlocksInfo

func (s *PublicExchangeAPI) GetBlocksInfo(ctx context.Context, start, end uint64) (blocks []Block, err error)

func (*PublicExchangeAPI) GetLockedBalances

func (s *PublicExchangeAPI) GetLockedBalances(address PKAddress) map[string]*Big

func (*PublicExchangeAPI) GetMaxAvailable

func (s *PublicExchangeAPI) GetMaxAvailable(address PKAddress, currency Smbol) (amount *Big)

func (*PublicExchangeAPI) GetPkByPkr

func (*PublicExchangeAPI) GetPkSynced

func (s *PublicExchangeAPI) GetPkSynced(ctx context.Context, pk *PKAddress) (map[string]interface{}, error)

func (*PublicExchangeAPI) GetPkr

func (s *PublicExchangeAPI) GetPkr(ctx context.Context, address PKAddress, index *keys.Uint256) (pkrAdd PKrAddress, e error)

func (*PublicExchangeAPI) GetRecords

func (s *PublicExchangeAPI) GetRecords(ctx context.Context, begin, end uint64, address *MixAdrress) (records []Record, err error)

func (*PublicExchangeAPI) GetTx

func (s *PublicExchangeAPI) GetTx(ctx context.Context, txHash keys.Uint256) (map[string]interface{}, error)

func (*PublicExchangeAPI) Merge

func (s *PublicExchangeAPI) Merge(ctx context.Context, address *PKAddress, cy Smbol) (map[string]interface{}, error)

func (*PublicExchangeAPI) Seed2Sk

func (s *PublicExchangeAPI) Seed2Sk(ctx context.Context, seed hexutil.Bytes) (keys.Uint512, error)

func (*PublicExchangeAPI) SignTxWithSk

func (s *PublicExchangeAPI) SignTxWithSk(param txtool.GTxParam, SK keys.Uint512) (txtool.GTx, error)

func (*PublicExchangeAPI) Sk2Tk

func (*PublicExchangeAPI) Tk2Pk

func (*PublicExchangeAPI) ValidAddress

func (s *PublicExchangeAPI) ValidAddress(ctx context.Context, addr MixBase58Adrress) (bool, error)

type PublicLightNodeApi

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

func (PublicLightNodeApi) CheckNil

func (plna PublicLightNodeApi) CheckNil(Nils []keys.Uint256) (nilResps []light.NilValue, e error)

func (PublicLightNodeApi) GetOutsByPKr

func (plna PublicLightNodeApi) GetOutsByPKr(ctx context.Context, addresses []*MixAdrress, start, end uint64) (outBlockResp light.BlockOutResp, e error)

type PublicNetAPI

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

PublicNetAPI offers network related RPC methods

func NewPublicNetAPI

func NewPublicNetAPI(net *p2p.Server, networkVersion uint64) *PublicNetAPI

NewPublicNetAPI creates a new net API instance.

func (*PublicNetAPI) Listening

func (s *PublicNetAPI) Listening() bool

Listening returns an indication if the node is listening for network connections.

func (*PublicNetAPI) PeerCount

func (s *PublicNetAPI) PeerCount() hexutil.Uint

PeerCount returns the number of connected peers

func (*PublicNetAPI) Version

func (s *PublicNetAPI) Version() string

Version returns the current ethereum protocol version.

type PublicSSIAPI

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

func (*PublicSSIAPI) CommitTx

func (s *PublicSSIAPI) CommitTx(ctx context.Context, txhash keys.Uint256) (e error)

func (*PublicSSIAPI) CreateKr

func (s *PublicSSIAPI) CreateKr() (kr txtool.Kr)

func (*PublicSSIAPI) Detail

func (s *PublicSSIAPI) Detail(ctx context.Context, roots []keys.Uint256, skr *keys.PKr) (douts []txtool.DOut, e error)

func (*PublicSSIAPI) GenTx

func (s *PublicSSIAPI) GenTx(ctx context.Context, param *ssi.GenTxParam) (hash keys.Uint256, e error)

func (*PublicSSIAPI) GetBlocksInfo

func (s *PublicSSIAPI) GetBlocksInfo(ctx context.Context, start hexutil.Uint64, count hexutil.Uint64) ([]ssi.Block, error)

func (*PublicSSIAPI) GetTx

func (s *PublicSSIAPI) GetTx(ctx context.Context, txhash keys.Uint256) (tx *txtool.GTx, e error)

type PublicStakeApI

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

func NewPublicStakeApI

func NewPublicStakeApI(b Backend, nonceLock *AddrLocker) *PublicStakeApI

func (*PublicStakeApI) BuyShare

func (s *PublicStakeApI) BuyShare(ctx context.Context, args BuyShareTxArg) (common.Hash, error)

func (*PublicStakeApI) CloseStakePool

func (s *PublicStakeApI) CloseStakePool(ctx context.Context, from common.Address) (common.Hash, error)

func (*PublicStakeApI) EstimateShares

func (s *PublicStakeApI) EstimateShares(ctx context.Context, args BuyShareTxArg) (map[string]interface{}, error)

func (*PublicStakeApI) GetShare

func (s *PublicStakeApI) GetShare(ctx context.Context, shareId common.Hash) map[string]interface{}

func (*PublicStakeApI) ModifyStakePoolFee

func (s *PublicStakeApI) ModifyStakePoolFee(ctx context.Context, from common.Address, fee hexutil.Uint64) (common.Hash, error)

func (*PublicStakeApI) ModifyStakePoolVote

func (s *PublicStakeApI) ModifyStakePoolVote(ctx context.Context, from common.Address, vote common.Address) (common.Hash, error)

func (*PublicStakeApI) MyShare

func (s *PublicStakeApI) MyShare(ctx context.Context, addr common.Address) []map[string]interface{}

func (*PublicStakeApI) PoolState

func (s *PublicStakeApI) PoolState(ctx context.Context, pool common.Hash) (map[string]interface{}, error)

func (*PublicStakeApI) RegistStakePool

func (s *PublicStakeApI) RegistStakePool(ctx context.Context, args RegistStakePoolTxArg) (common.Hash, error)

func (*PublicStakeApI) SharePoolSize

func (s *PublicStakeApI) SharePoolSize(ctx context.Context) (hexutil.Uint64, error)

func (*PublicStakeApI) SharePrice

func (s *PublicStakeApI) SharePrice(ctx context.Context) (*hexutil.Big, error)

func (*PublicStakeApI) StakePools

func (s *PublicStakeApI) StakePools(ctx context.Context) []map[string]interface{}

type PublicTransactionPoolAPI

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

PublicTransactionPoolAPI exposes methods for the RPC interface

func NewPublicTransactionPoolAPI

func NewPublicTransactionPoolAPI(b Backend, nonceLock *AddrLocker) *PublicTransactionPoolAPI

NewPublicTransactionPoolAPI creates a new RPC service with methods specific for the transaction pool.

func (*PublicTransactionPoolAPI) AddressUnlocked

func (s *PublicTransactionPoolAPI) AddressUnlocked(accountAddr address.AccountAddress) (bool, error)

func (*PublicTransactionPoolAPI) ClosePkg

func (*PublicTransactionPoolAPI) CommitTx

func (s *PublicTransactionPoolAPI) CommitTx(ctx context.Context, args *txtool.GTx) error

func (*PublicTransactionPoolAPI) EncryptTransaction

EncryptTransaction will sign the given transaction with the from account. The node needs to have the private key of the account corresponding with the given from address and it needs to be unlocked.

func (*PublicTransactionPoolAPI) GetBlockTransactionCountByHash

func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint

GetBlockTransactionCountByHash returns the number of transactions in the block with the given hash.

func (*PublicTransactionPoolAPI) GetBlockTransactionCountByNumber

func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint

GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number.

func (*PublicTransactionPoolAPI) GetRawTransactionByBlockHashAndIndex

func (s *PublicTransactionPoolAPI) GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) hexutil.Bytes

GetRawTransactionByBlockHashAndIndex returns the bytes of the transaction for the given block hash and index.

func (*PublicTransactionPoolAPI) GetRawTransactionByBlockNumberAndIndex

func (s *PublicTransactionPoolAPI) GetRawTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) hexutil.Bytes

GetRawTransactionByBlockNumberAndIndex returns the bytes of the transaction for the given block number and index.

func (*PublicTransactionPoolAPI) GetRawTransactionByHash

func (s *PublicTransactionPoolAPI) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error)

GetRawTransactionByHash returns the bytes of the transaction for the given hash.

func (*PublicTransactionPoolAPI) GetTransactionByBlockHashAndIndex

func (s *PublicTransactionPoolAPI) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) *RPCTransaction

GetTransactionByBlockHashAndIndex returns the transaction for the given block hash and index.

func (*PublicTransactionPoolAPI) GetTransactionByBlockNumberAndIndex

func (s *PublicTransactionPoolAPI) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) *RPCTransaction

GetTransactionByBlockNumberAndIndex returns the transaction for the given block number and index.

func (*PublicTransactionPoolAPI) GetTransactionByHash

func (s *PublicTransactionPoolAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) *RPCTransaction

GetTransactionByHash returns the transaction for the given hash

func (*PublicTransactionPoolAPI) GetTransactionCount

func (s *PublicTransactionPoolAPI) GetTransactionCount(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (*hexutil.Uint64, error)

GetTransactionCount returns the number of transactions the given address has sent for the given block number

func (*PublicTransactionPoolAPI) GetTransactionReceipt

func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error)

GetTransactionReceipt returns the transaction receipt for the given transaction hash.

func (*PublicTransactionPoolAPI) PendingTransactions

func (s *PublicTransactionPoolAPI) PendingTransactions() ([]*RPCTransaction, error)

PendingTransactions returns the transactions that are in the transaction pool and have a from address that is one of the accounts this node manages.

func (*PublicTransactionPoolAPI) ReSendTransaction

func (s *PublicTransactionPoolAPI) ReSendTransaction(ctx context.Context, txhash common.Hash) (common.Hash, error)

func (*PublicTransactionPoolAPI) SendTransaction

func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args SendTxArgs) (common.Hash, error)

SendTransaction creates a transaction for the given argument, sign it and submit it to the transaction pool.

func (*PublicTransactionPoolAPI) TransferPkg

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]*RPCTransaction

func (*PublicTxPoolAPI) Inspect

func (s *PublicTxPoolAPI) Inspect() map[string]map[string]string

func (*PublicTxPoolAPI) Status

func (s *PublicTxPoolAPI) Status() map[string]hexutil.Uint

Status returns the number of pending and queued transaction in the pool.

type RPCStatisticsShare

type RPCStatisticsShare struct {
	Address     interface{}   `json:"addr"`
	VoteAddress []interface{} `json:"voteAddr"`
	Total       uint32        `json:"total"`
	Remaining   uint32        `json:"remaining"`
	Missed      uint32        `json:"missed"`
	Expired     uint32        `json:"expired"`
	ShareIds    []common.Hash `json:"shareIds"`
	Pools       []common.Hash `json:"pools"`
	Profit      *big.Int      `json:"profit"`
}

type RPCTransaction

type RPCTransaction struct {
	BlockHash        common.Hash     `json:"blockHash"`
	BlockNumber      *hexutil.Big    `json:"blockNumber"`
	From             common.Address  `json:"from"`
	Gas              hexutil.Uint64  `json:"gas"`
	GasPrice         *hexutil.Big    `json:"gasPrice"`
	Hash             common.Hash     `json:"hash"`
	Input            hexutil.Bytes   `json:"input"`
	Nonce            hexutil.Uint64  `json:"nonce"`
	To               *common.Address `json:"to"`
	TransactionIndex hexutil.Uint    `json:"transactionIndex"`
	Value            *hexutil.Big    `json:"value"`
	Stx              *stx.T          `json:"stx"`
}

RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction

type ReceptionArgs

type ReceptionArgs struct {
	Addr     MixAdrress
	Currency Smbol
	Value    *Big
}

type Record

type Record struct {
	Pkr      PKrAddress
	Root     keys.Uint256
	TxHash   keys.Uint256
	Nil      keys.Uint256
	Num      uint64
	Currency string
	Value    *Big
}

type RegistStakePoolTxArg

type RegistStakePoolTxArg struct {
	From     address.AccountAddress `json:"from"`
	Vote     *common.Address        `json:"vote"`
	Gas      *hexutil.Uint64        `json:"gas"`
	GasPrice *hexutil.Big           `json:"gasPrice"`
	Value    *hexutil.Big           `json:"value"`
	Fee      *hexutil.Uint          `json:"fee"`
}

type SRC20Decimal

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

func NewSRC20Decimal

func NewSRC20Decimal(contractAddress address.AccountAddress, tokenName string) []SRC20Decimal

func (SRC20Decimal) Pack

func (d SRC20Decimal) Pack() ([]byte, error)

func (SRC20Decimal) Unpack

func (d SRC20Decimal) Unpack(outData []byte) (*uint8, error)

type SRCAbi

type SRCAbi interface {
	Pack() ([]byte, error)
	Unpack(outData []byte) (*uint8, error)
}

type SendTxArgs

type SendTxArgs struct {
	From        address.AccountAddress `json:"from"`
	To          *common.Address        `json:"to"`
	Gas         *hexutil.Uint64        `json:"gas"`
	GasCurrency Smbol                  `json:"gasCy"` //default SERO
	GasPrice    *hexutil.Big           `json:"gasPrice"`
	Value       *hexutil.Big           `json:"value"`
	Data        *hexutil.Bytes         `json:"data"`
	Currency    Smbol                  `json:"cy"`
	Dynamic     bool                   `json:"dy"` //contract address parameters are dynamically generated.
	Category    Smbol                  `json:"catg"`
	Tkt         *common.Hash           `json:"tkt"`
	Memo        string                 `json:"Memo"`
}

SendTxArgs represents the arguments to sumbit a new transaction into the transaction pool.

type Smbol

type Smbol string

func (*Smbol) IsEmpty

func (s *Smbol) IsEmpty() bool

func (*Smbol) IsNotEmpty

func (s *Smbol) IsNotEmpty() bool

func (*Smbol) IsNotSero

func (s *Smbol) IsNotSero() bool

func (*Smbol) IsSero

func (s *Smbol) IsSero() bool

func (Smbol) MarshalText

func (s Smbol) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*Smbol) UnmarshalText

func (s *Smbol) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler

type StakePool

type StakePool struct {
	PKr             keys.PKr
	VotePKr         keys.PKr
	TransactionHash common.Hash
	Amount          *big.Int `rlp:"nil"`
	Fee             uint16
	ShareNum        uint32
	ChoicedNum      uint32
	MissedNum       uint32
	WishVotNum      uint32
	Profit          *big.Int `rlp:"nil"`
	LastPayTime     uint64
	Closed          bool
}

type StructLogRes

type StructLogRes struct {
	Pc      uint64             `json:"pc"`
	Op      string             `json:"op"`
	Gas     uint64             `json:"gas"`
	GasCost uint64             `json:"gasCost"`
	Depth   int                `json:"depth"`
	Error   error              `json:"error,omitempty"`
	Stack   *[]string          `json:"stack,omitempty"`
	Memory  *[]string          `json:"memory,omitempty"`
	Storage *map[string]string `json:"storage,omitempty"`
}

StructLogRes stores a structured log emitted by the EVM while replaying a transaction in debug mode

func FormatLogs

func FormatLogs(logs []vm.StructLog) []StructLogRes

formatLogs formats EVM returned structured logs for json output

type TKAddress

type TKAddress [64]byte

func (TKAddress) MarshalText

func (b TKAddress) MarshalText() ([]byte, error)

func (TKAddress) ToUint512

func (b TKAddress) ToUint512() keys.Uint512

func (*TKAddress) UnmarshalText

func (b *TKAddress) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type TransferPkgArgs

type TransferPkgArgs struct {
	From     *address.AccountAddress `json:"from"`
	Gas      *hexutil.Uint64         `json:"gas"`
	GasPrice *hexutil.Big            `json:"gasPrice"`
	PkgId    *keys.Uint256           `json:"id"`
	To       *common.Address         `json:"To"`
}

Jump to

Keyboard shortcuts

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