ptnapi

package
v0.0.0-...-84a2c7a Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: GPL-3.0, GPL-3.0 Imports: 46 Imported by: 0

Documentation

Overview

Package ethapi implements the general PalletOne API functions.

Index

Constants

View Source
const (
	NONE   = "NONE"
	ALL    = "ALL"
	SINGLE = "SINGLE"
)
View Source
const DefaultResult = "Transaction executed locally, but may not be confirmed by the network yet!"
View Source
const (
	MaxTxInSequenceNum uint32 = 0xffffffff
)

Variables

This section is empty.

Functions

func CreateRawTransaction

func CreateRawTransaction(c *ptnjson.CreateRawTransactionCmd) (string, error)

create raw transction

func GetAPIs

func GetAPIs(apiBackend Backend) []rpc.API

func MakeAddress

func MakeAddress(ks *keystore.KeyStore, account string) (accounts.Account, error)

func RandFromString

func RandFromString(value string) (decimal.Decimal, error)

func SelectUtxoFromDagAndPool

func SelectUtxoFromDagAndPool(dbUtxo map[modules.OutPoint]*modules.Utxo, poolTxs []*txspool.TxPoolTransaction,
	from string, asset string) (map[modules.OutPoint]*modules.Utxo, error)

func WalletCreateProofTransaction

func WalletCreateProofTransaction(c *ptnjson.CreateProofTransactionCmd) (string, error)

func WalletCreateTransaction

func WalletCreateTransaction(c *ptnjson.CreateRawTransactionCmd) (string, error)

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 PalletOne API
	Downloader() *downloader.Downloader
	ProtocolVersion() int
	SuggestPrice(ctx context.Context) (*big.Int, error)
	ChainDb() ptndb.Database
	EventMux() *event.TypeMux
	AccountManager() *accounts.Manager

	// DAG API
	MemdagInfos() (*modules.MemdagInfos, error)
	SetHead(number uint64)
	HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*modules.Header, error)
	//BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Block, error)
	StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*state.StateDB, *modules.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
	//SubscribeChainEvent(ch chan<- coredata.ChainEvent) event.Subscription
	//SubscribeChainHeadEvent(ch chan<- coredata.ChainHeadEvent) event.Subscription
	//SubscribeChainSideEvent(ch chan<- coredata.ChainSideEvent) event.Subscription
	GetUnstableUnits() []*ptnjson.UnitSummaryJson
	// TxPool API
	SendTx(ctx context.Context, signedTx *modules.Transaction) error
	SendTxs(ctx context.Context, signedTxs []*modules.Transaction) []error
	GetPoolTransactions() (modules.Transactions, error)
	GetPoolTransaction(txHash common.Hash) *modules.Transaction
	GetTxByTxid_back(txid string) (*ptnjson.GetTxIdResult, error)
	GetTxPoolTxByHash(hash common.Hash) (*ptnjson.TxPoolTxJson, error)
	GetPoolTxsByAddr(addr string) ([]*txspool.TxPoolTransaction, error)

	//GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)
	Stats() (int, int, int)
	TxPoolContent() (map[common.Hash]*txspool.TxPoolTransaction, map[common.Hash]*txspool.TxPoolTransaction)
	Queued() ([]*txspool.TxPoolTransaction, error)
	SubscribeTxPreEvent(chan<- modules.TxPreEvent) event.Subscription

	//test
	SendConsensus(ctx context.Context) error

	// wallet api
	//WalletTokens(address string) (map[string]*modules.AccountToken, error)
	//WalletBalance(address string, assetid []byte, uniqueid []byte, chainid uint64) (uint64, error)
	QueryProofOfExistenceByReference(ref string) ([]*ptnjson.ProofOfExistenceJson, error)
	// dag's get common
	GetCommon(key []byte, stableDb bool) ([]byte, error)
	GetCommonByPrefix(prefix []byte, stableDb bool) map[string][]byte
	GetAllData() ([][]byte, [][]byte)
	SaveCommon(key, val []byte) error
	// Get Contract Api
	GetContract(contractAddr common.Address) (*ptnjson.ContractJson, error)

	//get level db
	GetUnitByHash(hash common.Hash) *modules.Unit
	GetUnitByNumber(number *modules.ChainIndex) *modules.Unit
	GetUnitsByIndex(start, end decimal.Decimal, asset string) []*modules.Unit
	GetHeaderByHash(hash common.Hash) (*modules.Header, error)
	GetHeaderByNumber(number *modules.ChainIndex) (*modules.Header, error)

	// get transaction interface
	GetUnitTxsInfo(hash common.Hash) ([]*ptnjson.TxSummaryJson, error)
	GetUnitTxsHashHex(hash common.Hash) ([]string, error)
	GetTxByHash(hash common.Hash) (*ptnjson.TxWithUnitInfoJson, error)
	GetTxByReqId(hash common.Hash) (*ptnjson.TxWithUnitInfoJson, error)
	GetTxSearchEntry(hash common.Hash) (*ptnjson.TxSerachEntryJson, error)

	//TODO wangjiyou
	GetPrefix(prefix string) map[string][]byte //getprefix

	GetUtxoEntry(outpoint *modules.OutPoint) (*ptnjson.UtxoJson, error)
	GetStxoEntry(outpoint *modules.OutPoint) (*ptnjson.StxoJson, error)
	QueryDbByKey(key []byte) *ptnjson.DbRowJson
	QueryDbByPrefix(prefix []byte) []*ptnjson.DbRowJson
	//GetAddrOutput(addr string) ([]modules.Output, error)
	//------- Get addr utxo start ------//
	GetAddrOutpoints(addr string) ([]modules.OutPoint, error)
	GetAddrByOutPoint(outPoint *modules.OutPoint) (common.Address, error)
	GetAddrUtxos(addr string) ([]*ptnjson.UtxoJson, error)
	GetAddrUtxos2(addr string) ([]*ptnjson.UtxoJson, error)
	GetAddrRawUtxos(addr string) (map[modules.OutPoint]*modules.Utxo, error)
	GetAllUtxos() ([]*ptnjson.UtxoJson, error)
	GetAddressBalanceStatistics(token string, topN int) (*statistics.TokenAddressBalanceJson, error)
	GetAddrTxHistory(addr string) ([]*ptnjson.TxHistoryJson, error)
	GetContractInvokeHistory(addr string) ([]*ptnjson.ContractInvokeHistoryJson, error)
	GetAddrTokenFlow(addr, token string) ([]*ptnjson.TokenFlowJson, error)
	GetAssetTxHistory(asset *modules.Asset) ([]*ptnjson.TxHistoryJson, error)
	GetAssetExistence(asset string) ([]*ptnjson.ProofOfExistenceJson, error)
	//contract control
	ContractInstall(ccName string, ccPath string, ccVersion string, ccDescription, ccAbi,
		ccLanguage string) (TemplateId []byte, err error)
	ContractDeploy(templateId []byte, txid string, args [][]byte, timeout time.Duration) (deployId []byte, err error)
	ContractInvoke(deployId []byte, txid string, args [][]byte, timeout time.Duration) (rspPayload []byte, err error)
	ContractStop(deployId []byte, txid string, deleteImage bool) error

	DecodeTx(hex string) (string, error)
	DecodeJsonTx(hex string) (string, error)
	EncodeTx(jsonStr string) (string, error)

	ContractInstallReqTx(from, to common.Address, daoAmount, daoFee uint64, tplName, path, version string,
		description, abi, language string, addrs []common.Address) (reqId common.Hash, tplId []byte, err error)
	ContractDeployReqTx(from, to common.Address, daoAmount, daoFee uint64, templateId []byte, args [][]byte,
		extData []byte, timeout time.Duration) (reqId common.Hash, contractAddr common.Address, err error)
	ContractInvokeReqTx(from, to common.Address, daoAmount, daoFee uint64, certID *big.Int,
		contractAddress common.Address, args [][]byte, timeout uint32) (reqId common.Hash, err error)
	SendContractInvokeReqTx(requestTx *modules.Transaction) (reqId common.Hash, err error)
	ContractInvokeReqTokenTx(from, to common.Address, token *modules.Asset, amountToken, fee uint64,
		contractAddress common.Address, args [][]byte, timeout uint32) (reqId common.Hash, err error)
	ContractStopReqTx(from, to common.Address, daoAmount, daoFee uint64, contractId common.Address,
		deleteImage bool) (reqId common.Hash, err error)
	ContractInstallReqTxFee(from, to common.Address, daoAmount, daoFee uint64, tplName, path, version string,
		description, abi, language string, addrs []common.Address) (fee float64, size float64, tm uint32, err error)
	ContractDeployReqTxFee(from, to common.Address, daoAmount, daoFee uint64, templateId []byte,
		args [][]byte, extData []byte, timeout time.Duration) (fee float64, size float64, tm uint32, err error)
	ContractInvokeReqTxFee(from, to common.Address, daoAmount, daoFee uint64, certID *big.Int,
		contractAddress common.Address, args [][]byte, timeout uint32) (fee float64, size float64, tm uint32, err error)
	ContractStopReqTxFee(from, to common.Address, daoAmount, daoFee uint64, contractId common.Address,
		deleteImage bool) (fee float64, size float64, tm uint32, err error)
	ContractQuery(id []byte, args [][]byte, timeout time.Duration) (rspPayload []byte, err error)

	ElectionVrf(id uint32) ([]byte, error)
	UpdateJuryAccount(addr common.Address, pwd string) bool
	GetJuryAccount() []common.Address

	TxPool() txspool.ITxPool
	Dag() dag.IDag
	SignAndSendTransaction(addr common.Address, tx *modules.Transaction) error
	SignAndSendRequest(addr common.Address, tx *modules.Transaction) error

	TransferPtn(from, to string, amount decimal.Decimal, text *string) (*TxExecuteResult, error)
	GetKeyStore() *keystore.KeyStore

	// get tx hash by req id
	GetTxHashByReqId(reqid common.Hash) (common.Hash, error)

	GetFileInfo(filehash string) ([]*modules.FileInfo, error)

	GetAllContractTpl() ([]*ptnjson.ContractTemplateJson, error)
	GetAllContracts() ([]*ptnjson.ContractJson, error)
	GetContractsByTpl(tplId []byte) ([]*ptnjson.ContractJson, error)
	GetContractTpl(tplId []byte) (*modules.ContractTemplate, error)
	//get contract key
	GetContractState(contractid []byte, key string) ([]byte, *modules.StateVersion, error)
	GetContractStatesByPrefix(id []byte, prefix string) (map[string]*modules.ContractStateValue, error)
	GetContractStateJsonByPrefix(id []byte, prefix string) ([]ptnjson.ContractStateJson, error)

	//SPV
	GetProofTxInfoByHash(txhash string) ([][]byte, error)
	ProofTransactionByHash(txhash string) (string, error)
	ProofTransactionByRlptx(rlptx [][]byte) (string, error)
	SyncUTXOByAddr(addr string) string
	StartCorsSync() (string, error)

	GetContractsWithJuryAddr(addr common.Hash) []*modules.Contract
}

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

