eth

package
v0.0.0-...-02504b7 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2020 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package eth is a generated protocol buffer package.

It is generated from these files:

tx.proto

It has these top-level messages:

ProtoCompleteTransaction

Index

Constants

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 GetHeightFromTx

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
)

type EthereumParser

type EthereumParser struct {
	*bchain.BaseParser
}

EthereumParser handle

func NewEthereumParser

func NewEthereumParser(b int) *EthereumParser

NewEthereumParser returns new EthereumParser instance

func (*EthereumParser) EthereumTypeGetErc20FromTx

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

EthereumTypeGetErc20FromTx returns Erc20 data from bchain.Tx

func (*EthereumParser) GetAddrDescFromAddress

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

GetAddrDescFromAddress returns internal address representation of given address

func (*EthereumParser) GetAddrDescFromVout

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

GetAddrDescFromVout returns internal address representation of given transaction output

func (*EthereumParser) GetAddressesFromAddrDesc

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

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

GetChainType returns EthereumType

func (*EthereumParser) GetScriptFromAddrDesc

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

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

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

EthereumTypeEstimateGas returns estimation of gas consumption for given transaction parameters

func (*EthereumRPC) EthereumTypeGetBalance

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

EthereumTypeGetBalance returns current balance of an address

func (*EthereumRPC) EthereumTypeGetErc20ContractBalance

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

EthereumTypeGetErc20ContractBalance returns balance of ERC20 contract for given address

func (*EthereumRPC) EthereumTypeGetErc20ContractInfo

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

EthereumTypeGetErc20ContractInfo returns information about ERC20 contract

func (*EthereumRPC) EthereumTypeGetNonce

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

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

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

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

func (b *EthereumRPC) InitializeMempool(addrDescForOutpoint bchain.AddrDescForOutpointFunc, onNewTxAddr bchain.OnNewTxAddrFunc) 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

type EthereumTxData struct {
	Status   int      `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"`
}

EthereumTxData contains ethereum specific transaction data

func GetEthereumTxData

func GetEthereumTxData(tx *bchain.Tx) *EthereumTxData

GetEthereumTxData returns EthereumTxData from bchain.Tx

type ProtoCompleteTransaction

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

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

func (*ProtoCompleteTransaction) GetBlockNumber

func (m *ProtoCompleteTransaction) GetBlockNumber() uint32

func (*ProtoCompleteTransaction) GetBlockTime

func (m *ProtoCompleteTransaction) GetBlockTime() uint64

func (*ProtoCompleteTransaction) GetReceipt

func (*ProtoCompleteTransaction) GetTx

func (*ProtoCompleteTransaction) ProtoMessage

func (*ProtoCompleteTransaction) ProtoMessage()

func (*ProtoCompleteTransaction) Reset

func (m *ProtoCompleteTransaction) Reset()

func (*ProtoCompleteTransaction) String

func (m *ProtoCompleteTransaction) String() string

type ProtoCompleteTransaction_ReceiptType

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

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

func (*ProtoCompleteTransaction_ReceiptType) GetGasUsed

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

func (*ProtoCompleteTransaction_ReceiptType) GetLog

func (*ProtoCompleteTransaction_ReceiptType) GetStatus

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

func (*ProtoCompleteTransaction_ReceiptType) ProtoMessage

func (*ProtoCompleteTransaction_ReceiptType) ProtoMessage()

func (*ProtoCompleteTransaction_ReceiptType) Reset

func (*ProtoCompleteTransaction_ReceiptType) String

type ProtoCompleteTransaction_ReceiptType_LogType

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

func (*ProtoCompleteTransaction_ReceiptType_LogType) GetAddress

func (*ProtoCompleteTransaction_ReceiptType_LogType) GetData

func (*ProtoCompleteTransaction_ReceiptType_LogType) GetTopics

func (*ProtoCompleteTransaction_ReceiptType_LogType) ProtoMessage

func (*ProtoCompleteTransaction_ReceiptType_LogType) Reset

func (*ProtoCompleteTransaction_ReceiptType_LogType) String

type ProtoCompleteTransaction_TxType

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

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

func (*ProtoCompleteTransaction_TxType) GetAccountNonce

func (m *ProtoCompleteTransaction_TxType) GetAccountNonce() uint64

func (*ProtoCompleteTransaction_TxType) GetFrom

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

func (*ProtoCompleteTransaction_TxType) GetGasLimit

func (m *ProtoCompleteTransaction_TxType) GetGasLimit() uint64

func (*ProtoCompleteTransaction_TxType) GetGasPrice

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

func (*ProtoCompleteTransaction_TxType) GetHash

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

func (*ProtoCompleteTransaction_TxType) GetPayload

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

func (*ProtoCompleteTransaction_TxType) GetTo

func (*ProtoCompleteTransaction_TxType) GetTransactionIndex

func (m *ProtoCompleteTransaction_TxType) GetTransactionIndex() uint32

func (*ProtoCompleteTransaction_TxType) GetValue

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

func (*ProtoCompleteTransaction_TxType) ProtoMessage

func (*ProtoCompleteTransaction_TxType) ProtoMessage()

func (*ProtoCompleteTransaction_TxType) Reset

func (*ProtoCompleteTransaction_TxType) String

Jump to

Keyboard shortcuts

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