ptnclient

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: 12 Imported by: 0

Documentation

Overview

Package ethclient provides a client for the palletone RPC API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClient added in v1.0.4

func GetClient(rpcParams *RPCParams) (*rpcclient.Client, error)

Types

type Client

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

Client defines typed wrappers for the Palletone RPC API.

func Dial

func Dial(rawurl string) (*Client, error)

Dial connects a client to the given URL.

func DialContext

func DialContext(ctx context.Context, rawurl string) (*Client, error)

func NewClient

func NewClient(c *rpc.Client) *Client

NewClient creates a client that uses the given RPC client.

func (*Client) BalanceAt

func (ec *Client) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)

BalanceAt returns the wei balance of the given account. The block number can be nil, in which case the balance is taken from the latest known block.

func (*Client) CallContract

func (ec *Client) CallContract(ctx context.Context, msg palletone.CallMsg, blockNumber *big.Int) ([]byte, error)

CallContract executes a message call transaction, which is directly executed in the VM of the node, but never mined into the blockchain.

blockNumber selects the block height at which the call runs. It can be nil, in which case the code is taken from the latest known block. Note that state from very old blocks might not be available.

func (*Client) Close

func (ec *Client) Close()

func (*Client) CodeAt

func (ec *Client) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)

CodeAt returns the contract code of the given account. The block number can be nil, in which case the code is taken from the latest known block.

func (*Client) CreateRawTransaction

func (ec *Client) CreateRawTransaction(ctx context.Context, params string) (string, error)
func (ec *Client) walletCreateTransaction(ctx context.Context, from string, to string, amount uint64, fee uint64) (string, error) {
	var result string
	err := ec.c.CallContext(ctx, &result, "wallet_createRawTransaction", from, to, amount, fee)
	return result, err
}

func (*Client) DecodeJsonTx added in v1.0.3

func (ec *Client) DecodeJsonTx(ctx context.Context, hex string) (string, error)

func (*Client) DecodeTx

func (ec *Client) DecodeTx(ctx context.Context, hex string) (string, error)

func (*Client) EncodeTx

func (ec *Client) EncodeTx(ctx context.Context, jsonStr string) (string, error)

func (*Client) EstimateGas

func (ec *Client) EstimateGas(ctx context.Context, msg palletone.CallMsg) (uint64, error)

EstimateGas tries to estimate the gas needed to execute a specific transaction based on the current pending state of the backend blockchain. There is no guarantee that this is the true gas limit requirement as other transactions may be added or removed by miners, but it should provide a basis for setting a reasonable default.

func (*Client) ForkingAt

func (ec *Client) ForkingAt(ctx context.Context, account common.Address, rate uint64) (uint64, error)

Forking tool's client for the palletone RPC API

func (*Client) GetAddrOutpoints

func (ec *Client) GetAddrOutpoints(ctx context.Context, addr string) ([]modules.OutPoint, error)

func (*Client) GetAddrOutput

func (ec *Client) GetAddrOutput(ctx context.Context, addr string) ([]modules.Output, error)

func (*Client) GetAddrTransactions

func (ec *Client) GetAddrTransactions(ctx context.Context, addr string) (map[string]modules.Transactions, error)

func (*Client) GetAddrUtxos

func (ec *Client) GetAddrUtxos(ctx context.Context, addr string) ([]ptnjson.UtxoJson, error)

func (*Client) GetAllUtxos

func (ec *Client) GetAllUtxos(ctx context.Context) ([]ptnjson.UtxoJson, error)

func (*Client) GetCommon

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

func (*Client) GetCommonByPrefix

func (ec *Client) GetCommonByPrefix(ctx context.Context, prefix string) (map[string][]byte, error)

func (*Client) GetPtnTestCoin

func (ec *Client) GetPtnTestCoin(ctx context.Context, from string, to string, amount string, password string, duration *uint64) (string, error)

func (*Client) GetTransactionByHash

func (ec *Client) GetTransactionByHash(ctx context.Context, hashHex string) (*ptnjson.TxSummaryJson, error)

GetTransactionByHash

func (*Client) GetTxHashByReqId

func (ec *Client) GetTxHashByReqId(ctx context.Context, hex string) (string, error)

GetTxHashByReqId

func (*Client) GetTxPoolTxByHash

func (ec *Client) GetTxPoolTxByHash(ctx context.Context, hex string) (*ptnjson.TxPoolTxJson, error)

GetPoolTxByHash

func (*Client) GetTxSearchEntry

func (ec *Client) GetTxSearchEntry(ctx context.Context, hashHex string) (*ptnjson.TxSerachEntryJson, error)

GetTxSearchEntry.

func (*Client) GetUnit

func (ec *Client) GetUnit(ctx context.Context, hash common.Hash) (*modules.Unit, error)

Get Unit

func (*Client) GetUnitNumber

func (ec *Client) GetUnitNumber(ctx context.Context, hash common.Hash) (uint64, error)

Get UnitNumber

func (*Client) GetUnitTransactions

