eth

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Package eth is a generated protocol buffer package.

It is generated from these files:

bchain/coins/eth/ethtx.proto

It has these top-level messages:

ProtoCompleteTransaction

Index

Constants

View Source
const (
	TxStatusUnknown = TxStatus(iota - 2)
	TxStatusPending
	TxStatusFailure
	TxStatusOK
)

statuses of transaction

View Source
const EtherAmountDecimalPoint = 18

EtherAmountDecimalPoint defines number of decimal points in Ether amounts

View Source
const EthereumTypeAddressDescriptorLen = 20

EthereumTypeAddressDescriptorLen - in case of EthereumType, the AddressDescriptor has fixed length

Variables

This section is empty.

Functions

func EIP55Address added in v0.3.2

func EIP55Address(addrDesc bchain.AddressDescriptor) string

EIP55Address returns an EIP55-compliant hex string representation of the address

func EIP55AddressFromAddress added in v0.3.2

func EIP55AddressFromAddress(address string) string

EIP55AddressFromAddress returns an EIP55-compliant hex string representation of the address

func GetHeightFromTx added in v0.2.0

func GetHeightFromTx(tx *bchain.Tx) (uint32, error)

GetHeightFromTx returns ethereum specific data from bchain.Tx

func NewEthereumRPC

func NewEthereumRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error)

NewEthereumRPC returns new EthRPC instance.

Types

type Configuration

type Configuration struct {
	CoinName                    string `json:"coin_name"`
	CoinShortcut                string `json:"coin_shortcut"`
	RPCURL                      string `json:"rpc_url"`
	RPCTimeout                  int    `json:"rpc_timeout"`
	BlockAddressesToKeep        int    `json:"block_addresses_to_keep"`
	MempoolTxTimeoutHours       int    `json:"mempoolTxTimeoutHours"`
	QueryBackendOnMempoolResync bool   `json:"queryBackendOnMempoolResync"`
}

Configuration represents json config file

type EthereumNet

type EthereumNet uint32

EthereumNet type specifies the type of ethereum network

const (
	// MainNet is production network
	MainNet EthereumNet = 1
	// TestNet is Ropsten test network
	TestNet EthereumNet = 3
	// TestNetGoerli is Goerli test network
	TestNetGoerli EthereumNet = 5
)

type EthereumParser

type EthereumParser struct {
	*bchain.BaseParser
}

EthereumParser handle

func NewEthereumParser

func NewEthereumParser(b int) *EthereumParser

NewEthereumParser returns new EthereumParser instance

func (*EthereumParser) EthereumTypeGetErc20FromTx added in v0.2.0

func (p *EthereumParser) EthereumTypeGetErc20FromTx(tx *bchain.Tx) ([]bchain.Erc20Transfer, error)

EthereumTypeGetErc20FromTx returns Erc20 data from bchain.Tx

func (*EthereumParser) GetAddrDescFromAddress added in v0.1.0

func (p *EthereumParser) GetAddrDescFromAddress(address string) (bchain.AddressDescriptor, error)

GetAddrDescFromAddress returns internal address representation of given address

func (*EthereumParser) GetAddrDescFromVout added in v0.1.0

func (p *EthereumParser) GetAddrDescFromVout(output *bchain.Vout) (bchain.AddressDescriptor, error)

GetAddrDescFromVout returns internal address representation of given transaction output

func (*EthereumParser) GetAddressesFromAddrDesc added in v0.1.0

func (p *EthereumParser) GetAddressesFromAddrDesc(addrDesc bchain.AddressDescriptor) ([]string, bool, error)

GetAddressesFromAddrDesc returns addresses for given address descriptor with flag if the addresses are searchable

func (*EthereumParser) GetChainType added in v0.2.0

func (p *EthereumParser) GetChainType() bchain.ChainType

GetChainType returns EthereumType

func (*EthereumParser) GetScriptFromAddrDesc added in v0.1.0

func (p *EthereumParser) GetScriptFromAddrDesc(addrDesc bchain.AddressDescriptor) ([]byte, error)