type CallArgs

type CallArgs struct {
	From     common.Address  `json:"from"`
	To       *common.Address `json:"to"`
	Gas      hexutil.Uint64  `json:"gas"`
	GasPrice hexutil.Big     `json:"gasPrice"`
	Value    hexutil.Big     `json:"value"`
	Data     hexutil.Bytes   `json:"data"`
}

CallArgs represents the arguments for a call.

type ContractDeployRsp

type ContractDeployRsp struct {
	ReqId      string `json:"reqId"`
	ContractId string `json:"ContractId"`
}

type ContractFeeLevelRsp

type ContractFeeLevelRsp struct {
	ContractTxTimeoutUnitFee  uint64  `json:"contract_tx_timeout_unit_fee"`
	ContractTxSizeUnitFee     uint64  `json:"contract_tx_size_unit_fee"`
	ContractTxInstallFeeLevel float64 `json:"contract_tx_install_fee_level"`
	ContractTxDeployFeeLevel  float64 `json:"contract_tx_deploy_fee_level"`
	ContractTxInvokeFeeLevel  float64 `json:"contract_tx_invoke_fee_level"`
	ContractTxStopFeeLevel    float64 `json:"contract_tx_stop_fee_level"`
}

type ContractFeeRsp

type ContractFeeRsp struct {
	TxSize         float64 `json:"tx_size(byte)"`
	TimeOut        uint32  `json:"time_out(s)"`
	ApproximateFee float64 `json:"approximate_fee(dao)"`
}

type ContractInstallRsp

type ContractInstallRsp struct {
	ReqId string `json:"reqId"`
	TplId string `json:"tplId"`
}

type ContractInvokeRsp

type ContractInvokeRsp struct {
	ReqId      string `json:"reqId"`
	ContractId string `json:"ContractId"`
}

