Documentation
¶
Overview ¶
Package ethapi implements the general PalletOne API functions.
Index ¶
- Constants
- func CreateRawTransaction(c *ptnjson.CreateRawTransactionCmd) (string, error)
- func GetAPIs(apiBackend Backend) []rpc.API
- func MakeAddress(ks *keystore.KeyStore, account string) (accounts.Account, error)
- func RandFromString(value string) (decimal.Decimal, error)
- func SelectUtxoFromDagAndPool(dbUtxo map[modules.OutPoint]*modules.Utxo, ...) (map[modules.OutPoint]*modules.Utxo, error)
- func SignRawTransaction(icmd interface{}, pubKeyFn tokenengine.AddressGetPubKey, ...) (ptnjson.SignRawTransactionResult, error)
- func WalletCreateProofTransaction(c *ptnjson.CreateProofTransactionCmd) (string, error)
- func WalletCreateTransaction(c *ptnjson.CreateRawTransactionCmd) (string, error)
- type AddrLocker
- type Authentifier
- type Backend
- type CallArgs
- type ContractDeployRsp
- type ContractInstallRsp
- type DeserializationError
- type ExecutionResult
- type FutureGetTxOutResult
- type GetUtxoEntry
- type InvalidParameterError
- type JuryList
- type MediatorCreateArgs
- type ParseError
- type PrivateAccountAPI
- func (s *PrivateAccountAPI) DeriveAccount(url string, path string, pin *bool) (accounts.Account, error)
- func (s *PrivateAccountAPI) ImportRawKey(privkey string, password string) (string, error)
- func (s *PrivateAccountAPI) ListAccounts() []string
- func (s *PrivateAccountAPI) ListWallets() []rawWallet
- func (s *PrivateAccountAPI) LlistAccounts() ([]string, error)
- func (s *PrivateAccountAPI) LockAccount(addrStr string) bool
- func (s *PrivateAccountAPI) NewAccount(password string) (string, error)
- func (s *PrivateAccountAPI) OpenWallet(url string, passphrase *string) error
- func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error)
- func (s *PrivateAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr string, passwd string) (hexutil.Bytes, error)
- func (s *PrivateAccountAPI) SignAndSendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error)
- func (s *PrivateAccountAPI) SignTransaction(ctx context.Context, args SendTxArgs, passwd string) (*SignTransactionResult, error)
- func (s *PrivateAccountAPI) TransferPtn(from, to string, amount decimal.Decimal, text *string, password string) (*TxExecuteResult, error)
- func (s *PrivateAccountAPI) UnlockAccount(addrStr string, password string, duration *uint64) (bool, error)
- type PrivateDebugAPI
- func (api *PrivateDebugAPI) ChaindbCompact() error
- func (api *PrivateDebugAPI) ChaindbProperty(property string) (string, error)
- func (api *PrivateDebugAPI) GetAllTokenBalance() map[string]uint64
- func (api *PrivateDebugAPI) QueryDbByKey(keyString string, keyHex string) *ptnjson.DbRowJson
- func (api *PrivateDebugAPI) QueryDbByPrefix(keyString string, keyHex string) []*ptnjson.DbRowJson
- func (api *PrivateDebugAPI) SaveCommon(keyHex string, valueHex string) error
- func (api *PrivateDebugAPI) SetHead(number hexutil.Uint64)
- type PrivateMediatorAPI
- func (a *PrivateMediatorAPI) Apply(args MediatorCreateArgs) (*TxExecuteResult, error)
- func (a *PrivateMediatorAPI) PayDeposit(from string, amount decimal.Decimal) (*TxExecuteResult, error)
- func (a *PrivateMediatorAPI) Quit(medAddStr string) (*TxExecuteResult, error)
- func (a *PrivateMediatorAPI) Vote(voterStr string, mediatorStrs []string) (*TxExecuteResult, error)
- func (a *PrivateMediatorAPI) WithdrawDeposit(medAddStr string, amount decimal.Decimal) (*TxExecuteResult, error)
- type PrivateWalletAPI
- func (s *PrivateWalletAPI) CreateProofOfExistenceTx(ctx context.Context, addr string, mainData, extraData, reference string, ...) (common.Hash, error)
- func (s *PrivateWalletAPI) Forking(ctx context.Context, rate uint64) uint64
- func (s *PrivateWalletAPI) TransferPtn(ctx context.Context, from string, to string, amount decimal.Decimal, ...) (common.Hash, error)
- func (s *PrivateWalletAPI) TransferToken(ctx context.Context, asset string, from string, to string, ...) (common.Hash, error)
- type PublicAccountAPI
- type PublicBlockChainAPI
- func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNr rpc.BlockNumber) (hexutil.Bytes, error)
- func (s *PublicBlockChainAPI) CcstartChaincodeContainer(ctx context.Context, deployId string, txid string) (string, error)
- func (s *PublicBlockChainAPI) DecodeTx(ctx context.Context, hex string) (string, error)
- func (s *PublicBlockChainAPI) Election(ctx context.Context, sid string) (string, error)
- func (s *PublicBlockChainAPI) EncodeTx(ctx context.Context, json string) (string, error)
- func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs) (hexutil.Uint64, error)
- func (s *PublicBlockChainAPI) Forking(ctx context.Context, rate uint64) uint64
- func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address string) (map[string]decimal.Decimal, error)
- func (s *PublicBlockChainAPI) GetChainParameters() (*core.ChainParameters, error)
- func (s *PublicBlockChainAPI) GetCode(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (hexutil.Bytes, error)
- func (s *PublicBlockChainAPI) GetJuryAccount(ctx context.Context) *JuryList
- func (s *PublicBlockChainAPI) GetPrefix(condition string) string
- func (s *PublicBlockChainAPI) GetProofTxInfoByHash(ctx context.Context, txhash string) ([][]byte, error)
- func (s *PublicBlockChainAPI) GetStorageAt(ctx context.Context, address common.Address, key string, ...) (hexutil.Bytes, error)
- func (s *PublicBlockChainAPI) GetTokenTxHistory(ctx context.Context, assetStr string) ([]*ptnjson.TxHistoryJson, error)
- func (s *PublicBlockChainAPI) ListSysConfig() ([]*ptnjson.ConfigJson, error)
- func (s *PublicBlockChainAPI) ProofTransactionByHash(ctx context.Context, txhash string) (string, error)
- func (s *PublicBlockChainAPI) ProofTransactionByRlptx(ctx context.Context, rlptx [][]byte) (string, error)
- func (s *PublicBlockChainAPI) SetJuryAccount(ctx context.Context, addr, pwd string) string
- func (s *PublicBlockChainAPI) StartCorsSync(ctx context.Context) (string, error)
- func (s *PublicBlockChainAPI) SyncUTXOByAddr(ctx context.Context, addr string) string
- type PublicContractAPI
- func (s *PublicContractAPI) Ccdeploy(ctx context.Context, templateId string, param []string, timeout uint32) (*ContractDeployRsp, error)
- func (s *PublicContractAPI) Ccdeploytx(ctx context.Context, from, to, daoAmount, daoFee, tplId string, param []string) (*ContractDeployRsp, error)
- func (s *PublicContractAPI) Ccinstall(ctx context.Context, ccname string, ccpath string, ccversion string) (hexutil.Bytes, error)
- func (s *PublicContractAPI) Ccinstalltx(ctx context.Context, ...) (*ContractInstallRsp, error)
- func (s *PublicContractAPI) Ccinvoke(ctx context.Context, contractAddr string, param []string, timeout uint32) (string, error)
- func (s *PublicContractAPI) CcinvokeToken(ctx context.Context, ...) (*ContractDeployRsp, error)
- func (s *PublicContractAPI) Ccinvoketx(ctx context.Context, from, to, daoAmount, daoFee, deployId string, ...) (*ContractDeployRsp, error)
- func (s *PublicContractAPI) CcinvoketxPass(ctx context.Context, from, to, daoAmount, daoFee, deployId string, ...) (string, error)
- func (s *PublicContractAPI) Ccquery(ctx context.Context, contractAddr string, param []string, timeout uint32) (string, error)
- func (s *PublicContractAPI) Ccstop(ctx context.Context, contractAddr string) error
- func (s *PublicContractAPI) Ccstoptx(ctx context.Context, ...) (string, error)
- func (s *PublicContractAPI) DepositContractInvoke(ctx context.Context, from, to, daoAmount, daoFee string, param []string) (string, error)
- func (s *PublicContractAPI) DepositContractQuery(ctx context.Context, param []string) (string, error)
- func (s *PublicContractAPI) GetContractState(contractid []byte, key string) ([]byte, *modules.StateVersion, error)
- func (s *PublicContractAPI) GetContractsByTpl(ctx context.Context, tplId string) ([]*ptnjson.ContractJson, error)
- func (s *PublicContractAPI) ListAllContractTemplates(ctx context.Context) ([]*ptnjson.ContractTemplateJson, error)
- func (s *PublicContractAPI) ListAllContracts(ctx context.Context) ([]*ptnjson.ContractJson, error)
- func (s *PublicContractAPI) SysConfigContractInvoke(ctx context.Context, from, to, daoAmount, daoFee string, param []string) (string, error)
- func (s *PublicContractAPI) SysConfigContractQuery(ctx context.Context, param []string) (string, error)
- type PublicDagAPI
- func (s *PublicDagAPI) GetAddrOutpoints(ctx context.Context, addr string) (string, error)
- func (s *PublicDagAPI) GetAddrUtxos(ctx context.Context, addr string) (string, error)
- func (s *PublicDagAPI) GetAllUtxos(ctx context.Context) (string, error)
- func (s *PublicDagAPI) GetCommon(ctx context.Context, key string) ([]byte, error)
- func (s *PublicDagAPI) GetCommonByPrefix(ctx context.Context, prefix string) (string, error)
- func (s *PublicDagAPI) GetFastUnitIndex(ctx context.Context, assetid string) string
- func (s *PublicDagAPI) GetHeaderByHash(ctx context.Context, condition string) (string, error)
- func (s *PublicDagAPI) GetHeaderByNumber(ctx context.Context, condition string) (string, error)
- func (s *PublicDagAPI) GetHexCommon(ctx context.Context, key string) (string, error)
- func (s *PublicDagAPI) GetTransactionsByTxid(ctx context.Context, txid string) (*ptnjson.GetTxIdResult, error)
- func (s *PublicDagAPI) GetTxByHash(ctx context.Context, hashHex string) (string, error)
- func (s *PublicDagAPI) GetTxByReqId(ctx context.Context, hashHex string) (string, error)
- func (s *PublicDagAPI) GetTxHashByReqId(ctx context.Context, hashHex string) (string, error)
- func (s *PublicDagAPI) GetTxPoolTxByHash(ctx context.Context, hex string) (string, error)
- func (s *PublicDagAPI) GetTxSearchEntry(ctx context.Context, hashHex string) (string, error)
- func (s *PublicDagAPI) GetUnitByHash(ctx context.Context, condition string) string
- func (s *PublicDagAPI) GetUnitByNumber(ctx context.Context, condition string) string
- func (s *PublicDagAPI) GetUnitSummaryByNumber(ctx context.Context, condition string) string
- func (s *PublicDagAPI) GetUnitTxsHashHex(ctx context.Context, hashHex string) (string, error)
- func (s *PublicDagAPI) GetUnitTxsInfo(ctx context.Context, hashHex string) (string, error)
- func (s *PublicDagAPI) GetUnitsByIndex(ctx context.Context, start, end decimal.Decimal, asset string) string
- func (s *PublicDagAPI) GetUnstableUnits() []*ptnjson.UnitSummaryJson
- func (s *PublicDagAPI) HeadUnitHash() string
- func (s *PublicDagAPI) HeadUnitNum() uint64
- func (s *PublicDagAPI) HeadUnitTime() string
- func (s *PublicDagAPI) StableUnitNum() uint64
- type PublicDebugAPI
- type PublicMediatorAPI
- func (a *PublicMediatorAPI) GetDeposit(addStr string) (*deposit.MediatorDeposit, error)
- func (a *PublicMediatorAPI) GetInfo(addStr string) (*modules.MediatorInfo, error)
- func (a *PublicMediatorAPI) GetNextUpdateTime() string
- func (a *PublicMediatorAPI) GetVoted(addStr string) ([]string, error)
- func (a *PublicMediatorAPI) IsActive(addStr string) (bool, error)
- func (a *PublicMediatorAPI) IsApproved(addStr string) (string, error)
- func (a *PublicMediatorAPI) IsInList(addStr string) (bool, error)
- func (a *PublicMediatorAPI) ListActives() []string
- func (a *PublicMediatorAPI) ListAll() []string
- func (a *PublicMediatorAPI) ListVoteResults() map[string]uint64
- func (a *PublicMediatorAPI) LookupMediatorInfo() []*modules.MediatorInfo
- type PublicNetAPI
- type PublicPalletOneAPI
- type PublicReturnInfo
- type PublicTransactionPoolAPI
- func (s *PublicTransactionPoolAPI) BatchSign(ctx context.Context, txid string, fromAddress, toAddress string, amount int, ...) ([]string, error)
- func (s *PublicTransactionPoolAPI) CmdCreateTransaction(ctx context.Context, from string, to string, amount, fee decimal.Decimal) (string, error)
- func (s *PublicTransactionPoolAPI) GetAddrOutpoints(ctx context.Context, addr string) (string, error)
- func (s *PublicTransactionPoolAPI) GetAddrUtxos(ctx context.Context, addr string) (string, error)
- func (s *PublicTransactionPoolAPI) GetAllUtxos(ctx context.Context) (string, error)
- func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint
- func (s *PublicTransactionPoolAPI) GetTransactionCount(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (*hexutil.Uint64, error)
- func (s *PublicTransactionPoolAPI) GetTransactionsByTxid(ctx context.Context, txid string) (*ptnjson.GetTxIdResult, error)
- func (s *PublicTransactionPoolAPI) GetTxHashByReqId(ctx context.Context, hashHex string) (string, error)
- func (s *PublicTransactionPoolAPI) GetTxPoolTxByHash(ctx context.Context, hex string) (string, error)
- func (s *PublicTransactionPoolAPI) SendJsonTransaction(ctx context.Context, jsonStr string) (common.Hash, error)
- func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encodedTx string) (common.Hash, error)
- func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args SendTxArgs) (common.Hash, error)
- func (s *PublicTransactionPoolAPI) Sign(addr common.Address, data hexutil.Bytes) (hexutil.Bytes, error)
- func (s *PublicTransactionPoolAPI) SignRawTransaction(ctx context.Context, params string, hashtype string, password string, ...) (ptnjson.SignRawTransactionResult, error)
- func (s *PublicTransactionPoolAPI) SignTransaction(ctx context.Context, args SendTxArgs) (*SignTransactionResult, error)
- type PublicTxPoolAPI
- type PublicWalletAPI
- func (s *PublicWalletAPI) CreateProofTransaction(ctx context.Context, params string, password string) (common.Hash, error)
- func (s *PublicWalletAPI) CreateRawTransaction(ctx context.Context, from string, to string, amount, fee decimal.Decimal) (string, error)
- func (s *PublicWalletAPI) Forking(ctx context.Context, rate uint64) uint64
- func (s *PublicWalletAPI) GetAddrTxHistory(ctx context.Context, addr string) ([]*ptnjson.TxHistoryJson, error)
- func (s *PublicWalletAPI) GetAddrUtxos(ctx context.Context, addr string) (string, error)
- func (s *PublicWalletAPI) GetAllTokenInfo(ctx context.Context) (string, error)
- func (s *PublicWalletAPI) GetBalance(ctx context.Context, address string) (map[string]decimal.Decimal, error)
- func (s *PublicWalletAPI) GetFileInfoByFileHash(ctx context.Context, filehash string) (string, error)
- func (s *PublicWalletAPI) GetFileInfoByTxid(ctx context.Context, txid string) (string, error)
- func (s *PublicWalletAPI) GetOneTokenInfo(ctx context.Context, symbol string) (string, error)
- func (s *PublicWalletAPI) GetProofOfExistencesByRef(ctx context.Context, reference string) ([]*ptnjson.ProofOfExistenceJson, error)
- func (s *PublicWalletAPI) GetPtnTestCoin(ctx context.Context, from string, to string, amount, password string, ...) (common.Hash, error)
- func (s *PublicWalletAPI) SendRawTransaction(ctx context.Context, params string) (common.Hash, error)
- func (s *PublicWalletAPI) SendRlpTransaction(ctx context.Context, encodedTx string) (common.Hash, error)
- type RPCTransaction
- type SendTxArgs
- type SignTransactionParams
- type SignTransactionResult
- type SignatureError
- type StructLogRes
- type TxExecuteResult
Constants ¶
const DefaultResult = "Transaction executed locally, but may not be confirmed by the network yet!"
const (
MaxTxInSequenceNum uint32 = 0xffffffff
)
Variables ¶
This section is empty.
Functions ¶
func CreateRawTransaction ¶
func CreateRawTransaction(c *ptnjson.CreateRawTransactionCmd) (string, error)
create raw transction
func MakeAddress ¶
func SignRawTransaction ¶
func SignRawTransaction(icmd interface{}, pubKeyFn tokenengine.AddressGetPubKey, hashFn tokenengine.AddressGetSign, addr common.Address) (ptnjson.SignRawTransactionResult, error)
sign rawtranscation
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 Authentifier ¶
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 // BlockChain API 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 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) ([]*modules.TxPoolTransaction, error) //GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error) Stats() (int, int, int) TxPoolContent() (map[common.Hash]*modules.TxPoolTransaction, map[common.Hash]*modules.TxPoolTransaction) Queued() ([]*modules.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) ([]byte, error) GetCommonByPrefix(prefix []byte) map[string][]byte SaveCommon(key, val []byte) error // Get Contract Api GetContract(hex_id string) (*modules.Contract, 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) 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) GetAddrRawUtxos(addr string) (map[modules.OutPoint]*modules.Utxo, error) GetAllUtxos() ([]*ptnjson.UtxoJson, error) GetAddrTxHistory(addr string) ([]*ptnjson.TxHistoryJson, error) GetAssetTxHistory(asset *modules.Asset) ([]*ptnjson.TxHistoryJson, 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 ContractStartChaincodeContainer(templateId []byte, txId string) (deployId []byte, e error) DecodeTx(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, 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) ContractInvokeReqTokenTx(from, to, toToken common.Address, daoAmount, daoFee, daoAmountToken uint64, asset string, 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) ElectionVrf(id uint32) ([]byte, error) UpdateJuryAccount(addr common.Address, pwd string) bool GetJuryAccount() []common.Address ContractQuery(contractId []byte, txid string, args [][]byte, timeout time.Duration) (rspPayload []byte, err error) 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) //get contract key GetContractState(contractid []byte, key string) ([]byte, *modules.StateVersion, error) GetContractStatesByPrefix(id []byte, prefix string) (map[string]*modules.ContractStateValue, error) //SPV GetProofTxInfoByHash(txhash string) ([][]byte, error) ProofTransactionByHash(txhash string) (string, error) ProofTransactionByRlptx(rlptx [][]byte) (string, error) SyncUTXOByAddr(addr string) string StartCorsSync() (string, error) GetChainParameters() *core.ChainParameters }
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 ContractInstallRsp ¶
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 FutureGetTxOutResult ¶
type FutureGetTxOutResult chan *response
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 MediatorCreateArgs ¶
type MediatorCreateArgs struct {
*modules.MediatorCreateOperation
}
创建 mediator 所需的参数, 至少包含普通账户地址
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) 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) 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) LlistAccounts ¶
func (s *PrivateAccountAPI) LlistAccounts() ([]string, error)
ListAccounts will return a list of addresses for accounts 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) SendTransaction ¶
func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error)
SendTransaction will create a transaction from the given arguments and tries to sign it with the key associated with args.To. If the given passwd isn't able to decrypt the key it fails.
func (*PrivateAccountAPI) Sign ¶
func (s *PrivateAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr string, passwd string) (hexutil.Bytes, error)
Sign calculates an PalletOne 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 key used to calculate the signature is decrypted with the given password.
https://github.com/palletone/go-palletone/wiki/Management-APIs#personal_sign
func (*PrivateAccountAPI) SignAndSendTransaction ¶
func (s *PrivateAccountAPI) SignAndSendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error)
// EcRecover returns the address for the account that was used to create the signature. // Note, this function is compatible with eth_sign and personal_sign. As such it recovers // the address of: // hash = keccak256("\x19Ethereum Signed Message:\n"${message length}${message}) // addr = ecrecover(hash, signature) // // Note, the signature must conform to the secp256k1 curve R, S and V values, where // the V value must be be 27 or 28 for legacy reasons. // // https://github.com/palletone/go-palletone/wiki/Management-APIs#personal_ecRecover
func (s *PrivateAccountAPI) EcRecover(ctx context.Context, data, sig hexutil.Bytes) (common.Address, error) { if len(sig) != 65 { return common.Address{}, fmt.Errorf("signature must be 65 bytes long") } if sig[64] != 27 && sig[64] != 28 { return common.Address{}, fmt.Errorf("invalid PalletOne signature (V is not 27 or 28)") } sig[64] -= 27 // Transform yellow paper V from 27/28 to 0/1 rpk, err := crypto.Ecrecover(signHash(data), sig) if err != nil { return common.Address{}, err } pubKey := crypto.ToECDSAPub(rpk) recoveredAddr := crypto.PubkeyToAddress(pubKey) return recoveredAddr, nil }
SignAndSendTransaction was renamed to SendTransaction. This method is deprecated and will be removed in the future. It primary goal is to give clients time to update.
func (*PrivateAccountAPI) SignTransaction ¶
func (s *PrivateAccountAPI) SignTransaction(ctx context.Context, args SendTxArgs, passwd string) (*SignTransactionResult, error)
SignTransaction will create a transaction from the given arguments and tries to sign it with the key associated with args.To. If the given passwd isn't able to decrypt the key it fails. The transaction is returned in RLP-form, not broadcast to other nodes
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 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 (a *PrivateMediatorAPI) Apply(args MediatorCreateArgs) (*TxExecuteResult, error)
func (*PrivateMediatorAPI) PayDeposit ¶
func (a *PrivateMediatorAPI) PayDeposit(from string, amount decimal.Decimal) (*TxExecuteResult, error)
func (*PrivateMediatorAPI) Quit ¶
func (a *PrivateMediatorAPI) Quit(medAddStr string) (*TxExecuteResult, error)
func (*PrivateMediatorAPI) Vote ¶
func (a *PrivateMediatorAPI) Vote(voterStr string, mediatorStrs []string) (*TxExecuteResult, error)
func (*PrivateMediatorAPI) WithdrawDeposit ¶
func (a *PrivateMediatorAPI) WithdrawDeposit(medAddStr string, amount decimal.Decimal) (*TxExecuteResult, error)
type PrivateWalletAPI ¶
type PrivateWalletAPI struct {
// contains filtered or unexported fields
}
func NewPrivateWalletAPI ¶
func NewPrivateWalletAPI(b Backend) *PrivateWalletAPI
func (*PrivateWalletAPI) CreateProofOfExistenceTx ¶
func (*PrivateWalletAPI) Forking ¶
func (s *PrivateWalletAPI) Forking(ctx context.Context, rate uint64) uint64
func (*PrivateWalletAPI) TransferPtn ¶
type PublicAccountAPI ¶
type PublicAccountAPI struct {
// contains filtered or unexported fields
}
// Inspect retrieves the content of the transaction pool and flattens it into an // easily inspectable list.
func (s *PublicTxPoolAPI) Inspect() map[string]map[string]map[string]string { content := map[string]map[string]map[string]string{ "pending": make(map[string]map[string]string), "queued": make(map[string]map[string]string), } pending, queue := s.b.TxPoolContent() // Define a formatter to flatten a transaction into a string var format = func(tx *modules.Transaction) string { if to := tx.To(); to != nil { return fmt.Sprintf("%s: %v wei + %v gas × %v wei", tx.To().Hex(), tx.Value(), tx.Gas(), tx.GasPrice()) } return fmt.Sprintf("contract creation: %v wei + %v gas × %v wei", tx.Value(), tx.Gas(), tx.GasPrice()) } // Flatten the pending transactions for account, txs := range pending { dump := make(map[string]string) for _, tx := range txs { dump[fmt.Sprintf("%d", tx.Nonce())] = format(tx) } content["pending"][account.Hex()] = dump } // Flatten the queued transactions for account, txs := range queue { dump := make(map[string]string) for _, tx := range txs { dump[fmt.Sprintf("%d", tx.Nonce())] = format(tx) } content["queued"][account.Hex()] = dump } return content }
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) 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) CcstartChaincodeContainer ¶
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) 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) GetJuryAccount ¶
func (s *PublicBlockChainAPI) GetJuryAccount(ctx context.Context) *JuryList
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 (*PublicBlockChainAPI) ProofTransactionByRlptx ¶
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) Ccdeploy ¶
func (s *PublicContractAPI) Ccdeploy(ctx context.Context, templateId string, param []string, timeout uint32) (*ContractDeployRsp, error)
func (*PublicContractAPI) Ccdeploytx ¶
func (s *PublicContractAPI) Ccdeploytx(ctx context.Context, from, to, daoAmount, daoFee, tplId string, param []string) (*ContractDeployRsp, error)
func (*PublicContractAPI) Ccinstall ¶
func (s *PublicContractAPI) Ccinstall(ctx context.Context, ccname string, ccpath string, ccversion string) (hexutil.Bytes, error)
contract command install
func (*PublicContractAPI) Ccinstalltx ¶
func (s *PublicContractAPI) Ccinstalltx(ctx context.Context, from, to, daoAmount, daoFee, tplName, path, version string, addr []string) (*ContractInstallRsp, error)
contract tx
func (*PublicContractAPI) CcinvokeToken ¶
func (s *PublicContractAPI) CcinvokeToken(ctx context.Context, from, to, toToken, daoAmount, daoFee, assetToken, amountToken, deployId string, param []string) (*ContractDeployRsp, error)
func (*PublicContractAPI) Ccinvoketx ¶
func (s *PublicContractAPI) Ccinvoketx(ctx context.Context, from, to, daoAmount, daoFee, deployId string, param []string, certID string, timeout string) (*ContractDeployRsp, error)
func (*PublicContractAPI) CcinvoketxPass ¶
func (*PublicContractAPI) Ccstop ¶
func (s *PublicContractAPI) Ccstop(ctx context.Context, contractAddr string) error
func (*PublicContractAPI) DepositContractInvoke ¶
func (*PublicContractAPI) DepositContractQuery ¶
func (*PublicContractAPI) GetContractState ¶
func (s *PublicContractAPI) GetContractState(contractid []byte, key string) ([]byte, *modules.StateVersion, error)
func (*PublicContractAPI) GetContractsByTpl ¶
func (s *PublicContractAPI) GetContractsByTpl(ctx context.Context, tplId string) ([]*ptnjson.ContractJson, error)
func (*PublicContractAPI) ListAllContractTemplates ¶
func (s *PublicContractAPI) ListAllContractTemplates(ctx context.Context) ([]*ptnjson.ContractTemplateJson, error)
func (*PublicContractAPI) ListAllContracts ¶
func (s *PublicContractAPI) ListAllContracts(ctx context.Context) ([]*ptnjson.ContractJson, error)
func (*PublicContractAPI) SysConfigContractInvoke ¶
func (*PublicContractAPI) SysConfigContractQuery ¶
type PublicDagAPI ¶
type PublicDagAPI struct {
// contains filtered or unexported fields
}
func NewPublicDagAPI ¶
func NewPublicDagAPI(b Backend) *PublicDagAPI
func (*PublicDagAPI) GetAddrOutpoints ¶
func (*PublicDagAPI) GetAddrUtxos ¶
func (*PublicDagAPI) GetAllUtxos ¶
func (s *PublicDagAPI) GetAllUtxos(ctx context.Context) (string, error)
func (*PublicDagAPI) GetCommonByPrefix ¶
func (*PublicDagAPI) GetFastUnitIndex ¶
func (s *PublicDagAPI) GetFastUnitIndex(ctx context.Context, assetid string) string
func (*PublicDagAPI) GetHeaderByHash ¶
func (*PublicDagAPI) GetHeaderByNumber ¶
func (*PublicDagAPI) GetHexCommon ¶
func (*PublicDagAPI) GetTransactionsByTxid ¶
func (s *PublicDagAPI) GetTransactionsByTxid(ctx context.Context, txid string) (*ptnjson.GetTxIdResult, error)
func (*PublicDagAPI) GetTxByHash ¶
func (*PublicDagAPI) GetTxByReqId ¶
func (*PublicDagAPI) GetTxHashByReqId ¶
func (*PublicDagAPI) GetTxPoolTxByHash ¶
GetTxPoolTxByHash returns the pool transaction for the given hash
func (*PublicDagAPI) GetTxSearchEntry ¶
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) GetUnitSummaryByNumber ¶
func (s *PublicDagAPI) GetUnitSummaryByNumber(ctx context.Context, condition string) string
func (*PublicDagAPI) GetUnitTxsHashHex ¶
func (*PublicDagAPI) GetUnitTxsInfo ¶
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
SaveTokenInfo save a token ,return hex key.
func (s *PublicDagAPI) SaveTokenInfo(ctx context.Context, name, token, creator string) (string, error) { //info to token info := modules.NewTokenInfo(name, token, creator) item, err := s.b.SaveTokenInfo(info) if err != nil { return "", err } this := NewPublicReturnInfo("save_token_info", item) result_json, _ := json.Marshal(this) return string(result_json), nil
}
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) 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() if err != nil { 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) (*deposit.MediatorDeposit, 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() []string
func (*PublicMediatorAPI) ListAll ¶
func (a *PublicMediatorAPI) ListAll() []string
func (*PublicMediatorAPI) ListVoteResults ¶
func (a *PublicMediatorAPI) ListVoteResults() map[string]uint64
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) 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 synchronise from - currentBlock: block number this node is currently importing - highestBlock: block number of the highest block header this node has received from peers - pulledStates: number of state entries processed until now - knownStates: number of known state entries that still need to be pulled
type 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) CmdCreateTransaction ¶
func (*PublicTransactionPoolAPI) GetAddrOutpoints ¶
func (*PublicTransactionPoolAPI) GetAddrUtxos ¶
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 (*PublicTransactionPoolAPI) GetTxPoolTxByHash ¶
func (s *PublicTransactionPoolAPI) GetTxPoolTxByHash(ctx context.Context, hex string) (string, error)
GetTxPoolTxByHash returns the pool transaction for the given hash
func (*PublicTransactionPoolAPI) SendJsonTransaction ¶
func (s *PublicTransactionPoolAPI) SendJsonTransaction(ctx context.Context, jsonStr string) (common.Hash, error)
SendJsonTransaction will add the signed transaction jsonto the transaction pool. The sender is responsible for signing the transaction and using the correct nonce.
func (*PublicTransactionPoolAPI) SendRawTransaction ¶
func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encodedTx string) (common.Hash, error)
SendRawTransaction will add the signed transaction to the transaction pool. The sender is responsible for signing the transaction and using the correct nonce.
func (*PublicTransactionPoolAPI) SendTransaction ¶
func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args SendTxArgs) (common.Hash, error)
SendTransaction creates a transaction for the given argument, sign it and submit it to the transaction pool.
func (*PublicTransactionPoolAPI) Sign ¶
func (s *PublicTransactionPoolAPI) Sign(addr common.Address, data hexutil.Bytes) (hexutil.Bytes, error)
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.
func (*PublicTransactionPoolAPI) SignRawTransaction ¶
func (s *PublicTransactionPoolAPI) SignRawTransaction(ctx context.Context, params string, hashtype string, password string, duration *uint64) (ptnjson.SignRawTransactionResult, error)
sign rawtranscation create raw transction
func (*PublicTransactionPoolAPI) SignTransaction ¶
func (s *PublicTransactionPoolAPI) SignTransaction(ctx context.Context, args SendTxArgs) (*SignTransactionResult, error)
SignTransaction will sign the given transaction with the from account. The node needs to have the private key of the account corresponding with the given from address and it needs to be unlocked.
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
type PublicWalletAPI ¶
type PublicWalletAPI struct {
// contains filtered or unexported fields
}
func NewPublicWalletAPI ¶
func NewPublicWalletAPI(b Backend) *PublicWalletAPI
func (*PublicWalletAPI) CreateProofTransaction ¶
func (*PublicWalletAPI) CreateRawTransaction ¶
func (*PublicWalletAPI) Forking ¶
func (s *PublicWalletAPI) Forking(ctx context.Context, rate uint64) uint64
Start forking command.
func (*PublicWalletAPI) GetAddrTxHistory ¶
func (s *PublicWalletAPI) GetAddrTxHistory(ctx context.Context, addr string) ([]*ptnjson.TxHistoryJson, error)
func (*PublicWalletAPI) GetAddrUtxos ¶
func (*PublicWalletAPI) GetAllTokenInfo ¶
func (s *PublicWalletAPI) GetAllTokenInfo(ctx context.Context) (string, error)
func (*PublicWalletAPI) GetBalance ¶
func (*PublicWalletAPI) GetFileInfoByFileHash ¶
func (*PublicWalletAPI) GetFileInfoByTxid ¶
func (*PublicWalletAPI) GetOneTokenInfo ¶
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) SendRawTransaction ¶
func (s *PublicWalletAPI) SendRawTransaction(ctx context.Context, params 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 ¶
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 SendTxArgs ¶
type SendTxArgs 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"` Nonce *hexutil.Uint64 `json:"nonce"` // We accept "data" and "input" for backwards-compatibility reasons. "input" is the // newer name and should be preferred by clients. Data *hexutil.Bytes `json:"data"` Input *hexutil.Bytes `json:"input"` }
SendTxArgs represents the arguments to sumbit a new transaction into the transaction pool.
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 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