GetScriptFromAddrDesc returns output script for given address descriptor

func (*EthereumParser) PackBlockHash

func (p *EthereumParser) PackBlockHash(hash string) ([]byte, error)

PackBlockHash packs block hash to byte array

func (*EthereumParser) PackTx

func (p *EthereumParser) PackTx(tx *bchain.Tx, height uint32, blockTime int64) ([]byte, error)

PackTx packs transaction to byte array

func (*EthereumParser) PackTxid

func (p *EthereumParser) PackTxid(txid string) ([]byte, error)

PackTxid packs txid to byte array

func (*EthereumParser) PackedTxidLen

func (p *EthereumParser) PackedTxidLen() int

PackedTxidLen returns length in bytes of packed txid

func (*EthereumParser) UnpackBlockHash

func (p *EthereumParser) UnpackBlockHash(buf []byte) (string, error)

UnpackBlockHash unpacks byte array to block hash

func (*EthereumParser) UnpackTx

func (p *EthereumParser) UnpackTx(buf []byte) (*bchain.Tx, uint32, error)

UnpackTx unpacks transaction from byte array

func (*EthereumParser) UnpackTxid

func (p *EthereumParser) UnpackTxid(buf []byte) (string, error)

UnpackTxid unpacks byte array to txid

type EthereumRPC

type EthereumRPC struct {
	*bchain.BaseChain

	Parser  *EthereumParser
	Mempool *bchain.MempoolEthereumType

	ChainConfig *Configuration
	// contains filtered or unexported fields
}

EthereumRPC is an interface to JSON-RPC eth service.

func (*EthereumRPC) CreateMempool added in v0.2.2

func (b *EthereumRPC) CreateMempool(chain bchain.BlockChain) (bchain.Mempool, error)

CreateMempool creates mempool if not already created, however does not initialize it

func (*EthereumRPC) EstimateFee

func (b *EthereumRPC) EstimateFee(blocks int) (big.Int, error)

EstimateFee returns fee estimation

func (*EthereumRPC) EstimateSmartFee

func (b *EthereumRPC) EstimateSmartFee(blocks int, conservative bool) (big.Int, error)

EstimateSmartFee returns fee estimation

func (*EthereumRPC) EthereumTypeEstimateGas added in v0.2.0

func (b *EthereumRPC) EthereumTypeEstimateGas(params map[string]interface{}) (uint64, error)

EthereumTypeEstimateGas returns estimation of gas consumption for given transaction parameters

func (*EthereumRPC) EthereumTypeGetBalance added in v0.2.0

func (b *EthereumRPC) EthereumTypeGetBalance(addrDesc bchain.AddressDescriptor) (*big.Int, error)

EthereumTypeGetBalance returns current balance of an address

func (*EthereumRPC) EthereumTypeGetErc20ContractBalance added in v0.2.0

func (b *EthereumRPC) EthereumTypeGetErc20ContractBalance(addrDesc, contractDesc bchain.AddressDescriptor) (*big.Int, error)

EthereumTypeGetErc20ContractBalance returns balance of ERC20 contract for given address

func (*EthereumRPC) EthereumTypeGetErc20ContractInfo added in v0.2.0

func (b *EthereumRPC) EthereumTypeGetErc20ContractInfo(contractDesc bchain.AddressDescriptor) (*bchain.Erc20Contract, error)

EthereumTypeGetErc20ContractInfo returns information about ERC20 contract

func (*EthereumRPC) EthereumTypeGetNonce added in v0.2.0

func (b *EthereumRPC) EthereumTypeGetNonce(addrDesc bchain.AddressDescriptor) (uint64, error)

EthereumTypeGetNonce returns current balance of an address

func (*EthereumRPC) GetBestBlockHash

func (b *EthereumRPC) GetBestBlockHash() (string, error)

GetBestBlockHash returns hash of the tip of the best-block-chain

func (*EthereumRPC) GetBestBlockHeight

