Documentation ¶
Overview ¶
description: sync_eth
@author: xwc1125 @date: 2020/10/05
Package chain description: sync_eth
@author: xwc1125 @date: 2020/10/05
description: sync_eth
@author: xwc1125 @date: 2020/10/05
description: sync_eth
@author: xwc1125 @date: 2020/10/05
description: sync_eth
@author: xwc1125 @date: 2020/10/05
description: sync_eth
@author: xwc1125 @date: 2020/10/05
description: sync_eth
@author: xwc1125 @date: 2020/10/05
description: sync_eth
@author: xwc1125 @date: 2020/10/05
Index ¶
- func CompressPubkey(pubkey *ecdsa.PublicKey) []byte
- func DecompressPubkey(pubkey []byte) (*ecdsa.PublicKey, error)
- func Ecrecover(hash, sig []byte) ([]byte, error)
- func S256() elliptic.Curve
- func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error)
- func Sign(hash []byte, prv *ecdsa.PrivateKey) ([]byte, error)
- func ToECDSA(d []byte) (*ecdsa.PrivateKey, error)
- func TxStatus(txReceipt *TransactionReceipt, isToken bool) bool
- func VerifySignature(pubkey, hash, signature []byte) bool
- type Block
- type BlockHeader
- type BlockTxHashes
- type Eth
- func (eth *Eth) GetBalance(address string, result interface{}) error
- func (eth *Eth) GetBlockByHash(height uint64, isFullTx bool, result interface{}) error
- func (eth *Eth) GetBlockByNumber(height uint64, isFullTx bool, result interface{}) error
- func (eth *Eth) GetCode(contract string) (hexutil.Bytes, error)
- func (eth *Eth) GetLatestBlock(isFullTx bool, result interface{}) error
- func (eth *Eth) GetNonce(address string) (hexutil.Uint64, error)
- func (eth *Eth) GetTokenBalance(contract, address string, blockNumber *big.Int, result interface{}) error
- func (eth *Eth) GetTokenDecimals(contract string) (decimals big.Int, err error)
- func (eth *Eth) GetTokenName(contract string) (name string, err error)
- func (eth *Eth) GetTokenSymbol(contract string) (symbol string, err error)
- func (eth *Eth) GetTokenTotalSupply(contract string) (totalSupply big.Int, err error)
- func (eth *Eth) GetTransactionByHash(hash string, result interface{}) error
- func (eth *Eth) GetTransactionReceipt(hash string, result interface{}) error
- func (eth *Eth) IsContract(address string) (bool, error)
- func (eth *Eth) SendRawTransactionMethod(tx *RawTransaction) (string, error)
- func (eth *Eth) SignTx(privateKey string, to *types.Address, value *big.Int, nonce uint64, ...) (*RawTransaction, error)
- type RawTransaction
- type TokenTransferInput
- type TokenTransferParams
- type Transaction
- type TransactionDetail
- type TransactionReceipt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompressPubkey ¶
CompressPubkey encodes a public key to the 33-byte compressed format.
func DecompressPubkey ¶
DecompressPubkey parses a public key in the 33-byte compressed format.
func Sign ¶
func Sign(hash []byte, prv *ecdsa.PrivateKey) ([]byte, error)
Sign calculates an ECDSA signature.
This function is susceptible to chosen plaintext attacks that can leak information about the private key that is used for signing. Callers must be aware that the given hash cannot be chosen by an adversery. Common solution is to hash any input before calculating the signature.
The produced signature is in the [R || S || V] format where V is 0 or 1.
func TxStatus ¶
func TxStatus(txReceipt *TransactionReceipt, isToken bool) bool
TxStatus get transaction status
func VerifySignature ¶
VerifySignature checks that the given public key created signature over hash. The public key should be in compressed (33 bytes) or uncompressed (65 bytes) format. The signature should have the 64 byte [R || S] format.
Types ¶
type Block ¶
type Block struct { BlockHeader Transactions []*Transaction `json:"transactions"` }
Block block with transactions
type BlockHeader ¶
type BlockHeader struct { Number hexutil.Uint64 `json:"number"` Hash string `json:"hash"` ParentHash string `json:"parentHash"` Coinbase string `json:"coinbase"` Size hexutil.Uint64 `json:"size"` Timestamp hexutil.Uint64 `json:"timestamp"` GasLimit hexutil.Uint64 `json:"gasLimit"` GasUsed hexutil.Uint64 `json:"gasUsed"` }
BlockHeader block header
type BlockTxHashes ¶
type BlockTxHashes struct { BlockHeader Transactions []string `json:"transactions"` }
BlockTxHashes block with txHashes
func Block2BlockTxHashes ¶
func Block2BlockTxHashes(b *Block) *BlockTxHashes
Block2BlockTxHashes block to blockTxHashes
func (*BlockTxHashes) Bytes ¶
func (b *BlockTxHashes) Bytes() ([]byte, error)
Bytes blockTxHashes json bytes
type Eth ¶
type Eth struct {
// contains filtered or unexported fields
}
Eth eth
func (*Eth) GetBalance ¶
GetBalance get balance
func (*Eth) GetBlockByHash ¶
GetBlockByHash get block by hash
func (*Eth) GetBlockByNumber ¶
GetBlockByNumber get block by height isFullTx whether return the full transaction
func (*Eth) GetLatestBlock ¶
GetLatestBlock get latest block
func (*Eth) GetTokenBalance ¶
func (eth *Eth) GetTokenBalance(contract, address string, blockNumber *big.Int, result interface{}) error
GetTokenBalance get token balance
func (*Eth) GetTokenDecimals ¶
GetTokenDecimals get token decimals
func (*Eth) GetTokenName ¶
GetTokenName get token name
func (*Eth) GetTokenSymbol ¶
GetTokenSymbol get token symbol
func (*Eth) GetTokenTotalSupply ¶
GetTokenTotalSupply get token total supply
func (*Eth) GetTransactionByHash ¶
GetTransactionByHash get transaction by hash
func (*Eth) GetTransactionReceipt ¶
GetTransactionReceipt get tx receipt by hash
func (*Eth) IsContract ¶
IsContract whether address is contract
func (*Eth) SendRawTransactionMethod ¶
func (eth *Eth) SendRawTransactionMethod(tx *RawTransaction) (string, error)
SendRawTransactionMethod send rawTx
type RawTransaction ¶
type RawTransaction struct { Nonce uint64 `json:"nonce" gencodec:"required"` GaPrice *big.Int `json:"gasPrice" gencodec:"required"` Gas uint64 `json:"gas" gencodec:"required"` To *types.Address `json:"to" rlp:"nil"` // nil means contract creation Value *big.Int `json:"value" gencodec:"required"` Input []byte `json:"input" gencodec:"required"` // Signature values V *big.Int `json:"v" gencodec:"required"` R *big.Int `json:"r" gencodec:"required"` S *big.Int `json:"s" gencodec:"required"` }
func (*RawTransaction) GetRawTx ¶
func (t *RawTransaction) GetRawTx() []byte
func (*RawTransaction) GetTxHash ¶
func (t *RawTransaction) GetTxHash() string
type TokenTransferInput ¶
type TokenTransferInput struct { Method string `json:"method"` MethodName string `json:"methodName"` From string `json:"from,omitempty"` To string `json:"to"` Value string `json:"value"` }
func ParseInput ¶
func ParseInput(input string) *TokenTransferInput
func ParseInputBytes ¶
func ParseInputBytes(inputBytes hexutil.Bytes) *TokenTransferInput
type TokenTransferParams ¶
type TokenTransferParams struct { MethodName string `json:"methodName"` From string `json:"from,omitempty"` To string `json:"to"` Value decimal.Decimal `json:"value"` }
func ParseTransferInput ¶
func ParseTransferInput(input *TokenTransferInput) *TokenTransferParams
type Transaction ¶
type Transaction struct { Hash string `json:"hash"` Nonce hexutil.Uint64 `json:"nonce"` BlockHash string `json:"blockHash"` BlockNumber hexutil.Uint64 `json:"blockNumber"` TransactionIndex hexutil.Uint64 `json:"transactionIndex"` From types.Address `json:"from"` To *types.Address `json:"to"` Value *hexutil.Big `json:"value"` GasPrice *hexutil.Big `json:"gasPrice"` GasLimit hexutil.Uint64 `json:"gas"` Input hexutil.Bytes `json:"input"` }
func (*Transaction) Bytes ¶
func (tx *Transaction) Bytes() ([]byte, error)
type TransactionDetail ¶
type TransactionDetail struct { *Transaction CumulativeGasUsed hexutil.Uint64 `json:"cumulativeGasUsed"` GasUsed hexutil.Uint64 `json:"gasUsed"` ContractAddress *types.Address `json:"contractAddress"` Logs json.RawMessage `json:"logs"` //LogsBloom hexutil.Bytes `json:"logsBloom"` Status bool `json:"status"` InputFormat *TokenTransferInput `json:"inputFormat"` }
type TransactionReceipt ¶
type TransactionReceipt struct { TransactionHash string `json:"transactionHash"` TransactionIndex hexutil.Uint64 `json:"transactionIndex"` BlockHash string `json:"blockHash"` BlockNumber hexutil.Uint64 `json:"blockNumber"` From types.Address `json:"from"` To *types.Address `json:"to"` CumulativeGasUsed hexutil.Uint64 `json:"cumulativeGasUsed"` GasUsed hexutil.Uint64 `json:"gasUsed"` ContractAddress *types.Address `json:"contractAddress"` Logs json.RawMessage `json:"logs"` Status hexutil.Uint64 `json:"status"` }
func (*TransactionReceipt) Bytes ¶
func (t *TransactionReceipt) Bytes() ([]byte, error)