type DeserializationError

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

DeserializationError describes a failed deserializaion due to bad user input. It corresponds to btcjson.ErrRPCDeserialization.

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 GenesisData

type GenesisData struct {
	Keys   []string
	Values []string
	Count  int
}

type GetUtxoEntry

type GetUtxoEntry func(outpoint *modules.OutPoint) (*ptnjson.UtxoJson, error)

type InvalidParameterError

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

InvalidParameterError describes an invalid parameter passed by the user. It corresponds to btcjson.ErrRPCInvalidParameter.

type JuryList

type JuryList struct {
	Addr []string `json:"account"`
}

type ParseError

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

ParseError describes a failed parse due to bad user input. It corresponds to btcjson.ErrRPCParse.

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

func (s *PrivateAccountAPI) ConvertAccount(address string) (string, error)

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

func (s *PrivateAccountAPI) GetPublicKey(address string) (string, error)

func (*PrivateAccountAPI) ImportRawKey

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

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

func (*PrivateAccountAPI) ListAccounts

func (s *PrivateAccountAPI) ListAccounts() []string

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(addrStr string) bool

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

func (*PrivateAccountAPI) NewAccount

func (s *PrivateAccountAPI) NewAccount(password string) (string, error)

NewAccount will create a new account and returns the 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) TransferPtn

func (s *PrivateAccountAPI) TransferPtn(from, to string, amount decimal.Decimal, text *string,
	password string) (*TxExecuteResult, error)

appended by albert·gou

func (*PrivateAccountAPI) UnlockAccount

func (s *PrivateAccountAPI) UnlockAccount(addrStr string, 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 PrivateContractAPI

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

func NewPrivateContractAPI

func NewPrivateContractAPI(b Backend) *PrivateContractAPI

func (*PrivateContractAPI) Ccdeploy

func (s *PrivateContractAPI) Ccdeploy(ctx context.Context, templateId string, param []string) (*ContractDeployRsp, error)

func (*PrivateContractAPI) Ccdeploytx

func (s *PrivateContractAPI) Ccdeploytx(ctx context.Context, from, to string, amount, fee decimal.Decimal,
	tplId string, param []string, extData string) (*ContractDeployRsp, error)

func (*PrivateContractAPI) Ccdeploytxfee

func (s *PrivateContractAPI) Ccdeploytxfee(ctx context.Context, from, to string, amount, fee decimal.Decimal,
	tplId string, param []string, extData string) (*ContractFeeRsp, error)

func (*PrivateContractAPI) Ccinstall

func (s *PrivateContractAPI) Ccinstall(ctx context.Context,
	ccname, ccpath, ccversion, ccdescription, ccabi, cclanguage string) (hexutil.Bytes, error)

contract command install

func (*PrivateContractAPI) Ccinstalltx

func (s *PrivateContractAPI) Ccinstalltx(ctx context.Context, from, to string, amount, fee decimal.Decimal,
	tplName, path, version, ccdescription, ccabi, cclanguage string, addr []string) (*ContractInstallRsp, error)

contract tx

func (*PrivateContractAPI) Ccinstalltxfee

func (s *PrivateContractAPI) Ccinstalltxfee(ctx context.Context, from, to string, amount, fee decimal.Decimal,
	tplName, path, version, ccdescription, ccabi, cclanguage string, addr []string) (*ContractFeeRsp, error)

func (*PrivateContractAPI) Ccinvoke

func (s *PrivateContractAPI) Ccinvoke(ctx context.Context, contractAddr string, param []string) (string, error)

func (*PrivateContractAPI) CcinvokeToken

func (s *PrivateContractAPI) CcinvokeToken(ctx context.Context, from, to, token string, amountToken, fee decimal.Decimal,
	contractAddress string, param []string) (*ContractInvokeRsp, error)

func (*PrivateContractAPI) Ccinvoketx

func (s *PrivateContractAPI) Ccinvoketx(ctx context.Context, from, to string, amount, fee decimal.Decimal,
	deployId string, param []string, certID string, timeout string) (*ContractDeployRsp, error)

func (*PrivateContractAPI) CcinvoketxPass

func (s *PrivateContractAPI) CcinvoketxPass(ctx context.Context, from, to string, amount, fee decimal.Decimal,
	deployId string, param []string, password string, duration *uint64, certID string) (string, error)

func (*PrivateContractAPI) Ccinvoketxfee

func (s *PrivateContractAPI) Ccinvoketxfee(ctx context.Context, from, to string, amount, fee decimal.Decimal,
	deployId string, param []string, certID string, timeout string) (*ContractFeeRsp, error)

func (*PrivateContractAPI) Ccstop

func (s *PrivateContractAPI) Ccstop(ctx context.Context, contractAddr string) error

func (*PrivateContractAPI) Ccstoptx

func (s *PrivateContractAPI) Ccstoptx(ctx context.Context, from, to string, amount, fee decimal.Decimal, contractId string) (string, error)

func (*PrivateContractAPI) Ccstoptxfee

func (s *PrivateContractAPI) Ccstoptxfee(ctx context.Context, from, to string, amount, fee decimal.Decimal,
	contractId string) (*ContractFeeRsp, error)

func (*PrivateContractAPI) DepositContractInvoke

func (s *PrivateContractAPI) DepositContractInvoke(ctx context.Context, from, to string, amount, fee decimal.Decimal,
	param []string) (string, error)

func (*PrivateContractAPI) SysConfigContractInvoke

func (s *PrivateContractAPI) SysConfigContractInvoke(ctx context.Context, from, to string, amount, fee decimal.Decimal,
	param []string) (string, error)

type PrivateDagAPI

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

所有可能大数据量的查询只能在本地查询

func NewPrivateDagAPI

func NewPrivateDagAPI(b Backend) *PrivateDagAPI

func (*PrivateDagAPI) CheckHeader

func (s *PrivateDagAPI) CheckHeader(ctx context.Context, number int) (bool, error)

func (*PrivateDagAPI) CheckUnits

func (s *PrivateDagAPI) CheckUnits(ctx context.Context, assetId string, number int) (bool, error)

func (*PrivateDagAPI) GetAllUtxos

func (s *PrivateDagAPI) GetAllUtxos(ctx context.Context) (string, error)

func (*PrivateDagAPI) GetCommonByPrefix

func (s *PrivateDagAPI) GetCommonByPrefix(ctx context.Context, prefix string) (string, error)

func (*PrivateDagAPI) GetHeaderByAuthor

func (s *PrivateDagAPI) GetHeaderByAuthor(ctx context.Context, author string, startHeight, count uint64) (string, error)

func (*PrivateDagAPI) RebuildAddrTxIndex

func (s *PrivateDagAPI) RebuildAddrTxIndex() error

type PrivateDebugAPI

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

PrivateDebugAPI is the collection of PalletOne 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 PalletOne 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) GetAllTokenBalance