func (b *EthereumRPC) GetBestBlockHeight() (uint32, error)

GetBestBlockHeight returns height of the tip of the best-block-chain

func (*EthereumRPC) GetBlock

func (b *EthereumRPC) GetBlock(hash string, height uint32) (*bchain.Block, error)

GetBlock returns block with given hash or height, hash has precedence if both passed

func (*EthereumRPC) GetBlockHash

func (b *EthereumRPC) GetBlockHash(height uint32) (string, error)

GetBlockHash returns hash of block in best-block-chain at given height

func (*EthereumRPC) GetBlockHeader

func (b *EthereumRPC) GetBlockHeader(hash string) (*bchain.BlockHeader, error)

GetBlockHeader returns header of block with given hash

func (*EthereumRPC) GetBlockInfo added in v0.1.0

func (b *EthereumRPC) GetBlockInfo(hash string) (*bchain.BlockInfo, error)

GetBlockInfo returns extended header (more info than in bchain.BlockHeader) with a list of txids

func (*EthereumRPC) GetChainInfo added in v0.1.0

func (b *EthereumRPC) GetChainInfo() (*bchain.ChainInfo, error)

GetChainInfo returns information about the connected backend

func (*EthereumRPC) GetChainParser

func (b *EthereumRPC) GetChainParser() bchain.BlockChainParser

GetChainParser returns ethereum BlockChainParser

func (*EthereumRPC) GetCoinName

func (b *EthereumRPC) GetCoinName() string

GetCoinName returns coin name

func (*EthereumRPC) GetMempoolTransactions

func (b *EthereumRPC) GetMempoolTransactions() ([]string, error)

GetMempoolTransactions returns transactions in mempool

func (*EthereumRPC) GetSubversion

func (b *EthereumRPC) GetSubversion() string

GetSubversion returns empty string, ethereum does not have subversion

func (*EthereumRPC) GetTransaction

func (b *EthereumRPC) GetTransaction(txid string) (*bchain.Tx, error)

GetTransaction returns a transaction by the transaction ID.

func (*EthereumRPC) GetTransactionForMempool

func (b *EthereumRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error)

GetTransactionForMempool returns a transaction by the transaction ID. It could be optimized for mempool, i.e. without block time and confirmations

func (*EthereumRPC) GetTransactionSpecific added in v0.1.1

func (b *EthereumRPC) GetTransactionSpecific(tx *bchain.Tx) (json.RawMessage, error)

GetTransactionSpecific returns json as returned by backend, with all coin specific data

func (*EthereumRPC) Initialize

func (b *EthereumRPC) Initialize() error

Initialize initializes ethereum rpc interface

func (*EthereumRPC) InitializeMempool added in v0.2.2

func (b *EthereumRPC) InitializeMempool(addrDescForOutpoint bchain.AddrDescForOutpointFunc, onNewTxAddr bchain.OnNewTxAddrFunc, onNewTx bchain.OnNewTxFunc) error

InitializeMempool creates subscriptions to newHeads and newPendingTransactions

func (*EthereumRPC) SendRawTransaction

func (b *EthereumRPC) SendRawTransaction(hex string) (string, error)

SendRawTransaction sends raw transaction

func (*EthereumRPC) Shutdown

func (b *EthereumRPC) Shutdown(ctx context.Context) error

Shutdown cleans up rpc interface to ethereum

type EthereumTxData added in v0.2.0

type EthereumTxData struct {
	Status   TxStatus `json:"status"` // 1 OK, 0 Fail, -1 pending, -2 unknown
	Nonce    uint64   `json:"nonce"`
	GasLimit *big.Int `json:"gaslimit"`
	GasUsed  *big.Int `json:"gasused"`
	GasPrice *big.Int `json:"gasprice"`
	Data     string   `json:"data"`
}

EthereumTxData contains ethereum specific transaction data

func GetEthereumTxData added in v0.2.0

func GetEthereumTxData(tx *bchain.Tx) *EthereumTxData

GetEthereumTxData returns EthereumTxData from bchain.Tx

