ptnapi

package
v1.0.9 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: 50 Imported by: 0

Documentation

Overview

Package ethapi implements the general PalletOne API functions.

*
*    This file is part of go-palletone.
*    go-palletone is free software: you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation, either version 3 of the License, or
*    (at your option) any later version.
*    go-palletone is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*    You should have received a copy of the GNU General Public License
*    along with go-palletone.  If not, see <http://www.gnu.org/licenses/>.
* /
*
*  * @author PalletOne core developer <dev@pallet.one>
*  * @date 2018-2019
*

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 GO = "go"
View Source
const GOLANG = "golang"
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, reqTxMapping map[common.Hash]common.Hash,
	poolTxs []*txspool.TxPoolTransaction,
	from string, asset string) (map[modules.OutPoint]*modules.Utxo, error)

传入数据库获取的UTXO和从交易池获取的Tx,当前发送用户和Asset,过滤、合并处理UTXO,返回该用户能使用的UTXO

func SignRawTransactionOld added in v1.0.6

sign rawtranscation

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 {
	sync.Locker
	// 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(tx *modules.Transaction) error
	SendTxs(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)
	GetUnpackedTxsByAddr(addr string) ([]*txspool.TxPoolTransaction, error)
	GetPoolAddrUtxos(addr common.Address, token *modules.Asset) (map[modules.OutPoint]*modules.Utxo, error)
	//GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)
	Status() (int, int, int)
	TxPoolClear()
	TxPoolContent() (map[common.Hash]*txspool.TxPoolTransaction, map[common.Hash]*txspool.TxPoolTransaction)
	TxPoolOrphan() ([]*txspool.TxPoolTransaction, error)
	TxPoolPacked() (map[common.Hash][]*txspool.TxPoolTransaction, error)
	TxPoolUnpack() ([]*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)
	GetTxPackInfo(txHash common.Hash) (*ptnjson.TxPackInfoJson, 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)
	GetDagAddrUtxos(addr string) ([]*ptnjson.UtxoJson, error)
	GetAddrUtxoTxs(addr string) ([]*ptnjson.TxWithUnitInfoJson, 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)
	GetAddressCount() int
	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
	ContractEventBroadcast(event jury.ContractEvent, local bool)
	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)
	SendContractInvokeReqTx(requestTx *modules.Transaction) (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(maindata string) ([]*modules.ProofOfExistencesInfo, error)
	GetProofOfExistencesByMaindata(maindata string) ([]*modules.ProofOfExistencesInfo, 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)

	EnableGasFee() bool
	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:"request_id"`
	ContractId string `json:"contract_id"`
}

type ContractFeeLevelRsp added in v1.0.2

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 added in v1.0.3

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:"request_id"`
	TplId string `json:"template_id"`
}

type ContractInvokeRsp added in v1.0.5

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

type ContractStopRsp added in v1.0.6

type ContractStopRsp struct {
	ReqId      string `json:"request_id"`
	ContractId string `json:"contract_id"`
}

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 added in v1.0.4

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

type GetUtxoEntry

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

type Int added in v1.0.6

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

func (*Int) Uint32 added in v1.0.6

func (i *Int) Uint32() uint32

func (*Int) Uint64 added in v1.0.6

func (i *Int) Uint64() uint64

func (*Int) UnmarshalJSON added in v1.0.6

func (d *Int) UnmarshalJSON(iBytes []byte) 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 NewHdAccountResult added in v1.0.6

type NewHdAccountResult struct {
	Address  common.Address
	Mnemonic string
}

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 added in v1.0.4

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) DumpPrivateKey added in v1.0.6

func (s *PrivateAccountAPI) DumpPrivateKey(address string, password string) (string, error)

func (*PrivateAccountAPI) GetHdAccount added in v1.0.6

func (s *PrivateAccountAPI) GetHdAccount(addr, password string, userId Int) (string, error)

func (*PrivateAccountAPI) GetPublicKey added in v1.0.3

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