func (api *PrivateDebugAPI) GetAllTokenBalance() map[string]uint64

func (*PrivateDebugAPI) QueryDbByKey

func (api *PrivateDebugAPI) QueryDbByKey(keyString string, keyHex string) *ptnjson.DbRowJson

func (*PrivateDebugAPI) QueryDbByPrefix

func (api *PrivateDebugAPI) QueryDbByPrefix(keyString string, keyHex string) []*ptnjson.DbRowJson

func (*PrivateDebugAPI) SaveCommon

func (api *PrivateDebugAPI) SaveCommon(keyHex string, valueHex string) error

func (*PrivateDebugAPI) SetHead

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

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

type PrivateMediatorAPI

type PrivateMediatorAPI struct {
	Backend
}

func NewPrivateMediatorAPI

func NewPrivateMediatorAPI(b Backend) *PrivateMediatorAPI

func (*PrivateMediatorAPI) Apply

func (*PrivateMediatorAPI) PayDeposit

func (a *PrivateMediatorAPI) PayDeposit(from string, amount decimal.Decimal, fee decimal.Decimal) (*TxExecuteResult, error)

func (*PrivateMediatorAPI) Quit

func (a *PrivateMediatorAPI) Quit(medAddStr string, fee decimal.Decimal) (*TxExecuteResult, error)

func (*PrivateMediatorAPI) Update

func (*PrivateMediatorAPI) Vote

func (a *PrivateMediatorAPI) Vote(voterStr string, mediatorStrs []string) (*TxExecuteResult, error)

type PrivateWalletAPI

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

func NewPrivateWalletAPI

func NewPrivateWalletAPI(b Backend) *PrivateWalletAPI

func (*PrivateWalletAPI) AggregateUtxo

func (s *PrivateWalletAPI) AggregateUtxo(ctx context.Context,
	address string, fee decimal.Decimal) ([]common.Hash, error)

将UTXO碎片聚集成整的UTXO

func (*PrivateWalletAPI) CreateProofOfExistenceTx

func (s *PrivateWalletAPI) CreateProofOfExistenceTx(ctx context.Context, addr string,
	mainData, extraData, reference string, password string) (common.Hash, error)

func (*PrivateWalletAPI) CreateTraceability

func (s *PrivateWalletAPI) CreateTraceability(ctx context.Context, addr, uid, symbol, mainData, extraData, reference string) (common.Hash, error)

创建一笔溯源交易,调用721合约

func (*PrivateWalletAPI) Forking

func (s *PrivateWalletAPI) Forking(ctx context.Context, rate uint64) uint64

func (*PrivateWalletAPI) MultiSignRawTransaction

func (s *PrivateWalletAPI) MultiSignRawTransaction(ctx context.Context, params, redeemScript string, addr common.Address, hashtype string, password string, duration *uint64) (ptnjson.SignRawTransactionResult, error)

func (*PrivateWalletAPI) SignRawTransaction

func (s *PrivateWalletAPI) SignRawTransaction(ctx context.Context, params string, hashtype string, password string, duration *uint64) (ptnjson.SignRawTransactionResult, error)

func (*PrivateWalletAPI) TransferPtn

func (s *PrivateWalletAPI) TransferPtn(ctx context.Context, from string, to string,
	amount decimal.Decimal, fee decimal.Decimal, Extra string, password string, duration *uint64) (common.Hash, error)

func (*PrivateWalletAPI) TransferToken

func (s *PrivateWalletAPI) TransferToken(ctx context.Context, asset string, from string, to string,
	amount decimal.Decimal, fee decimal.Decimal, Extra string, password string, duration *uint64) (common.Hash, error)

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() []common.Address

Accounts returns the collection of accounts this node manages

type PublicBlockChainAPI

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

PublicBlockChainAPI provides an API to access the PalletOne 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 PalletOne blockchain API.

func (*PublicBlockChainAPI) AddressBalanceStatistics

func (s *PublicBlockChainAPI) AddressBalanceStatistics(ctx context.Context, token string,
	topN int) (*statistics.TokenAddressBalanceJson, error)

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

func (s *PublicBlockChainAPI) DecodeJsonTx(ctx context.Context, hex string) (string, error)

func (*PublicBlockChainAPI) DecodeTx

func (s *PublicBlockChainAPI) DecodeTx(ctx context.Context, hex string) (string, error)

func (*PublicBlockChainAPI) Election

func (s *PublicBlockChainAPI) Election(ctx context.Context, sid string) (string, error)

func (*PublicBlockChainAPI) EncodeTx

func (s *PublicBlockChainAPI) EncodeTx(ctx context.Context, json string) (string, 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) Forking

func (s *PublicBlockChainAPI) Forking(ctx context.Context, rate uint64) uint64

Start forking command.

func (*PublicBlockChainAPI) GetAddressWithPublicKey

func (s *PublicBlockChainAPI) GetAddressWithPublicKey(pubkey string) (addStr string, err error)

func (*PublicBlockChainAPI) GetAssetExistence

func (s *PublicBlockChainAPI) GetAssetExistence(ctx context.Context,
	asset string) ([]*ptnjson.ProofOfExistenceJson, error)

func (*PublicBlockChainAPI) GetBalance

func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address string) (map[string]decimal.Decimal, 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) GetChainParameters

func (s *PublicBlockChainAPI) GetChainParameters() (*core.ChainParameters, error)

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

func (s *PublicBlockChainAPI) GetDynamicGlobalProperty() (*ptnjson.DynamicGlobalPropertyJson, error)

func (*PublicBlockChainAPI) GetGlobalProperty

func (s *PublicBlockChainAPI) GetGlobalProperty() (*modules.GlobalProperty, error)

func (*PublicBlockChainAPI) GetImmutableParameters

func (s *PublicBlockChainAPI) GetImmutableParameters() (*core.ImmutableChainParameters, error)

func (*PublicBlockChainAPI) GetJuryAccount

func (s *PublicBlockChainAPI) GetJuryAccount(ctx context.Context) *JuryList

func (*PublicBlockChainAPI) GetPledge

func (s *PublicBlockChainAPI) GetPledge(addStr string) (*modules.PledgeStatusJson, error)