func (ec *Client) GetUnitTransactions(ctx context.Context, hashHex string) ([]*ptnjson.TxSummaryJson, error)

func (*Client) GetUnitTxsHash

func (ec *Client) GetUnitTxsHash(ctx context.Context, hashHex string) ([]string, error)

func (*Client) GetUtxoEntry

func (ec *Client) GetUtxoEntry(ctx context.Context, key []byte) (*ptnjson.UtxoJson, error)

func (*Client) HeaderByHash

func (ec *Client) HeaderByHash(ctx context.Context, hash common.Hash) (*modules.Header, error)

HeaderByHash returns the block header with the given hash.

func (*Client) HeaderByNumber

func (ec *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*modules.Header, error)

HeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.

func (*Client) MultiSignRawTransaction added in v1.0.5

func (ec *Client) MultiSignRawTransaction(ctx context.Context, params, redeem string, addr common.Address, password string, duration *uint64) (*ptnjson.SignRawTransactionResult, error)

func (*Client) NetworkID

func (ec *Client) NetworkID(ctx context.Context) (*big.Int, error)

NetworkID returns the network ID (also known as the chain ID) for this chain.

func (*Client) NonceAt

func (ec *Client) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)

NonceAt returns the account nonce of the given account. The block number can be nil, in which case the nonce is taken from the latest known block.

func (*Client) PendingBalanceAt

func (ec *Client) PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error)

PendingBalanceAt returns the wei balance of the given account in the pending state.

func (*Client) PendingCallContract

func (ec *Client) PendingCallContract(ctx context.Context, msg palletone.CallMsg) ([]byte, error)

PendingCallContract executes a message call transaction using the EVM. The state seen by the contract call is the pending state.

func (*Client) PendingCodeAt

func (ec *Client) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)

PendingCodeAt returns the contract code of the given account in the pending state.

func (*Client) PendingNonceAt

func (ec *Client) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)

PendingNonceAt returns the account nonce of the given account in the pending state. This is the nonce that should be used for the next transaction.

func (*Client) PendingStorageAt

func (ec *Client) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error)

PendingStorageAt returns the value of key in the contract storage of the given account in the pending state.

func (*Client) PendingTransactionCount

func (ec *Client) PendingTransactionCount(ctx context.Context) (uint, error)

PendingTransactionCount returns the total number of transactions in the pending state.

func (*Client) SignRawTransaction

func (ec *Client) SignRawTransaction(ctx context.Context, params string, password string, duration *uint64) (*ptnjson.SignRawTransactionResult, error)

func (*Client) StorageAt

func (ec *Client) StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)

StorageAt returns the value of key in the contract storage of the given account. The block number can be nil, in which case the value is taken from the latest known block.

func (*Client) SubscribeNewHead

func (ec *Client) SubscribeNewHead(ctx context.Context, ch chan<- *modules.Header) (palletone.Subscription, error)

SubscribeNewHead subscribes to notifications about the current blockchain head on the given channel.

func (*Client) SuggestGasPrice

func (ec *Client) SuggestGasPrice(ctx context.Context) (*big.Int, error)

SuggestGasPrice retrieves the currently suggested gas price to allow a timely execution of a transaction.

func (*Client) SyncProgress

func (ec *Client) SyncProgress(ctx context.Context) (*palletone.SyncProgress, error)

SyncProgress retrieves the current progress of the sync algorithm. If there's no sync currently running, it returns nil.

func (*Client) TransactionByHash

func (ec *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx *modules.Transaction,
	isPending bool, err error)

TransactionByHash returns the transaction with the given hash.

func (*Client) TransferToken

func (ec *Client) TransferToken(ctx context.Context, asset string, from string, to string, amount uint64, fee uint64, password string, extra string, duration *uint64) (string, error)

func (*Client) WalletBalance

func (ec *Client) WalletBalance(ctx context.Context, address string, assetid []byte, uniqueid []byte, chainid uint64) (uint64, error)

func (*Client) WalletSendTransaction

func (ec *Client) WalletSendTransaction(ctx context.Context, params string) (string, error)

SendTransaction injects a signed transaction into the pending pool for execution.

If the transaction was a contract creation use the TransactionReceipt method to get the contract address after the transaction has been mined.

func (ec *Client) SendTransaction(ctx context.Context, tx *modules.Transaction) error {
	data, err := rlp.EncodeToBytes(tx)
	if err != nil {
		return err
	}
	return ec.c.CallContext(ctx, nil, "ptn_sendRawTransaction", common.ToHex(data))
}

func (*Client) WalletTokens

func (ec *Client) WalletTokens(ctx context.Context, addr string) (string, error)

* rpc wallet 操作接口 The apis for wallet by rpc

type RPCParams added in v1.0.4

type RPCParams struct {
	Host      string `json:"host"`
	RPCUser   string `json:"rpcUser"`
	RPCPasswd string `json:"rpcPasswd"`
	CertPath  string `json:"certPath"`
}

Jump to

Keyboard shortcuts

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