appended by albert·gou func (s *PrivateAccountAPI) TransferPtn(from, to string, amount decimal.Decimal, text *string,

	password string) (*TxExecuteResult, error) {
	// 参数检查
	fromAdd, err := common.StringToAddress(from)
	if err != nil {
		return nil, fmt.Errorf("invalid account address: %v", from)
	}

	// 解锁账户
	ks := fetchKeystore(s.am)
	if !ks.IsUnlock(fromAdd) {
		duration := 1 * time.Second
		err = ks.TimedUnlock(accounts.Account{Address: fromAdd}, password, duration)
		if err != nil {
			return nil, err
		}
	}

	return s.b.TransferPtn(from, to, amount, text)
}

func (*PrivateAccountAPI) ImportHdAccountMnemonic added in v1.0.6

func (s *PrivateAccountAPI) ImportHdAccountMnemonic(mnemonic string, password string) (string, error)

func (*PrivateAccountAPI) ImportMnemonic added in v1.0.6

func (s *PrivateAccountAPI) ImportMnemonic(mnemonic string, password 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) IsUnlock added in v1.0.6

func (s *PrivateAccountAPI) IsUnlock(addrStr string) (bool, error)

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) NewHdAccount added in v1.0.6

func (s *PrivateAccountAPI) NewHdAccount(password string) (*NewHdAccountResult, error)

func (*PrivateAccountAPI) NewOutAccount added in v1.0.8

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

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

func (s *PrivateAccountAPI) Sign(ctx context.Context, data string, addr string,
	passwd string) (hexutil.Bytes, error)

对一个文本进行签名

func (*PrivateAccountAPI) SignHex added in v1.0.6

func (s *PrivateAccountAPI) SignHex(ctx context.Context, data hexutil.Bytes, addr string,
	passwd string) (hexutil.Bytes, error)

对16进制数据进行签名

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 added in v1.0.1

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

func NewPrivateContractAPI added in v1.0.1

func NewPrivateContractAPI(b Backend) *PrivateContractAPI

func (*PrivateContractAPI) Ccdeploy added in v1.0.1

func (s *PrivateContractAPI) Ccdeploy(templateId string, param []string) (*ContractDeployRsp, error)

func (*PrivateContractAPI) Ccdeploytx added in v1.0.1

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

func (*PrivateContractAPI) Ccdeploytxfee added in v1.0.3

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

func (*PrivateContractAPI) Ccinstall added in v1.0.1

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

contract command install

func (*PrivateContractAPI) Ccinstalltx added in v1.0.1

func (s *PrivateContractAPI) Ccinstalltx(from, to string, amount, fee decimal.Decimal,
	tplName, path, version, ccdescription, ccabi, cclanguage string, addrs []string, pwd *string, timeout *Int) (*ContractInstallRsp, error)

将Install包装成对系统合约的ccinvoke

func (*PrivateContractAPI) Ccinstalltxfee added in v1.0.3

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

func (*PrivateContractAPI) Ccinvoke added in v1.0.1

func (s *PrivateContractAPI) Ccinvoke(contractAddr string, param []string) (string, error)

func (*PrivateContractAPI) CcinvokeMutiToken added in v1.0.8

func (s *PrivateContractAPI) CcinvokeMutiToken(from, to, token1, token2 string, amountToken1, amountToken2, fee decimal.Decimal,
	contractAddress string, param []string, pwd *string, timeout *Int) (*ContractInvokeRsp, error)

func (*PrivateContractAPI) CcinvokeToken added in v1.0.1

func (s *PrivateContractAPI) CcinvokeToken(from, to, token string, amountToken, fee decimal.Decimal,
	contractAddress string, param []string, pwd *string, timeout *Int) (*ContractInvokeRsp, error)

func (*PrivateContractAPI) CcinvokeTokenSync added in v1.0.8

func (s *PrivateContractAPI) CcinvokeTokenSync(from, to, token string, amountToken, fee decimal.Decimal,
	contractAddress string, param []string, pwd *string, timeout *Int) (*ptnjson.ContractInvokeResultJson, error)