func (*PublicBlockChainAPI) GetPrefix

func (s *PublicBlockChainAPI) GetPrefix(condition string) string

Query leveldb

func (*PublicBlockChainAPI) GetProofTxInfoByHash

func (s *PublicBlockChainAPI) GetProofTxInfoByHash(ctx context.Context, txhash string) ([][]byte, error)

SPV

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

func (s *PublicBlockChainAPI) GetTokenTxHistory(ctx context.Context,
	assetStr string) ([]*ptnjson.TxHistoryJson, error)

func (*PublicBlockChainAPI) ListSysConfig

func (s *PublicBlockChainAPI) ListSysConfig() ([]*ptnjson.ConfigJson, error)

func (*PublicBlockChainAPI) ProofTransactionByHash

func (s *PublicBlockChainAPI) ProofTransactionByHash(ctx context.Context, txhash string) (string, error)

func (*PublicBlockChainAPI) ProofTransactionByRlptx

func (s *PublicBlockChainAPI) ProofTransactionByRlptx(ctx context.Context, rlptx [][]byte) (string, error)

func (*PublicBlockChainAPI) SetJuryAccount

func (s *PublicBlockChainAPI) SetJuryAccount(ctx context.Context, addr, pwd string) string

func (*PublicBlockChainAPI) StartCorsSync

func (s *PublicBlockChainAPI) StartCorsSync(ctx context.Context) (string, error)

func (*PublicBlockChainAPI) SyncUTXOByAddr

func (s *PublicBlockChainAPI) SyncUTXOByAddr(ctx context.Context, addr string) string

type PublicContractAPI

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

func NewPublicContractAPI

func NewPublicContractAPI(b Backend) *PublicContractAPI

func (*PublicContractAPI) Ccquery

func (s *PublicContractAPI) Ccquery(ctx context.Context, id string, param []string, timeout uint32) (string, error)

func (*PublicContractAPI) DepositContractQuery

func (s *PublicContractAPI) DepositContractQuery(ctx context.Context, param []string) (string, error)

func (*PublicContractAPI) GetAllContractsUsedTemplateId

func (s *PublicContractAPI) GetAllContractsUsedTemplateId(ctx context.Context, tplId string) ([]*ptnjson.ContractJson, error)

查看某个模板id对应着多个合约实例的合约信息

func (*PublicContractAPI) GetContractFeeLevel

func (s *PublicContractAPI) GetContractFeeLevel(ctx context.Context) (*ContractFeeLevelRsp, error)

func (*PublicContractAPI) GetContractInfoByAddr

func (s *PublicContractAPI) GetContractInfoByAddr(ctx context.Context, contractAddr string) (*ptnjson.ContractJson, error)

通过合约地址,获取合约的详细信息

func (*PublicContractAPI) GetContractInfoById

func (s *PublicContractAPI) GetContractInfoById(ctx context.Context, contractId string) (*ptnjson.ContractJson, error)

通过合约Id,获取合约的详细信息

func (*PublicContractAPI) GetContractState

func (s *PublicContractAPI) GetContractState(ctx context.Context,
	contractAddr, prefix string) (string, error)

func (*PublicContractAPI) GetContractTemplateInfoById

func (s *PublicContractAPI) GetContractTemplateInfoById(ctx context.Context, contractTplId string) (*modules.ContractTemplate, error)

通过合约模板id获取模板信息

func (*PublicContractAPI) GetContractsWithJuryAddress

func (s *PublicContractAPI) GetContractsWithJuryAddress(ctx context.Context, addr string) ([]*ptnjson.ContractJson, error)

获取所担任的用户合约相关信息

func (*PublicContractAPI) ListAllContractTemplates

func (s *PublicContractAPI) ListAllContractTemplates(ctx context.Context) ([]*ptnjson.ContractTemplateJson, error)

TODO

func (*PublicContractAPI) ListAllContracts

func (s *PublicContractAPI) ListAllContracts(ctx context.Context) ([]*ptnjson.ContractJson, error)

TODO

func (*PublicContractAPI) SysConfigContractQuery

func (s *PublicContractAPI) SysConfigContractQuery(ctx context.Context, param []string) (string, error)

type PublicDagAPI

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

func NewPublicDagAPI

func NewPublicDagAPI(b Backend) *PublicDagAPI

func (*PublicDagAPI) GetAddrOutpoints

func (s *PublicDagAPI) GetAddrOutpoints(ctx context.Context, addr string) (string, error)

func (*PublicDagAPI) GetAddrUtxos

func (s *PublicDagAPI) GetAddrUtxos(ctx context.Context, addr string) (string, error)

func (*PublicDagAPI) GetCommon

func (s *PublicDagAPI) GetCommon(ctx context.Context, key string) ([]byte, error)

func (*PublicDagAPI) GetFastUnitIndex

func (s *PublicDagAPI) GetFastUnitIndex(ctx context.Context, assetid string) string

func (*PublicDagAPI) GetGenesisData

func (s *PublicDagAPI) GetGenesisData(ctx context.Context) (*GenesisData, error)

func (*PublicDagAPI) GetHeadUnit

func (s *PublicDagAPI) GetHeadUnit() (*ptnjson.UnitPropertyJson, error)

func (*PublicDagAPI) GetHeaderByHash

func (s *PublicDagAPI) GetHeaderByHash(ctx context.Context, condition string) (string, error)

func (*PublicDagAPI) GetHeaderByNumber

func (s *PublicDagAPI) GetHeaderByNumber(ctx context.Context, condition string) (string, error)

func (*PublicDagAPI) GetHexCommon

func (s *PublicDagAPI) GetHexCommon(ctx context.Context, key string) (string, error)

func (*PublicDagAPI) GetLdbCommon

func (s *PublicDagAPI) GetLdbCommon(ctx context.Context, key string) ([]byte, error)

func (*PublicDagAPI) GetMediatorSchedule

func (s *PublicDagAPI) GetMediatorSchedule() (*modules.MediatorSchedule, error)

func (*PublicDagAPI) GetStableUnit

func (s *PublicDagAPI) GetStableUnit() (*ptnjson.UnitPropertyJson, error)

func (*PublicDagAPI) GetTransactionsByTxid

func (s *PublicDagAPI) GetTransactionsByTxid(ctx context.Context, txid string) (*ptnjson.GetTxIdResult, error)

func (*PublicDagAPI) GetTxByHash

func (s *PublicDagAPI) GetTxByHash(ctx context.Context, hashHex string) (string, error)