func GetEthereumTxDataFromSpecificData added in v0.3.5

func GetEthereumTxDataFromSpecificData(coinSpecificData interface{}) *EthereumTxData

GetEthereumTxDataFromSpecificData returns EthereumTxData from coinSpecificData

type ProtoCompleteTransaction added in v0.2.0

type ProtoCompleteTransaction struct {
	BlockNumber uint32                                `protobuf:"varint,1,opt,name=BlockNumber" json:"BlockNumber,omitempty"`
	BlockTime   uint64                                `protobuf:"varint,2,opt,name=BlockTime" json:"BlockTime,omitempty"`
	Tx          *ProtoCompleteTransaction_TxType      `protobuf:"bytes,3,opt,name=Tx" json:"Tx,omitempty"`
	Receipt     *ProtoCompleteTransaction_ReceiptType `protobuf:"bytes,4,opt,name=Receipt" json:"Receipt,omitempty"`
}

func (*ProtoCompleteTransaction) Descriptor added in v0.2.0

func (*ProtoCompleteTransaction) Descriptor() ([]byte, []int)

func (*ProtoCompleteTransaction) GetBlockNumber added in v0.2.0

func (m *ProtoCompleteTransaction) GetBlockNumber() uint32

func (*ProtoCompleteTransaction) GetBlockTime added in v0.2.0

func (m *ProtoCompleteTransaction) GetBlockTime() uint64

func (*ProtoCompleteTransaction) GetReceipt added in v0.2.0

func (*ProtoCompleteTransaction) GetTx added in v0.2.0

func (*ProtoCompleteTransaction) ProtoMessage added in v0.2.0

func (*ProtoCompleteTransaction) ProtoMessage()

func (*ProtoCompleteTransaction) Reset added in v0.2.0

func (m *ProtoCompleteTransaction) Reset()

func (*ProtoCompleteTransaction) String added in v0.2.0

func (m *ProtoCompleteTransaction) String() string

type ProtoCompleteTransaction_ReceiptType added in v0.2.0

type ProtoCompleteTransaction_ReceiptType struct {
	GasUsed []byte                                          `protobuf:"bytes,1,opt,name=GasUsed,proto3" json:"GasUsed,omitempty"`
	Status  []byte                                          `protobuf:"bytes,2,opt,name=Status,proto3" json:"Status,omitempty"`
	Log     []*ProtoCompleteTransaction_ReceiptType_LogType `protobuf:"bytes,3,rep,name=Log" json:"Log,omitempty"`
}

func (*ProtoCompleteTransaction_ReceiptType) Descriptor added in v0.2.0

func (*ProtoCompleteTransaction_ReceiptType) Descriptor() ([]byte, []int)

func (*ProtoCompleteTransaction_ReceiptType) GetGasUsed added in v0.2.0

func (m *ProtoCompleteTransaction_ReceiptType) GetGasUsed() []byte

func (*ProtoCompleteTransaction_ReceiptType) GetLog added in v0.2.0

func (*ProtoCompleteTransaction_ReceiptType) GetStatus added in v0.2.0

func (m *ProtoCompleteTransaction_ReceiptType) GetStatus() []byte

func (*ProtoCompleteTransaction_ReceiptType) ProtoMessage added in v0.2.0

func (*ProtoCompleteTransaction_ReceiptType) ProtoMessage()

func (*ProtoCompleteTransaction_ReceiptType) Reset added in v0.2.0

func (*ProtoCompleteTransaction_ReceiptType) String added in v0.2.0

type ProtoCompleteTransaction_ReceiptType_LogType added in v0.2.0

type ProtoCompleteTransaction_ReceiptType_LogType struct {
	Address []byte   `protobuf:"bytes,1,opt,name=Address,proto3" json:"Address,omitempty"`
	Data    []byte   `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,omitempty"`
	Topics  [][]byte `protobuf:"bytes,3,rep,name=Topics,proto3" json:"Topics,omitempty"`
}