调用ccinvokeToken,并等待打包后返回

func (*PrivateContractAPI) Ccinvoketx added in v1.0.1

func (s *PrivateContractAPI) Ccinvoketx(from, to string, amount, fee decimal.Decimal,
	contractAddress string, param []string, password *string, timeout *Int) (*ContractInvokeRsp, error)

func (*PrivateContractAPI) CcinvoketxSync added in v1.0.8

func (s *PrivateContractAPI) CcinvoketxSync(from, to string, amount, fee decimal.Decimal,
	contractAddress string, param []string, password *string, timeout *Int) (*ptnjson.ContractInvokeResultJson, error)

调用ccinvoke,并等待打包后返回

func (*PrivateContractAPI) Ccinvoketxfee added in v1.0.3

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

func (*PrivateContractAPI) Ccstop added in v1.0.1

func (s *PrivateContractAPI) Ccstop(contractAddr string) error

func (*PrivateContractAPI) Ccstoptx added in v1.0.1

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

func (*PrivateContractAPI) Ccstoptxfee added in v1.0.3

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

func (*PrivateContractAPI) DepositContractInvoke added in v1.0.1

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

func (*PrivateContractAPI) SysConfigContractInvoke added in v1.0.1

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

type PrivateDagAPI added in v1.0.1

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

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

func NewPrivateDagAPI added in v1.0.1

func NewPrivateDagAPI(b Backend) *PrivateDagAPI

func (*PrivateDagAPI) CheckHeader added in v1.0.3

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

func (*PrivateDagAPI) CheckUnits added in v1.0.3

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

func (*PrivateDagAPI) GetAllUtxos added in v1.0.1

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

func (*PrivateDagAPI) GetCommonByPrefix added in v1.0.1

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

func (*PrivateDagAPI) GetHeaderByAuthor added in v1.0.4

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

func (*PrivateDagAPI) GetLocalTx added in v1.0.6

func (s *PrivateDagAPI) GetLocalTx(txId string) (*TxAndStatus, error)

func (*PrivateDagAPI) RebuildAddrTxIndex added in v1.0.3

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 {
	// contains filtered or unexported fields
}

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 added in v1.0.1

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 added in v1.0.2

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

将UTXO碎片聚集成整的UTXO

func (*PrivateWalletAPI) CreateProofOfExistenceTx

func (s *PrivateWalletAPI) CreateProofOfExistenceTx(addr string,
	mainData, extraData, reference string, pwd *string) (common.Hash, error)

func (*PrivateWalletAPI) CreateProofOfExistenceTxSync added in v1.0.8

func (s *PrivateWalletAPI) CreateProofOfExistenceTxSync(addr string,
	mainData, extraData, reference string, password *string) (common.Hash, error)

func (*PrivateWalletAPI) CreateTraceability added in v1.0.2

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

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

func (*PrivateWalletAPI) CreateTxWithOutFee added in v1.0.6

func (s *PrivateWalletAPI) CreateTxWithOutFee(ctx context.Context, asset, fromStr, toStr string, amount decimal.Decimal, pwd *string, duration *Int) (ptnjson.SignRawTransactionResult, error)

func (*PrivateWalletAPI) Forking

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

func (*PrivateWalletAPI) GetPtnTestCoin added in v1.0.6

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

sign rawtranscation create raw transction

func (*PrivateWalletAPI) MultiSignRawTransaction added in v1.0.5

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

func (*PrivateWalletAPI) SignAndFeeTransaction added in v1.0.6

func (s *PrivateWalletAPI) SignAndFeeTransaction(ctx context.Context, params string, gasFrom string, gasFee decimal.Decimal, Extra string, pwd *string, duration *Int) (ptnjson.SignRawTransactionResult, error)

func (*PrivateWalletAPI) SignRawTransaction added in v1.0.1

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

func (*PrivateWalletAPI) TransferPtn