func (*PublicDagAPI) GetTxByReqId

func (s *PublicDagAPI) GetTxByReqId(ctx context.Context, hashHex string) (string, error)

func (*PublicDagAPI) GetTxHashByReqId

func (s *PublicDagAPI) GetTxHashByReqId(ctx context.Context, hashHex string) (string, error)

func (*PublicDagAPI) GetTxPoolTxByHash

func (s *PublicDagAPI) GetTxPoolTxByHash(ctx context.Context, hex string) (string, error)

GetTxPoolTxByHash returns the pool transaction for the given hash

func (*PublicDagAPI) GetTxSearchEntry

func (s *PublicDagAPI) GetTxSearchEntry(ctx context.Context, hashHex string) (string, error)

func (*PublicDagAPI) GetTxStatusByHash

func (s *PublicDagAPI) GetTxStatusByHash(ctx context.Context, hex string) (*ptnjson.TxPoolTxJson, error)

GetTxStatusByHash returns the transaction status for hash

func (*PublicDagAPI) GetUnitByHash

func (s *PublicDagAPI) GetUnitByHash(ctx context.Context, condition string) string

func (*PublicDagAPI) GetUnitByNumber

func (s *PublicDagAPI) GetUnitByNumber(ctx context.Context, condition string) string

func (*PublicDagAPI) GetUnitJsonByIndex

func (s *PublicDagAPI) GetUnitJsonByIndex(ctx context.Context, asset_id string, index uint64) string

func (*PublicDagAPI) GetUnitSummaryByNumber

func (s *PublicDagAPI) GetUnitSummaryByNumber(ctx context.Context, condition string) string

func (*PublicDagAPI) GetUnitTxsHashHex

func (s *PublicDagAPI) GetUnitTxsHashHex(ctx context.Context, hashHex string) (string, error)

func (*PublicDagAPI) GetUnitTxsInfo

func (s *PublicDagAPI) GetUnitTxsInfo(ctx context.Context, hashHex string) (string, error)

func (*PublicDagAPI) GetUnitsByIndex

func (s *PublicDagAPI) GetUnitsByIndex(ctx context.Context, start, end decimal.Decimal, asset string) string

getUnitsByIndex

func (*PublicDagAPI) GetUnstableUnits

func (s *PublicDagAPI) GetUnstableUnits() []*ptnjson.UnitSummaryJson

func (*PublicDagAPI) HeadUnitHash

func (s *PublicDagAPI) HeadUnitHash() string

func (*PublicDagAPI) HeadUnitNum

func (s *PublicDagAPI) HeadUnitNum() uint64

func (*PublicDagAPI) HeadUnitTime

func (s *PublicDagAPI) HeadUnitTime() string

func (*PublicDagAPI) IsSynced

func (s *PublicDagAPI) IsSynced() bool

func (*PublicDagAPI) MemdagInfos

func (s *PublicDagAPI) MemdagInfos(ctx context.Context) (string, error)

MemdagInfos returns the pool transaction for the given hash

type PublicDebugAPI

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

// 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 (s *PublicTransactionPoolAPI) PendingTransactions() ([]*RPCTransaction, error) {
	pending, err := s.b.GetPoolTransactions()

		return nil, err
	}

	transactions := make([]*RPCTransaction, 0, len(pending))
	for _, tx := range pending {
		var signer types.Signer = types.HomesteadSigner{}
		if tx.Protected() {
			//signer = types.NewEIP155Signer(tx.ChainId())
		}
		from, _ := types.Sender(signer, tx)
		if _, err := s.b.AccountManager().Find(accounts.Account{Address: from}); err == nil {
			transactions = append(transactions, newRPCPendingTransaction(tx))
		}
	}
	return transactions, nil
}

// Resend accepts an existing transaction and a new gas price and limit. It will remove // the given transaction from the pool and reinsert it with the new gas price and limit.

func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, sendArgs SendTxArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error) {
	if sendArgs.Nonce == nil {
		return common.Hash{}, fmt.Errorf("missing transaction nonce in transaction spec")
	}
	if err := sendArgs.setDefaults(ctx, s.b); err != nil {
		return common.Hash{}, err
	}
	matchTx := sendArgs.toTransaction()
	pending, err := s.b.GetPoolTransactions()
	if err != nil {
		return common.Hash{}, err
	}

	for _, p := range pending {
		var signer types.Signer = types.HomesteadSigner{}
		if p.Protected() {
			//signer = types.NewEIP155Signer(p.ChainId())
		}
		wantSigHash := signer.Hash(matchTx)

		if pFrom, err := types.Sender(signer, p); err == nil && pFrom == sendArgs.From && signer.Hash(p) == wantSigHash {
			// Match. Re-sign and send the transaction.
			if gasPrice != nil && (*big.Int)(gasPrice).Sign() != 0 {
				sendArgs.GasPrice = gasPrice
			}
			if gasLimit != nil && *gasLimit != 0 {
				sendArgs.Gas = gasLimit
			}
			signedTx, err := s.sign(sendArgs.From, sendArgs.toTransaction())
			if err != nil {
				return common.Hash{}, err
			}
			if err = s.b.SendTx(ctx, signedTx); err != nil {
				return common.Hash{}, err
			}
			return signedTx.Hash(), nil
		}
	}

	return common.Hash{}, fmt.Errorf("Transaction %#x not found", matchTx.Hash())
}

PublicDebugAPI is the collection of PalletOne 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 PalletOne service.

func (*PublicDebugAPI) GetProtocolVersion

func (api *PublicDebugAPI) GetProtocolVersion() int

type PublicMediatorAPI

type PublicMediatorAPI struct {
	Backend
}

func NewPublicMediatorAPI

func NewPublicMediatorAPI(b Backend) *PublicMediatorAPI

func (*PublicMediatorAPI) GetDeposit

func (a *PublicMediatorAPI) GetDeposit(addStr string) (*modules.MediatorDepositJson, error)

func (*PublicMediatorAPI) GetInfo

func (a *PublicMediatorAPI) GetInfo(addStr string) (*modules.MediatorInfo, error)

func (*PublicMediatorAPI) GetNextUpdateTime

func (a *PublicMediatorAPI) GetNextUpdateTime() string

func (*PublicMediatorAPI) GetVoted

func (a *PublicMediatorAPI) GetVoted(addStr string) ([]string, error)

func (*PublicMediatorAPI) IsActive

func (a *PublicMediatorAPI) IsActive(addStr string) (bool, error)