func (*ProtoCompleteTransaction_ReceiptType_LogType) Descriptor added in v0.2.0

func (*ProtoCompleteTransaction_ReceiptType_LogType) GetAddress added in v0.2.0

func (*ProtoCompleteTransaction_ReceiptType_LogType) GetData added in v0.2.0

func (*ProtoCompleteTransaction_ReceiptType_LogType) GetTopics added in v0.2.0

func (*ProtoCompleteTransaction_ReceiptType_LogType) ProtoMessage added in v0.2.0

func (*ProtoCompleteTransaction_ReceiptType_LogType) Reset added in v0.2.0

func (*ProtoCompleteTransaction_ReceiptType_LogType) String added in v0.2.0

type ProtoCompleteTransaction_TxType added in v0.2.0

type ProtoCompleteTransaction_TxType struct {
	AccountNonce     uint64 `protobuf:"varint,1,opt,name=AccountNonce" json:"AccountNonce,omitempty"`
	GasPrice         []byte `protobuf:"bytes,2,opt,name=GasPrice,proto3" json:"GasPrice,omitempty"`
	GasLimit         uint64 `protobuf:"varint,3,opt,name=GasLimit" json:"GasLimit,omitempty"`
	Value            []byte `protobuf:"bytes,4,opt,name=Value,proto3" json:"Value,omitempty"`
	Payload          []byte `protobuf:"bytes,5,opt,name=Payload,proto3" json:"Payload,omitempty"`
	Hash             []byte `protobuf:"bytes,6,opt,name=Hash,proto3" json:"Hash,omitempty"`
	To               []byte `protobuf:"bytes,7,opt,name=To,proto3" json:"To,omitempty"`
	From             []byte `protobuf:"bytes,8,opt,name=From,proto3" json:"From,omitempty"`
	TransactionIndex uint32 `protobuf:"varint,9,opt,name=TransactionIndex" json:"TransactionIndex,omitempty"`
}

func (*ProtoCompleteTransaction_TxType) Descriptor added in v0.2.0

func (*ProtoCompleteTransaction_TxType) Descriptor() ([]byte, []int)

func (*ProtoCompleteTransaction_TxType) GetAccountNonce added in v0.2.0

func (m *ProtoCompleteTransaction_TxType) GetAccountNonce() uint64

func (*ProtoCompleteTransaction_TxType) GetFrom added in v0.2.0

func (m *ProtoCompleteTransaction_TxType) GetFrom() []byte

func (*ProtoCompleteTransaction_TxType) GetGasLimit added in v0.2.0

func (m *ProtoCompleteTransaction_TxType) GetGasLimit() uint64

func (*ProtoCompleteTransaction_TxType) GetGasPrice added in v0.2.0

func (m *ProtoCompleteTransaction_TxType) GetGasPrice() []byte

func (*ProtoCompleteTransaction_TxType) GetHash added in v0.2.0

func (m *ProtoCompleteTransaction_TxType) GetHash() []byte

func (*ProtoCompleteTransaction_TxType) GetPayload added in v0.2.0

func (m *ProtoCompleteTransaction_TxType) GetPayload() []byte

func (*ProtoCompleteTransaction_TxType) GetTo added in v0.2.0

func (*ProtoCompleteTransaction_TxType) GetTransactionIndex added in v0.2.0

func (m *ProtoCompleteTransaction_TxType) GetTransactionIndex() uint32

func (*ProtoCompleteTransaction_TxType) GetValue added in v0.2.0

func (m *ProtoCompleteTransaction_TxType) GetValue() []byte

func (*ProtoCompleteTransaction_TxType) ProtoMessage added in v0.2.0

func (*ProtoCompleteTransaction_TxType) ProtoMessage()

func (*ProtoCompleteTransaction_TxType) Reset added in v0.2.0

func (*ProtoCompleteTransaction_TxType) String added in v0.2.0

type TxStatus added in v0.3.5

type TxStatus int

TxStatus is status of transaction

Jump to

Keyboard shortcuts

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