func (s *PrivateWalletAPI) TransferPtn(ctx context.Context, from string, to string,
	amount decimal.Decimal, fee decimal.Decimal, data *string, password *string, duration *Int) (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, data *string, pwd *string, duration *Int) (common.Hash, error)

func (*PrivateWalletAPI) TransferToken2 added in v1.0.6

func (s *PrivateWalletAPI) TransferToken2(ctx context.Context, asset string, fromStr string, toStr string,
	gasFromStr string, amount decimal.Decimal, fee decimal.Decimal, data *string,
	pwd *string, timeout *Int) (common.Hash, error)

构造手续费代付的交易并广播

func (*PrivateWalletAPI) TransferToken2MultiAddr added in v1.0.8

func (s *PrivateWalletAPI) TransferToken2MultiAddr(asset string, from string, addrAndAmountJson string,
	fee decimal.Decimal, password string) (common.Hash, error)

构建转移给多个地址Token的交易 addrAndAmountJson 为 Address:Amount的Map

func (*PrivateWalletAPI) TransferTokenSync added in v1.0.6

func (s *PrivateWalletAPI) TransferTokenSync(ctx context.Context, asset string, fromStr string, toStr string,
	amount decimal.Decimal, fee decimal.Decimal, data *string, pwd *string, timeout *Int) (*ptnjson.TxHashWithUnitInfoJson, error)

转移Token,并确认打包后返回

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 added in v1.0.1

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

func (*PublicBlockChainAPI) AddressCount added in v1.0.6

func (s *PublicBlockChainAPI) AddressCount() (int, 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 added in v1.0.3

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 added in v1.0.3

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

func (*PublicBlockChainAPI) GetAssetExistence added in v1.0.1

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 added in v1.0.5

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

func (*PublicBlockChainAPI) GetGlobalProperty added in v1.0.5

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

func (*PublicBlockChainAPI) GetImmutableParameters added in v1.0.5

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

func (*PublicBlockChainAPI) GetJuryAccount

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

func (*PublicBlockChainAPI) GetPledge added in v1.0.3

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(id string, param []string, timeout *Int) (string, error)

func (*PublicContractAPI) DepositContractQuery

func (s *PublicContractAPI) DepositContractQuery(param []string) (string, error)

func (*PublicContractAPI) GetAllContractsUsedTemplateId added in v1.0.1

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

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

func (*PublicContractAPI) GetContractFeeLevel added in v1.0.2

func (s *PublicContractAPI) GetContractFeeLevel() (*ContractFeeLevelRsp, error)

func (*PublicContractAPI) GetContractInfoByAddr added in v1.0.1

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

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

func (*PublicContractAPI) GetContractInfoById added in v1.0.1

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

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

func (*PublicContractAPI) GetContractState

func (s *PublicContractAPI) GetContractState(contractAddr, prefix string) (string, error)

func (*PublicContractAPI) GetContractTemplateInfoById added in v1.0.1

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

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

func (*PublicContractAPI) GetContractsWithJuryAddress added in v1.0.5

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

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

func (*PublicContractAPI) ListAllContractTemplates

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

TODO

func (*PublicContractAPI) ListAllContracts

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

TODO

func (*PublicContractAPI) SysConfigContractQuery

func (s *PublicContractAPI) SysConfigContractQuery(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) GetAddrUtxoTxs added in v1.0.6

func (s *PublicDagAPI) GetAddrUtxoTxs(ctx context.Context, addr string) ([]*ptnjson.TxWithUnitInfoJson, error)

func (*PublicDagAPI) GetAddrUtxos

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

func (*PublicDagAPI) GetChainInfo added in v1.0.7

func (s *PublicDagAPI) GetChainInfo() (*ptnjson.ChainInfo, 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 added in v1.0.4

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

func (*PublicDagAPI) GetHeadUnit added in v1.0.5

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, height Int) (string, error)

func (*PublicDagAPI) GetHexCommon

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

func (*PublicDagAPI) GetLdbCommon added in v1.0.3

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

func (*PublicDagAPI) GetStableUnit added in v1.0.5

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) GetTxPackInfo added in v1.0.6