func (*PublicMediatorAPI) IsApproved

func (a *PublicMediatorAPI) IsApproved(addStr string) (string, error)

func (*PublicMediatorAPI) IsInList

func (a *PublicMediatorAPI) IsInList(addStr string) (bool, error)

func (*PublicMediatorAPI) ListActives

func (a *PublicMediatorAPI) ListActives() []common.Address

func (*PublicMediatorAPI) ListAll

func (a *PublicMediatorAPI) ListAll() []string

func (*PublicMediatorAPI) ListVoteResults

func (a *PublicMediatorAPI) ListVoteResults() map[string]uint64

func (*PublicMediatorAPI) ListVotingFor

func (a *PublicMediatorAPI) ListVotingFor(addStr string) (map[string]uint64, error)

func (*PublicMediatorAPI) LookupMediatorInfo

func (a *PublicMediatorAPI) LookupMediatorInfo() []*modules.MediatorInfo

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 PublicPalletOneAPI

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

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

func NewPublicPalletOneAPI

func NewPublicPalletOneAPI(b Backend) *PublicPalletOneAPI

NewPublicPalletOneAPI creates a new PalletOne protocol API.

func (*PublicPalletOneAPI) GasPrice

func (s *PublicPalletOneAPI) GasPrice(ctx context.Context) (*big.Int, error)

GasPrice returns a suggestion for a gas price.

func (*PublicPalletOneAPI) ProtocolVersion

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

ProtocolVersion returns the current PalletOne protocol version this node supports

func (*PublicPalletOneAPI) Syncing

func (s *PublicPalletOneAPI) 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 synchronize 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 PublicReturnInfo

type PublicReturnInfo struct {
	Item string      `json:"item"`
	Info interface{} `json:"info"`
	Hex  string      `json:"hex"`
}

func NewPublicReturnInfo

func NewPublicReturnInfo(name string, info interface{}) *PublicReturnInfo

func NewPublicReturnInfoWithHex

func NewPublicReturnInfoWithHex(name string, info interface{}, rlpData []byte) *PublicReturnInfo

type PublicTransactionPoolAPI

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

// newRPCTransactionFromBlockIndex returns a transaction that will serialize to the RPC representation.

func newRPCTransactionFromBlockIndex(b *types.Block, index uint64) *RPCTransaction {
	txs := b.Transactions()
	if index >= uint64(len(txs)) {
		return nil
	}
	return newRPCTransaction(txs[index], b.Hash(), b.NumberU64(), index)
}

// newRPCRawTransactionFromBlockIndex returns the bytes of a transaction given a block and a transaction index.

func newRPCRawTransactionFromBlockIndex(b *types.Block, index uint64) hexutil.Bytes {
	txs := b.Transactions()
	if index >= uint64(len(txs)) {
		return nil
	}
	blob, _ := rlp.EncodeToBytes(txs[index])
	return blob
}

// newRPCTransactionFromBlockHash returns a transaction that will serialize to the RPC representation.

func newRPCTransactionFromBlockHash(b *types.Block, hash common.Hash) *RPCTransaction {
	for idx, tx := range b.Transactions() {
		if tx.Hash() == hash {
			return newRPCTransactionFromBlockIndex(b, uint64(idx))
		}
	}
	return nil
}

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

func (s *PublicTransactionPoolAPI) BatchSign(ctx context.Context, txid string, fromAddress, toAddress string, amount int, count int, password string) ([]string, error)

转为压力测试准备数据用

func (*PublicTransactionPoolAPI) GetAddrOutpoints

func (s *PublicTransactionPoolAPI) GetAddrOutpoints(ctx context.Context, addr string) (string, error)

func (*PublicTransactionPoolAPI) GetAddrUtxos

func (s *PublicTransactionPoolAPI) GetAddrUtxos(ctx context.Context, addr string) (string, error)

func (*PublicTransactionPoolAPI) GetAllUtxos

func (s *PublicTransactionPoolAPI) GetAllUtxos(ctx context.Context) (string, error)

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

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

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

func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint {
	if block, _ := s.b.GetBlock(ctx, blockHash); block != nil {
		n := hexutil.Uint(len(block.Transactions()))
		return &n
	}
	return nil
}

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

func (s *PublicTransactionPoolAPI) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) *RPCTransaction {
	if block, _ := s.b.BlockByNumber(ctx, blockNr); block != nil {
		return newRPCTransactionFromBlockIndex(block, uint64(index))
	}
	return nil
}

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

func (s *PublicTransactionPoolAPI) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) *RPCTransaction {
	if block, _ := s.b.GetBlock(ctx, blockHash); block != nil {
		return newRPCTransactionFromBlockIndex(block, uint64(index))
	}
	return nil
}

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

func (s *PublicTransactionPoolAPI) GetRawTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) hexutil.Bytes {
	if block, _ := s.b.BlockByNumber(ctx, blockNr); block != nil {
		return newRPCRawTransactionFromBlockIndex(block, uint64(index))
	}
	return nil
}

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

func (s *PublicTransactionPoolAPI) GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) hexutil.Bytes {
	if block, _ := s.b.GetBlock(ctx, blockHash); block != nil {
		return newRPCRawTransactionFromBlockIndex(block, uint64(index))
	}
	return nil
}

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

func (*PublicTransactionPoolAPI) GetTransactionsByTxid

func (s *PublicTransactionPoolAPI) GetTransactionsByTxid(ctx context.Context, txid string) (*ptnjson.GetTxIdResult, error)

func (*PublicTransactionPoolAPI) GetTxHashByReqId

func (s *PublicTransactionPoolAPI) GetTxHashByReqId(ctx context.Context, hashHex string) (string, error)

func (*PublicTransactionPoolAPI) GetTxPoolTxByHash

func (s *PublicTransactionPoolAPI) GetTxPoolTxByHash(ctx context.Context, hex string) (*ptnjson.TxPoolTxJson, error)

GetTxPoolTxByHash returns the pool transaction for the given hash

func (*PublicTransactionPoolAPI) Sign

Sign calculates an ECDSA signature for: keccack256("\x19Ethereum Signed Message:\n" + len(message) + message).

Note, the produced signature conforms to the secp256k1 curve R, S and V values, where the V value will be 27 or 28 for legacy reasons.

The account associated with addr must be unlocked.

https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign

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

Content returns the transactions contained within the transaction pool.

func (*PublicTxPoolAPI) Pending

func (s *PublicTxPoolAPI) Pending() ([]*ptnjson.TxPoolPendingJson, error)

未确认的交易列表

func (*PublicTxPoolAPI) Queue

func (s *PublicTxPoolAPI) Queue() map[common.Hash]*modules.Transaction

func (*PublicTxPoolAPI) Status

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

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

type PublicWalletAPI

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

func NewPublicWalletAPI

func NewPublicWalletAPI(b Backend) *PublicWalletAPI

func (*PublicWalletAPI) AddBatchTxs

func (s *PublicWalletAPI) AddBatchTxs(ctx context.Context, path string) (int, error)

压测交易池,批量添加交易

func (*PublicWalletAPI) CreateProofTransaction

func (s *PublicWalletAPI) CreateProofTransaction(ctx context.Context, params string, password string) (common.Hash, error)

func (*PublicWalletAPI) CreateRawTransaction

func (s *PublicWalletAPI) CreateRawTransaction(ctx context.Context, from string, to string, amount, fee decimal.Decimal) (string, error)

func (*PublicWalletAPI) Forking

func (s *PublicWalletAPI) Forking(ctx context.Context, rate uint64) uint64

Start forking command.

func (*PublicWalletAPI) GetAddrTokenFlow

func (s *PublicWalletAPI) GetAddrTokenFlow(ctx context.Context, addr string, token string) ([]*ptnjson.TokenFlowJson, error)

获得某地址的通证流水

func (*PublicWalletAPI) GetAddrTxHistory

func (s *PublicWalletAPI) GetAddrTxHistory(ctx context.Context, addr string) ([]*ptnjson.TxHistoryJson, error)

func (*PublicWalletAPI) GetAddrUtxos

func (s *PublicWalletAPI) GetAddrUtxos(ctx context.Context, addr string) (string, error)

func (*PublicWalletAPI) GetAddrUtxos2

func (s *PublicWalletAPI) GetAddrUtxos2(ctx context.Context, addr string) (string, error)

func (*PublicWalletAPI) GetAllTokenInfo

func (s *PublicWalletAPI) GetAllTokenInfo(ctx context.Context) (string, error)

func (*PublicWalletAPI) GetBalance

func (s *PublicWalletAPI) GetBalance(ctx context.Context, address string) (map[string]decimal.Decimal, error)

func (*PublicWalletAPI) GetBalance2

func (s *PublicWalletAPI) GetBalance2(ctx context.Context, address string) (*walletjson.StableUnstable, error)

func (*PublicWalletAPI) GetContractInvokeHistory

func (s *PublicWalletAPI) GetContractInvokeHistory(ctx context.Context, contractAddr string) ([]*ptnjson.ContractInvokeHistoryJson, error)

func (*PublicWalletAPI) GetFileInfoByFileHash

func (s *PublicWalletAPI) GetFileInfoByFileHash(ctx context.Context, filehash string) ([]*ptnjson.ProofOfExistenceJson, error)

func (*PublicWalletAPI) GetFileInfoByTxid

func (s *PublicWalletAPI) GetFileInfoByTxid(ctx context.Context, txid common.Hash) (*ptnjson.ProofOfExistenceJson, error)

根据交易哈希 查询存证结果

func (*PublicWalletAPI) GetOneTokenInfo

func (s *PublicWalletAPI) GetOneTokenInfo(ctx context.Context, symbol string) (string, error)

func (*PublicWalletAPI) GetProofOfExistencesByAsset

func (s *PublicWalletAPI) GetProofOfExistencesByAsset(ctx context.Context, asset string) ([]*ptnjson.ProofOfExistenceJson, error)

func (*PublicWalletAPI) GetProofOfExistencesByRef

func (s *PublicWalletAPI) GetProofOfExistencesByRef(ctx context.Context, reference string) ([]*ptnjson.ProofOfExistenceJson, error)

func (*PublicWalletAPI) GetPtnTestCoin

func (s *PublicWalletAPI) GetPtnTestCoin(ctx context.Context, from string, to string, amount, password string, duration *uint64) (common.Hash, error)

sign rawtranscation create raw transction

func (*PublicWalletAPI) GetStxo

func (s *PublicWalletAPI) GetStxo(ctx context.Context, txid string, msgIdx int, outIdx int) (*ptnjson.StxoJson, error)

好像某个UTXO是被那个交易花费的

func (*PublicWalletAPI) SendJsonTransaction

func (s *PublicWalletAPI) SendJsonTransaction(ctx context.Context, params string) (common.Hash, error)

func (*PublicWalletAPI) SendRawTransaction

func (s *PublicWalletAPI) SendRawTransaction(ctx context.Context, signedTxHex string) (common.Hash, error)

walletSendTransaction will add the signed transaction to the transaction pool. The sender is responsible for signing the transaction and using the correct nonce.

func (*PublicWalletAPI) SendRlpTransaction

func (s *PublicWalletAPI) SendRlpTransaction(ctx context.Context, encodedTx string) (common.Hash, error)

type RPCTransaction

type RPCTransaction struct {
	//UnitHash common.Hash `json:"unit_Hash"`
	//From      common.Address `json:"from"`
	UnitIndex uint64      `json:"unit_index"`
	Hash      common.Hash `json:"hash"`

	TransactionIndex hexutil.Uint `json:"transaction_index"`
}

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

type SignTransactionParams

type SignTransactionParams struct {
	RawTx  string `json:"rawtx"`
	Inputs []struct {
		Txid         string `json:"txid"`
		Vout         uint32 `json:"vout"`
		MessageIndex uint32 `json:"messageindex"`
		ScriptPubKey string `json:"scriptPubKey"`
		RedeemScript string `json:"redeemScript"`
	} `json:"rawtxinput"`
	PrivKeys []string `json:"privkeys"`
	Flags    string   `jsonrpcdefault:"\"ALL\""`
}

type SignTransactionResult

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

SignTransactionResult represents a RLP encoded signed transaction.

type SignatureError

type SignatureError struct {
	InputIndex uint32
	Error      error
}
type response struct {
	result []byte

err error } type FutureGetTxOutResult chan *response

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

type TxExecuteResult

type TxExecuteResult struct {
	TxContent string      `json:"txContent"` // 交易内容
	TxHash    common.Hash `json:"txHash"`    // 交易hash
	TxSize    string      `json:"txSize"`    // 交易大小
	TxFee     string      `json:"txFee"`     // 交易费用
	Tip       string      `json:"tip"`       // 提示
	Warning   string      `json:"warning"`   // 警告
}

交易执行结果

Jump to

Keyboard shortcuts

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