func (s *PublicDagAPI) GetTxPackInfo(ctx context.Context, txHash string) (*ptnjson.TxPackInfoJson, 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 added in v1.0.4

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, height Int) string

func (*PublicDagAPI) GetUnitHexByHash added in v1.0.7

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

func (*PublicDagAPI) GetUnitHexByIndex added in v1.0.7

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

func (*PublicDagAPI) GetUnitJsonByIndex added in v1.0.4

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

func (*PublicDagAPI) GetUnitSummaryByNumber

func (s *PublicDagAPI) GetUnitSummaryByNumber(ctx context.Context, height Int) 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) InsertUnitByHex added in v1.0.7

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

func (*PublicDagAPI) IsSynced added in v1.0.2

func (s *PublicDagAPI) IsSynced() bool

func (*PublicDagAPI) MemdagInfos added in v1.0.4

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

MemdagInfos returns the pool transaction for the given hash

func (*PublicDagAPI) StableUnitNum

func (s *PublicDagAPI) StableUnitNum() uint64

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) GetSchedule added in v1.0.7

func (s *PublicMediatorAPI) GetSchedule() (*modules.MediatorSchedule, error)

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 added in v1.0.3

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

func (*PublicMediatorAPI) LookupMediatorInfo

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

func (*PublicMediatorAPI) NextSlotTime added in v1.0.7

func (s *PublicMediatorAPI) NextSlotTime() (int64, error)

返回当前离下一个生产槽的时间差(秒)

func (*PublicMediatorAPI) NextUpdateTime added in v1.0.7

func (s *PublicMediatorAPI) NextUpdateTime() (int64, 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 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) Clear added in v1.0.7

func (s *PublicTxPoolAPI) Clear() bool

func (*PublicTxPoolAPI) Content

func (s *PublicTxPoolAPI) Content() map[string]map[string]*RPCTransaction

Content returns the transactions contained within the transaction pool.

func (*PublicTxPoolAPI) Orphan added in v1.0.9

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

孤儿的交易列表

func (*PublicTxPoolAPI) Packed added in v1.0.9

func (s *PublicTxPoolAPI) Packed() map[common.Hash][]*ptnjson.TxPoolTxJson

func (*PublicTxPoolAPI) Status

func (s *PublicTxPoolAPI) Status() map[string]int

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

func (*PublicTxPoolAPI) Unpack added in v1.0.9

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

type PublicWalletAPI

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

func NewPublicWalletAPI

func NewPublicWalletAPI(b Backend) *PublicWalletAPI

func (*PublicWalletAPI) AddBatchTxs added in v1.0.1

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

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

func (*PublicWalletAPI) CreateRawTransaction

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

func (*PublicWalletAPI) Forking

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

Start forking command.

func (*PublicWalletAPI) GetAddrTokenFlow added in v1.0.3

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 added in v1.0.3

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, addr string) (map[string]decimal.Decimal, error)

func (*PublicWalletAPI) GetBalance2 added in v1.0.3

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

func (*PublicWalletAPI) GetContractInvokeHistory added in v1.0.3

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

func (*PublicWalletAPI) GetFileInfoByFileHash

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

GetProofOfExistencesByMaindata替代GetFileInfoByFileHash

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 added in v1.0.1

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

func (*PublicWalletAPI) GetProofOfExistencesByMaindata added in v1.0.7

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

func (*PublicWalletAPI) GetProofOfExistencesByRef

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

func (*PublicWalletAPI) GetStxo added in v1.0.1

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

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

func (*PublicWalletAPI) GetUtxo added in v1.0.9

func (s *PublicWalletAPI) GetUtxo(txid string, msgIdx int, outIdx int) (*ptnjson.UtxoJson, error)

func (*PublicWalletAPI) SendJsonTransaction added in v1.0.2

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 TxAndStatus added in v1.0.6

type TxAndStatus struct {
	Tx     *ptnjson.TxJson
	Status string
}

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