geth

package
v1.5.1-0...-810389c Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2016 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

Package geth contains the simplified mobile APIs to go-ethereum.

The scope of this package is *not* to allow writing a custom Ethereun client with pieces plucked from go-ethereum, rather to allow writing native dapps on mobile platforms. Keep this in mind when using or extending this package!

API limitations

Since gomobile cannot bridge arbitrary types between Go and Android/iOS, the exposed APIs need to be manually wrapped into simplified types, with custom constructors and getters/setters to ensure that they can be meaninfully used from Java/ObjC too.

With this in mind, please try to limit the scope of this package and only add essentials without which mobile support cannot work, especially since manually syncing the code will be unwieldy otherwise. In the long term we might consider writing custom library generators, but those are out of scope now.

Content wise each file in this package corresponds to an entire Go package from the go-ethereum repository. Please adhere to this scoping to prevent this package getting unmaintainable.

Wrapping guidelines:

Every type that is to be exposed should be wrapped into its own plain struct, which internally contains a single field: the original go-ethereum version. This is needed because gomobile cannot expose named types for now.

Whenever a method argument or a return type is a custom struct, the pointer variant should always be used as value types crossing over between language boundaries might have strange behaviors.

Slices of types should be converted into a single multiplicative type wrapping a go slice with the methods `Size`, `Get` and `Set`. Further slice operations should not be provided to limit the remote code complexity. Arrays should be avoided as much as possible since they complicate bounds checking.

Note, a panic *cannot* cross over language boundaries, instead will result in an undebuggable SEGFAULT in the process. For error handling only ever use error returns, which may be the only or the second return.

Index

Constants

View Source
const (
	// StandardScryptN is the N parameter of Scrypt encryption algorithm, using 256MB
	// memory and taking approximately 1s CPU time on a modern processor.
	StandardScryptN = int(accounts.StandardScryptN)

	// StandardScryptP is the P parameter of Scrypt encryption algorithm, using 256MB
	// memory and taking approximately 1s CPU time on a modern processor.
	StandardScryptP = int(accounts.StandardScryptP)

	// LightScryptN is the N parameter of Scrypt encryption algorithm, using 4MB
	// memory and taking approximately 100ms CPU time on a modern processor.
	LightScryptN = int(accounts.LightScryptN)

	// LightScryptP is the P parameter of Scrypt encryption algorithm, using 4MB
	// memory and taking approximately 100ms CPU time on a modern processor.
	LightScryptP = int(accounts.LightScryptP)
)

Variables

This section is empty.

Functions

func MainnetGenesis

func MainnetGenesis() string

MainnetGenesis returns the JSON spec to use for the main Ethereum network. It is actually empty since that defaults to the hard coded binary genesis block.

func TestnetGenesis

func TestnetGenesis() string

TestnetGenesis returns the JSON spec to use for the Ethereum test network.

Types

type Account

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

Account represents a stored key.

func (*Account) GetAddress

func (a *Account) GetAddress() *Address

GetAddress retrieves the address associated with the account.

func (*Account) GetFile

func (a *Account) GetFile() string

GetFile retrieves the path of the file containing the account key.

type AccountManager

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

AccountManager manages a key storage directory on disk.

func NewAccountManager

func NewAccountManager(keydir string, scryptN, scryptP int) *AccountManager

NewAccountManager creates a manager for the given directory.

func (*AccountManager) DeleteAccount

func (am *AccountManager) DeleteAccount(a *Account, passphrase string) error

DeleteAccount deletes the key matched by account if the passphrase is correct. If a contains no filename, the address must match a unique key.

func (*AccountManager) ExportKey

func (am *AccountManager) ExportKey(a *Account, passphrase, newPassphrase string) ([]byte, error)

ExportKey exports as a JSON key, encrypted with newPassphrase.

func (*AccountManager) GetAccounts

func (am *AccountManager) GetAccounts() *Accounts

GetAccounts returns all key files present in the directory.

func (*AccountManager) HasAddress

func (am *AccountManager) HasAddress(addr *Address) bool

HasAddress reports whether a key with the given address is present.

func (*AccountManager) ImportKey

func (am *AccountManager) ImportKey(keyJSON []byte, passphrase, newPassphrase string) (*Account, error)

ImportKey stores the given encrypted JSON key into the key directory.

func (*AccountManager) ImportPreSaleKey

func (am *AccountManager) ImportPreSaleKey(keyJSON []byte, passphrase string) (*Account, error)

ImportPreSaleKey decrypts the given Ethereum presale wallet and stores a key file in the key directory. The key file is encrypted with the same passphrase.

func (*AccountManager) Lock

func (am *AccountManager) Lock(addr *Address) error

Lock removes the private key with the given address from memory.

func (*AccountManager) NewAccount

func (am *AccountManager) NewAccount(passphrase string) (*Account, error)

NewAccount generates a new key and stores it into the key directory, encrypting it with the passphrase.

func (*AccountManager) Sign

func (am *AccountManager) Sign(addr *Address, hash []byte) ([]byte, error)

Sign signs hash with an unlocked private key matching the given address.

func (*AccountManager) SignWithPassphrase

func (am *AccountManager) SignWithPassphrase(addr *Address, passphrase string, hash []byte) ([]byte, error)

SignWithPassphrase signs hash if the private key matching the given address can be decrypted with the given passphrase.

func (*AccountManager) TimedUnlock

func (am *AccountManager) TimedUnlock(a *Account, passphrase string, timeout int64) error

TimedUnlock unlocks the given account with the passphrase. The account stays unlocked for the duration of timeout. A timeout of 0 unlocks the account until the program exits. The account must match a unique key file.

If the account address is already unlocked for a duration, TimedUnlock extends or shortens the active unlock timeout. If the address was previously unlocked indefinitely the timeout is not altered.

func (*AccountManager) Unlock

func (am *AccountManager) Unlock(a *Account, passphrase string) error

Unlock unlocks the given account indefinitely.

func (*AccountManager) Update

func (am *AccountManager) Update(a *Account, passphrase, newPassphrase string) error

Update changes the passphrase of an existing account.

type Accounts

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

Accounts represents a slice of accounts.

func (*Accounts) Get

func (a *Accounts) Get(index int) (*Account, error)

Get returns the account at the given index from the slice.

func (*Accounts) Set

func (a *Accounts) Set(index int, account *Account) error

Set sets the account at the given index in the slice.

func (*Accounts) Size

func (a *Accounts) Size() int

Size returns the number of accounts in the slice.

type Address

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

Address represents the 20 byte address of an Ethereum account.

func NewAddressFromBytes

func NewAddressFromBytes(address []byte) (*Address, error)

NewAddressFromBytes converts a slice of bytes to a hash value.

func NewAddressFromHex

func NewAddressFromHex(address string) (*Address, error)

NewAddressFromHex converts a hex string to a address value.

func (*Address) GetBytes

func (a *Address) GetBytes() []byte

GetBytes retrieves the byte representation of the address.

func (*Address) GetHex

func (a *Address) GetHex() string

GetHex retrieves the hex string representation of the address.

func (*Address) SetBytes

func (a *Address) SetBytes(address []byte) error

SetBytes sets the specified slice of bytes as the address value.

func (*Address) SetHex

func (a *Address) SetHex(address string) error

SetHex sets the specified hex string as the address value.

type Addresses

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

Addresses represents a slice of addresses.

func (*Addresses) Get

func (a *Addresses) Get(index int) (*Address, error)

Get returns the address at the given index from the slice.

func (*Addresses) Set

func (a *Addresses) Set(index int, address *Address) error

Set sets the address at the given index in the slice.

func (*Addresses) Size

func (a *Addresses) Size() int

Size returns the number of addresses in the slice.

type BigInt

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

A BigInt represents a signed multi-precision integer.

func NewBigInt

func NewBigInt(x int64) *BigInt

NewBigInt allocates and returns a new BigInt set to x.

func (*BigInt) GetBytes

func (bi *BigInt) GetBytes() []byte

GetBytes returns the absolute value of x as a big-endian byte slice.

func (*BigInt) GetInt64

func (bi *BigInt) GetInt64() int64

GetInt64 returns the int64 representation of x. If x cannot be represented in an int64, the result is undefined.

func (*BigInt) GetString

func (bi *BigInt) GetString(base int) string

GetString returns the value of x as a formatted string in some number base.

func (*BigInt) SetBytes

func (bi *BigInt) SetBytes(buf []byte)

SetBytes interprets buf as the bytes of a big-endian unsigned integer and sets the big int to that value.

func (*BigInt) SetInt64

func (bi *BigInt) SetInt64(x int64)

SetInt64 sets the big int to x.

func (*BigInt) SetString

func (bi *BigInt) SetString(x string, base int)

SetString sets the big int to x.

The string prefix determines the actual conversion base. A prefix of "0x" or "0X" selects base 16; the "0" prefix selects base 8, and a "0b" or "0B" prefix selects base 2. Otherwise the selected base is 10.

func (*BigInt) String

func (bi *BigInt) String() string

String returns the value of x as a formatted decimal string.

type BigInts

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

BigInts represents a slice of big ints.

func (*BigInts) Get

func (bi *BigInts) Get(index int) (*BigInt, error)

Get returns the bigint at the given index from the slice.

func (*BigInts) Set

func (bi *BigInts) Set(index int, bigint *BigInt) error

Set sets the big int at the given index in the slice.

func (*BigInts) Size

func (bi *BigInts) Size() int

Size returns the number of big ints in the slice.

type Block

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

Block represents an entire block in the Ethereum blockchain.

func (*Block) GetBloom

func (b *Block) GetBloom() *Bloom

func (*Block) GetCoinbase

func (b *Block) GetCoinbase() *Address

func (*Block) GetDifficulty

func (b *Block) GetDifficulty() *BigInt

func (*Block) GetExtra

func (b *Block) GetExtra() []byte

func (*Block) GetGasLimit

func (b *Block) GetGasLimit() int64

func (*Block) GetGasUsed

func (b *Block) GetGasUsed() int64

func (*Block) GetHash

func (b *Block) GetHash() *Hash

func (*Block) GetHashNoNonce

func (b *Block) GetHashNoNonce() *Hash

func (*Block) GetHeader

func (b *Block) GetHeader() *Header

func (*Block) GetMixDigest

func (b *Block) GetMixDigest() *Hash

func (*Block) GetNonce

func (b *Block) GetNonce() int64

func (*Block) GetNumber

func (b *Block) GetNumber() int64

func (*Block) GetParentHash

func (b *Block) GetParentHash() *Hash

func (*Block) GetReceiptHash

func (b *Block) GetReceiptHash() *Hash

func (*Block) GetRoot

func (b *Block) GetRoot() *Hash

func (*Block) GetTime

func (b *Block) GetTime() int64

func (*Block) GetTransaction

func (b *Block) GetTransaction(hash *Hash) *Transaction

func (*Block) GetTransactions

func (b *Block) GetTransactions() *Transactions

func (*Block) GetTxHash

func (b *Block) GetTxHash() *Hash

func (*Block) GetUncleHash

func (b *Block) GetUncleHash() *Hash

func (*Block) GetUncles

func (b *Block) GetUncles() *Headers

type Bloom

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

Bloom represents a 256 bit bloom filter.

func (*Bloom) GetBytes

func (b *Bloom) GetBytes() []byte

GetBytes retrieves the byte representation of the bloom filter.

func (*Bloom) GetHex

func (b *Bloom) GetHex() string

GetHex retrieves the hex string representation of the bloom filter.

type BoundContract

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

BoundContract is the base wrapper object that reflects a contract on the Ethereum network. It contains a collection of methods that are used by the higher level contract bindings to operate.

func BindContract

func BindContract(address *Address, abiJSON string, client *EthereumClient) (*BoundContract, error)

BindContract creates a low level contract interface through which calls and transactions may be made through.

func DeployContract

func DeployContract(opts *TransactOpts, abiJSON string, bytecode []byte, client *EthereumClient, args *Interfaces) (*BoundContract, error)

DeployContract deploys a contract onto the Ethereum blockchain and binds the deployment address with a wrapper.

func (*BoundContract) Call

func (c *BoundContract) Call(opts *CallOpts, out *Interfaces, method string, args *Interfaces) error

Call invokes the (constant) contract method with params as input values and sets the output to result.

func (*BoundContract) GetAddress

func (c *BoundContract) GetAddress() *Address

func (*BoundContract) GetDeployer

func (c *BoundContract) GetDeployer() *Transaction

func (*BoundContract) Transact

func (c *BoundContract) Transact(opts *TransactOpts, method string, args *Interfaces) (*Transaction, error)

Transact invokes the (paid) contract method with params as input values.

func (*BoundContract) Transfer

func (c *BoundContract) Transfer(opts *TransactOpts) (*Transaction, error)

Transfer initiates a plain transaction to move funds to the contract, calling its default method if one is available.

type CallMsg

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

CallMsg contains parameters for contract calls.

func NewCallMsg

func NewCallMsg() *CallMsg

NewCallMsg creates an empty contract call parameter list.

func (*CallMsg) GetData

func (msg *CallMsg) GetData() []byte

func (*CallMsg) GetFrom

func (msg *CallMsg) GetFrom() *Address

func (*CallMsg) GetGas

func (msg *CallMsg) GetGas() int64

func (*CallMsg) GetGasPrice

func (msg *CallMsg) GetGasPrice() *BigInt

func (*CallMsg) GetTo

func (msg *CallMsg) GetTo() *Address

func (*CallMsg) GetValue

func (msg *CallMsg) GetValue() *BigInt

func (*CallMsg) SetData

func (msg *CallMsg) SetData(data []byte)

func (*CallMsg) SetFrom

func (msg *CallMsg) SetFrom(address *Address)

func (*CallMsg) SetGas

func (msg *CallMsg) SetGas(gas int64)

func (*CallMsg) SetGasPrice

func (msg *CallMsg) SetGasPrice(price *BigInt)

func (*CallMsg) SetTo

func (msg *CallMsg) SetTo(address *Address)

func (*CallMsg) SetValue

func (msg *CallMsg) SetValue(value *BigInt)

type CallOpts

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

CallOpts is the collection of options to fine tune a contract call request.

func NewCallOpts

func NewCallOpts() *CallOpts

NewCallOpts creates a new option set for contract calls.

func (*CallOpts) GetGasLimit

func (opts *CallOpts) GetGasLimit() int64

func (*CallOpts) IsPending

func (opts *CallOpts) IsPending() bool

func (*CallOpts) SetContext

func (opts *CallOpts) SetContext(context *Context)

func (*CallOpts) SetGasLimit

func (opts *CallOpts) SetGasLimit(limit int64)

func (*CallOpts) SetPending

func (opts *CallOpts) SetPending(pending bool)

type ChainConfig

type ChainConfig struct {
	ChainID        int64 // Chain ID for replay protection
	HomesteadBlock int64 // Homestead switch block
	DAOForkBlock   int64 // TheDAO hard-fork switch block
	DAOForkSupport bool  // Whether the nodes supports or opposes the DAO hard-fork
	EIP150Block    int64 // Homestead gas reprice switch block
	EIP150Hash     Hash  // Homestead gas reprice switch block hash
	EIP155Block    int64 // Replay protection switch block
	EIP158Block    int64 // Empty account pruning switch block
}

ChainConfig is the core config which determines the blockchain settings.

func MainnetChainConfig

func MainnetChainConfig() *ChainConfig

MainnetChainConfig returns the chain configurations for the main Ethereum network.

func NewChainConfig

func NewChainConfig() *ChainConfig

NewChainConfig creates a new chain configuration that transitions immediately to homestead and has no notion of the DAO fork (ideal for a private network).

func TestnetChainConfig

func TestnetChainConfig() *ChainConfig

TestnetChainConfig returns the chain configurations for the Ethereum test network.

type Context

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

Context carries a deadline, a cancelation signal, and other values across API boundaries.

func NewContext

func NewContext() *Context

NewContext returns a non-nil, empty Context. It is never canceled, has no values, and has no deadline. It is typically used by the main function, initialization, and tests, and as the top-level Context for incoming requests.

func (*Context) WithCancel

func (c *Context) WithCancel() *Context

WithCancel returns a copy of the original context with cancellation mechanism included.

Canceling this context releases resources associated with it, so code should call cancel as soon as the operations running in this Context complete.

func (*Context) WithDeadline

func (c *Context) WithDeadline(sec int64, nsec int64) *Context

WithDeadline returns a copy of the original context with the deadline adjusted to be no later than the specified time.

Canceling this context releases resources associated with it, so code should call cancel as soon as the operations running in this Context complete.

func (*Context) WithTimeout

func (c *Context) WithTimeout(nsec int64) *Context

WithTimeout returns a copy of the original context with the deadline adjusted to be no later than now + the duration specified.

Canceling this context releases resources associated with it, so code should call cancel as soon as the operations running in this Context complete.

type Enode

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

Enode represents a host on the network.

func NewEnode

func NewEnode(rawurl string) (*Enode, error)

NewEnode parses a node designator.

There are two basic forms of node designators

  • incomplete nodes, which only have the public key (node ID)
  • complete nodes, which contain the public key and IP/Port information

For incomplete nodes, the designator must look like one of these

enode://<hex node id>
<hex node id>

For complete nodes, the node ID is encoded in the username portion of the URL, separated from the host by an @ sign. The hostname can only be given as an IP address, DNS domain names are not allowed. The port in the host name section is the TCP listening port. If the TCP and UDP (discovery) ports differ, the UDP port is specified as query parameter "discport".

In the following example, the node URL describes a node with IP address 10.3.58.6, TCP listening port 30303 and UDP discovery port 30301.

enode://<hex node id>@10.3.58.6:30303?discport=30301

type Enodes

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

Enodes represents a slice of accounts.

func FoundationBootnodes

func FoundationBootnodes() *Enodes

FoundationBootnodes returns the enode URLs of the P2P bootstrap nodes operated by the foundation running the V5 discovery protocol.

func NewEnodes

func NewEnodes(size int) *Enodes

NewEnodes creates a slice of uninitialized enodes.

func NewEnodesEmpty

func NewEnodesEmpty() *Enodes

NewEnodesEmpty creates an empty slice of Enode values.

func (*Enodes) Append

func (e *Enodes) Append(enode *Enode)

Append adds a new enode element to the end of the slice.

func (*Enodes) Get

func (e *Enodes) Get(index int) (*Enode, error)

Get returns the enode at the given index from the slice.

func (*Enodes) Set

func (e *Enodes) Set(index int, enode *Enode) error

Set sets the enode at the given index in the slice.

func (*Enodes) Size

func (e *Enodes) Size() int

Size returns the number of enodes in the slice.

type EthereumClient

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

EthereumClient provides access to the Ethereum APIs.

func NewEthereumClient

func NewEthereumClient(rawurl string) (*EthereumClient, error)

NewEthereumClient connects a client to the given URL.

func (*EthereumClient) CallContract

func (ec *EthereumClient) CallContract(ctx *Context, msg *CallMsg, number int64) ([]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 <0, in which case the code is taken from the latest known block. Note that state from very old blocks might not be available.

func (*EthereumClient) EstimateGas

func (ec *EthereumClient) EstimateGas(ctx *Context, msg *CallMsg) (*BigInt, 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 (*EthereumClient) FilterLogs

func (ec *EthereumClient) FilterLogs(ctx *Context, query *FilterQuery) (*Logs, error)

FilterLogs executes a filter query.

func (*EthereumClient) GetBalanceAt

func (ec *EthereumClient) GetBalanceAt(ctx *Context, account *Address, number int64) (*BigInt, error)

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

func (*EthereumClient) GetBlockByHash

func (ec *EthereumClient) GetBlockByHash(ctx *Context, hash *Hash) (*Block, error)

GetBlockByHash returns the given full block.

func (*EthereumClient) GetBlockByNumber

func (ec *EthereumClient) GetBlockByNumber(ctx *Context, number int64) (*Block, error)

GetBlockByNumber returns a block from the current canonical chain. If number is <0, the latest known block is returned.

func (*EthereumClient) GetCodeAt

func (ec *EthereumClient) GetCodeAt(ctx *Context, account *Address, number int64) ([]byte, error)

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

func (*EthereumClient) GetHeaderByHash

func (ec *EthereumClient) GetHeaderByHash(ctx *Context, hash *Hash) (*Header, error)

GetHeaderByHash returns the block header with the given hash.

func (*EthereumClient) GetHeaderByNumber

func (ec *EthereumClient) GetHeaderByNumber(ctx *Context, number int64) (*Header, error)

GetHeaderByNumber returns a block header from the current canonical chain. If number is <0, the latest known header is returned.

func (*EthereumClient) GetNonceAt

func (ec *EthereumClient) GetNonceAt(ctx *Context, account *Address, number int64) (int64, error)

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

func (*EthereumClient) GetPendingBalanceAt

func (ec *EthereumClient) GetPendingBalanceAt(ctx *Context, account *Address) (*BigInt, error)

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

func (*EthereumClient) GetPendingCodeAt

func (ec *EthereumClient) GetPendingCodeAt(ctx *Context, account *Address) ([]byte, error)

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

func (*EthereumClient) GetPendingNonceAt

func (ec *EthereumClient) GetPendingNonceAt(ctx *Context, account *Address) (int64, error)

GetPendingNonceAt 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 (*EthereumClient) GetPendingStorageAt

func (ec *EthereumClient) GetPendingStorageAt(ctx *Context, account *Address, key *Hash) ([]byte, error)

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

func (*EthereumClient) GetPendingTransactionCount

func (ec *EthereumClient) GetPendingTransactionCount(ctx *Context) (int, error)

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

func (*EthereumClient) GetStorageAt

func (ec *EthereumClient) GetStorageAt(ctx *Context, account *Address, key *Hash, number int64) ([]byte, error)

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

func (*EthereumClient) GetTransactionByHash

func (ec *EthereumClient) GetTransactionByHash(ctx *Context, hash *Hash) (*Transaction, error)

GetTransactionByHash returns the transaction with the given hash.

func (*EthereumClient) GetTransactionCount

func (ec *EthereumClient) GetTransactionCount(ctx *Context, hash *Hash) (int, error)

GetTransactionCount returns the total number of transactions in the given block.

func (*EthereumClient) GetTransactionInBlock

func (ec *EthereumClient) GetTransactionInBlock(ctx *Context, hash *Hash, index int) (*Transaction, error)

GetTransactionInBlock returns a single transaction at index in the given block.

func (*EthereumClient) GetTransactionReceipt

func (ec *EthereumClient) GetTransactionReceipt(ctx *Context, hash *Hash) (*Receipt, error)

GetTransactionReceipt returns the receipt of a transaction by transaction hash. Note that the receipt is not available for pending transactions.

func (*EthereumClient) PendingCallContract

func (ec *EthereumClient) PendingCallContract(ctx *Context, msg *CallMsg) ([]byte, error)

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

func (*EthereumClient) SendTransaction

func (ec *EthereumClient) SendTransaction(ctx *Context, tx *Transaction) 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 (*EthereumClient) SubscribeFilterLogs

func (ec *EthereumClient) SubscribeFilterLogs(ctx *Context, query *FilterQuery, handler FilterLogsHandler, buffer int) (*Subscription, error)

SubscribeFilterLogs subscribes to the results of a streaming filter query.

func (*EthereumClient) SubscribeNewHead

func (ec *EthereumClient) SubscribeNewHead(ctx *Context, handler NewHeadHandler, buffer int) (*Subscription, error)

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

func (*EthereumClient) SuggestGasPrice

func (ec *EthereumClient) SuggestGasPrice(ctx *Context) (*BigInt, error)

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

func (*EthereumClient) SyncProgress

func (ec *EthereumClient) SyncProgress(ctx *Context) (*SyncProgress, error)

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

type FilterLogsHandler

type FilterLogsHandler interface {
	OnFilterLogs(log *Log)
	OnError(failure string)
}

FilterLogsHandler is a client-side subscription callback to invoke on events and subscription failure.

type FilterQuery

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

FilterQuery contains options for contact log filtering.

func NewFilterQuery

func NewFilterQuery() *FilterQuery

NewFilterQuery creates an empty filter query for contact log filtering.

func (*FilterQuery) GetAddresses

func (fq *FilterQuery) GetAddresses() *Addresses

func (*FilterQuery) GetFromBlock

func (fq *FilterQuery) GetFromBlock() *BigInt

func (*FilterQuery) GetToBlock

func (fq *FilterQuery) GetToBlock() *BigInt

func (*FilterQuery) GetTopics

func (fq *FilterQuery) GetTopics() *Topics

type Hash

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

Hash represents the 32 byte Keccak256 hash of arbitrary data.

func NewHashFromBytes

func NewHashFromBytes(hash []byte) (*Hash, error)

NewHashFromBytes converts a slice of bytes to a hash value.

func NewHashFromHex

func NewHashFromHex(hash string) (*Hash, error)

NewHashFromHex converts a hex string to a hash value.

func (*Hash) GetBytes

func (h *Hash) GetBytes() []byte

GetBytes retrieves the byte representation of the hash.

func (*Hash) GetHex

func (h *Hash) GetHex() string

GetHex retrieves the hex string representation of the hash.

func (*Hash) SetBytes

func (h *Hash) SetBytes(hash []byte) error

SetBytes sets the specified slice of bytes as the hash value.

func (*Hash) SetHex

func (h *Hash) SetHex(hash string) error

SetHex sets the specified hex string as the hash value.

type Hashes

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

Hashes represents a slice of hashes.

func (*Hashes) Get

func (h *Hashes) Get(index int) (*Hash, error)

Get returns the hash at the given index from the slice.

func (*Hashes) Size

func (h *Hashes) Size() int

Size returns the number of hashes in the slice.

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

Header represents a block header in the Ethereum blockchain.

func (*Header) GetBloom

func (h *Header) GetBloom() *Bloom

func (*Header) GetCoinbase

func (h *Header) GetCoinbase() *Address

func (*Header) GetDifficulty

func (h *Header) GetDifficulty() *BigInt

func (*Header) GetExtra

func (h *Header) GetExtra() []byte

func (*Header) GetGasLimit

func (h *Header) GetGasLimit() int64

func (*Header) GetGasUsed

func (h *Header) GetGasUsed() int64

func (*Header) GetHash

func (h *Header) GetHash() *Hash

func (*Header) GetHashNoNonce

func (h *Header) GetHashNoNonce() *Hash

func (*Header) GetMixDigest

func (h *Header) GetMixDigest() *Hash

func (*Header) GetNonce

func (h *Header) GetNonce() *Nonce

func (*Header) GetNumber

func (h *Header) GetNumber() int64

func (*Header) GetParentHash

func (h *Header) GetParentHash() *Hash

func (*Header) GetReceiptHash

func (h *Header) GetReceiptHash() *Hash

func (*Header) GetRoot

func (h *Header) GetRoot() *Hash

func (*Header) GetTime

func (h *Header) GetTime() int64

func (*Header) GetTxHash

func (h *Header) GetTxHash() *Hash

func (*Header) GetUncleHash

func (h *Header) GetUncleHash() *Hash

type Headers

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

Headers represents a slice of headers.

func (*Headers) Get

func (h *Headers) Get(index int) (*Header, error)

Get returns the header at the given index from the slice.

func (*Headers) Size

func (h *Headers) Size() int

Size returns the number of headers in the slice.

type Interface

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

Interface represents a wrapped version of Go's interface{}, with the capacity to store arbitrary data types.

Since it's impossible to get the arbitrary-ness converted between Go and mobile platforms, we're using explicit getters and setters for the conversions. There is of course no point in enumerating everything, just enough to support the contract bindins requiring client side generated code.

func NewInterface

func NewInterface() *Interface

NewInterface creates a new empty interface that can be used to pass around generic types.

func (*Interface) GetAddress

func (i *Interface) GetAddress() *Address

func (*Interface) GetAddresses

func (i *Interface) GetAddresses() *Addresses

func (*Interface) GetBigInt

func (i *Interface) GetBigInt() *BigInt

func (*Interface) GetBigInts

func (i *Interface) GetBigInts() *BigInts

func (*Interface) GetBinaries

func (i *Interface) GetBinaries() [][]byte

func (*Interface) GetBinary

func (i *Interface) GetBinary() []byte

func (*Interface) GetBool

func (i *Interface) GetBool() bool

func (*Interface) GetBools

func (i *Interface) GetBools() []bool

func (*Interface) GetHash

func (i *Interface) GetHash() *Hash

func (*Interface) GetHashes

func (i *Interface) GetHashes() *Hashes

func (*Interface) GetInt16

func (i *Interface) GetInt16() int16

func (*Interface) GetInt32

func (i *Interface) GetInt32() int32

func (*Interface) GetInt64

func (i *Interface) GetInt64() int64

func (*Interface) GetInt8

func (i *Interface) GetInt8() int8

func (*Interface) GetString

func (i *Interface) GetString() string

func (*Interface) GetStrings

func (i *Interface) GetStrings() *Strings

func (*Interface) GetUint16

func (i *Interface) GetUint16() *BigInt

func (*Interface) GetUint32

func (i *Interface) GetUint32() *BigInt

func (*Interface) GetUint64

func (i *Interface) GetUint64() *BigInt

func (*Interface) GetUint8

func (i *Interface) GetUint8() *BigInt

func (*Interface) SetAddress

func (i *Interface) SetAddress(address *Address)

func (*Interface) SetAddresses

func (i *Interface) SetAddresses(addrs *Addresses)

func (*Interface) SetBigInt

func (i *Interface) SetBigInt(bigint *BigInt)

func (*Interface) SetBigInts

func (i *Interface) SetBigInts(bigints *BigInts)

func (*Interface) SetBinaries

func (i *Interface) SetBinaries(binaries [][]byte)

func (*Interface) SetBinary

func (i *Interface) SetBinary(binary []byte)

func (*Interface) SetBool

func (i *Interface) SetBool(b bool)

func (*Interface) SetBools

func (i *Interface) SetBools(bs []bool)

func (*Interface) SetDefaultAddress

func (i *Interface) SetDefaultAddress()

func (*Interface) SetDefaultAddresses

func (i *Interface) SetDefaultAddresses()

func (*Interface) SetDefaultBigInt

func (i *Interface) SetDefaultBigInt()

func (*Interface) SetDefaultBigInts

func (i *Interface) SetDefaultBigInts()

func (*Interface) SetDefaultBinaries

func (i *Interface) SetDefaultBinaries()

func (*Interface) SetDefaultBinary

func (i *Interface) SetDefaultBinary()

func (*Interface) SetDefaultBool

func (i *Interface) SetDefaultBool()

func (*Interface) SetDefaultBools

func (i *Interface) SetDefaultBools()

func (*Interface) SetDefaultHash

func (i *Interface) SetDefaultHash()

func (*Interface) SetDefaultHashes

func (i *Interface) SetDefaultHashes()

func (*Interface) SetDefaultInt16

func (i *Interface) SetDefaultInt16()

func (*Interface) SetDefaultInt32

func (i *Interface) SetDefaultInt32()

func (*Interface) SetDefaultInt64

func (i *Interface) SetDefaultInt64()

func (*Interface) SetDefaultInt8

func (i *Interface) SetDefaultInt8()

func (*Interface) SetDefaultString

func (i *Interface) SetDefaultString()

func (*Interface) SetDefaultStrings

func (i *Interface) SetDefaultStrings()

func (*Interface) SetDefaultUint16

func (i *Interface) SetDefaultUint16()

func (*Interface) SetDefaultUint32

func (i *Interface) SetDefaultUint32()

func (*Interface) SetDefaultUint64

func (i *Interface) SetDefaultUint64()

func (*Interface) SetDefaultUint8

func (i *Interface) SetDefaultUint8()

func (*Interface) SetHash

func (i *Interface) SetHash(hash *Hash)

func (*Interface) SetHashes

func (i *Interface) SetHashes(hashes *Hashes)

func (*Interface) SetInt16

func (i *Interface) SetInt16(n int16)

func (*Interface) SetInt32

func (i *Interface) SetInt32(n int32)

func (*Interface) SetInt64

func (i *Interface) SetInt64(n int64)

func (*Interface) SetInt8

func (i *Interface) SetInt8(n int8)

func (*Interface) SetString

func (i *Interface) SetString(str string)

func (*Interface) SetStrings

func (i *Interface) SetStrings(strs *Strings)

func (*Interface) SetUint16

func (i *Interface) SetUint16(bigint *BigInt)

func (*Interface) SetUint32

func (i *Interface) SetUint32(bigint *BigInt)

func (*Interface) SetUint64

func (i *Interface) SetUint64(bigint *BigInt)

func (*Interface) SetUint8

func (i *Interface) SetUint8(bigint *BigInt)

type Interfaces

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

Interfaces is a slices of wrapped generic objects.

func NewInterfaces

func NewInterfaces(size int) *Interfaces

NewInterfaces creates a slice of uninitialized interfaces.

func (*Interfaces) Get

func (i *Interfaces) Get(index int) (*Interface, error)

Get returns the bigint at the given index from the slice.

func (*Interfaces) Set

func (i *Interfaces) Set(index int, object *Interface) error

Set sets the big int at the given index in the slice.

func (*Interfaces) Size

func (i *Interfaces) Size() int

Size returns the number of interfaces in the slice.

type Log

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

Log represents a contract log event. These events are generated by the LOG opcode and stored/indexed by the node.

func (*Log) GetAddress

func (l *Log) GetAddress() *Address

func (*Log) GetBlockHash

func (l *Log) GetBlockHash() *Hash

func (*Log) GetBlockNumber

func (l *Log) GetBlockNumber() int64

func (*Log) GetData

func (l *Log) GetData() []byte

func (*Log) GetIndex

func (l *Log) GetIndex() int

func (*Log) GetTopics

func (l *Log) GetTopics() *Hashes

func (*Log) GetTxHash

func (l *Log) GetTxHash() *Hash

func (*Log) GetTxIndex

func (l *Log) GetTxIndex() int

type Logs

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

Logs represents a slice of VM logs.

func (*Logs) Get

func (l *Logs) Get(index int) (*Log, error)

Get returns the log at the given index from the slice.

func (*Logs) Size

func (l *Logs) Size() int

Size returns the number of logs in the slice.

type NewHeadHandler

type NewHeadHandler interface {
	OnNewHead(header *Header)
	OnError(failure string)
}

NewHeadHandler is a client-side subscription callback to invoke on events and subscription failure.

type Node

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

Node represents a Geth Ethereum node instance.

func NewNode

func NewNode(datadir string, config *NodeConfig) (*Node, error)

NewNode creates and configures a new Geth node.

func (*Node) GetEthereumClient

func (n *Node) GetEthereumClient() (*EthereumClient, error)

GetEthereumClient retrieves a client to access the Ethereum subsystem.

func (*Node) GetNodeInfo

func (n *Node) GetNodeInfo() *NodeInfo

GetNodeInfo gathers and returns a collection of metadata known about the host.

func (*Node) GetPeersInfo

func (n *Node) GetPeersInfo() *PeerInfos

GetPeersInfo returns an array of metadata objects describing connected peers.

func (*Node) Start

func (n *Node) Start() error

Start creates a live P2P node and starts running it.

func (*Node) Stop

func (n *Node) Stop() error

Stop terminates a running node along with all it's services. In the node was not started, an error is returned.

type NodeConfig

type NodeConfig struct {
	// Bootstrap nodes used to establish connectivity with the rest of the network.
	BootstrapNodes *Enodes

	// MaxPeers is the maximum number of peers that can be connected. If this is
	// set to zero, then only the configured static and trusted peers can connect.
	MaxPeers int

	// EthereumEnabled specifies whether the node should run the Ethereum protocol.
	EthereumEnabled bool

	// EthereumNetworkID is the network identifier used by the Ethereum protocol to
	// decide if remote peers should be accepted or not.
	EthereumNetworkID int

	// EthereumChainConfig is the default parameters of the blockchain to use. If no
	// configuration is specified, it defaults to the main network.
	EthereumChainConfig *ChainConfig

	// EthereumGenesis is the genesis JSON to use to seed the blockchain with. An
	// empty genesis state is equivalent to using the mainnet's state.
	EthereumGenesis string

	// EthereumTestnetNonces specifies whether to use account nonces from the testnet
	// range (2^20) or from the mainnet one (0).
	EthereumTestnetNonces bool

	// EthereumDatabaseCache is the system memory in MB to allocate for database caching.
	// A minimum of 16MB is always reserved.
	EthereumDatabaseCache int

	// WhisperEnabled specifies whether the node should run the Whisper protocol.
	WhisperEnabled bool
}

NodeConfig represents the collection of configuration values to fine tune the Geth node embedded into a mobile process. The available values are a subset of the entire API provided by go-ethereum to reduce the maintenance surface and dev complexity.

func NewNodeConfig

func NewNodeConfig() *NodeConfig

NewNodeConfig creates a new node option set, initialized to the default values.

type NodeInfo

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

NodeInfo represents pi short summary of the information known about the host.

func (*NodeInfo) GetDiscoveryPort

func (ni *NodeInfo) GetDiscoveryPort() int

func (*NodeInfo) GetEnode

func (ni *NodeInfo) GetEnode() string

func (*NodeInfo) GetID

func (ni *NodeInfo) GetID() string

func (*NodeInfo) GetIP

func (ni *NodeInfo) GetIP() string

func (*NodeInfo) GetListenerAddress

func (ni *NodeInfo) GetListenerAddress() string

func (*NodeInfo) GetListenerPort

func (ni *NodeInfo) GetListenerPort() int

func (*NodeInfo) GetName

func (ni *NodeInfo) GetName() string

func (*NodeInfo) GetProtocols

func (ni *NodeInfo) GetProtocols() *Strings

type Nonce

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

A Nonce is a 64-bit hash which proves (combined with the mix-hash) that a sufficient amount of computation has been carried out on a block.

func (*Nonce) GetBytes

func (n *Nonce) GetBytes() []byte

GetBytes retrieves the byte representation of the block nonce.

func (*Nonce) GetHex

func (n *Nonce) GetHex() string

GetHex retrieves the hex string representation of the block nonce.

type PeerInfo

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

PeerInfo represents pi short summary of the information known about pi connected peer.

func (*PeerInfo) GetCaps

func (pi *PeerInfo) GetCaps() *Strings

func (*PeerInfo) GetID

func (pi *PeerInfo) GetID() string

func (*PeerInfo) GetLocalAddress

func (pi *PeerInfo) GetLocalAddress() string

func (*PeerInfo) GetName

func (pi *PeerInfo) GetName() string

func (*PeerInfo) GetRemoteAddress

func (pi *PeerInfo) GetRemoteAddress() string

type PeerInfos

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

PeerInfos represents a slice of infos about remote peers.

func (*PeerInfos) Get

func (pi *PeerInfos) Get(index int) (*PeerInfo, error)

Get returns the peer info at the given index from the slice.

func (*PeerInfos) Size

func (pi *PeerInfos) Size() int

Size returns the number of peer info entries in the slice.

type Receipt

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

Receipt represents the results of a transaction.

func (*Receipt) GetBloom

func (r *Receipt) GetBloom() *Bloom

func (*Receipt) GetContractAddress

func (r *Receipt) GetContractAddress() *Address

func (*Receipt) GetCumulativeGasUsed

func (r *Receipt) GetCumulativeGasUsed() *BigInt

func (*Receipt) GetGasUsed

func (r *Receipt) GetGasUsed() *BigInt

func (*Receipt) GetLogs

func (r *Receipt) GetLogs() *Logs

func (*Receipt) GetPostState

func (r *Receipt) GetPostState() []byte

func (*Receipt) GetTxHash

func (r *Receipt) GetTxHash() *Hash

type Signer

type Signer interface {
	Sign(*Address, *Transaction) (*Transaction, error)
}

Signer is an interaface defining the callback when a contract requires a method to sign the transaction before submission.

type Strings

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

Strings represents s slice of strs.

func (*Strings) Get

func (s *Strings) Get(index int) (string, error)

Get returns the string at the given index from the slice.

func (*Strings) Set

func (s *Strings) Set(index int, str string) error

Set sets the string at the given index in the slice.

func (*Strings) Size

func (s *Strings) Size() int

Size returns the number of strs in the slice.

func (*Strings) String

func (s *Strings) String() string

String implements the Stringer interface.

type Subscription

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

Subscription represents an event subscription where events are delivered on a data channel.

func (*Subscription) Unsubscribe

func (s *Subscription) Unsubscribe()

Unsubscribe cancels the sending of events to the data channel and closes the error channel.

type SyncProgress

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

SyncProgress gives progress indications when the node is synchronising with the Ethereum network.

func (*SyncProgress) GetCurrentBlock

func (p *SyncProgress) GetCurrentBlock() int64

func (*SyncProgress) GetHighestBlock

func (p *SyncProgress) GetHighestBlock() int64

func (*SyncProgress) GetKnownStates

func (p *SyncProgress) GetKnownStates() int64

func (*SyncProgress) GetPulledStates

func (p *SyncProgress) GetPulledStates() int64

func (*SyncProgress) GetStartingBlock

func (p *SyncProgress) GetStartingBlock() int64

type Topics

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

Topics is a set of topic lists to filter events with.

func (*Topics) Get

func (t *Topics) Get(index int) (*Hashes, error)

Get returns the topic list at the given index from the slice.

func (*Topics) Set

func (t *Topics) Set(index int, topics *Hashes) error

Set sets the topic list at the given index in the slice.

func (*Topics) Size

func (t *Topics) Size() int

Size returns the number of topic lists inside the set

type TransactOpts

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

TransactOpts is the collection of authorization data required to create a valid Ethereum transaction.

func (*TransactOpts) GetFrom

func (opts *TransactOpts) GetFrom() *Address

func (*TransactOpts) GetGasLimit

func (opts *TransactOpts) GetGasLimit() int64

func (*TransactOpts) GetGasPrice

func (opts *TransactOpts) GetGasPrice() *BigInt

func (*TransactOpts) GetNonce

func (opts *TransactOpts) GetNonce() int64

func (*TransactOpts) GetValue

func (opts *TransactOpts) GetValue() *BigInt

func (*TransactOpts) SetContext

func (opts *TransactOpts) SetContext(context *Context)

func (*TransactOpts) SetFrom

func (opts *TransactOpts) SetFrom(from *Address)

func (*TransactOpts) SetGasLimit

func (opts *TransactOpts) SetGasLimit(limit int64)

func (*TransactOpts) SetGasPrice

func (opts *TransactOpts) SetGasPrice(price *BigInt)

func (*TransactOpts) SetNonce

func (opts *TransactOpts) SetNonce(nonce int64)

func (*TransactOpts) SetSigner

func (opts *TransactOpts) SetSigner(s Signer)

func (*TransactOpts) SetValue

func (opts *TransactOpts) SetValue(value *BigInt)

type Transaction

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

Transaction represents a single Ethereum transaction.

func (*Transaction) GetCost

func (tx *Transaction) GetCost() *BigInt

func (*Transaction) GetData

func (tx *Transaction) GetData() []byte

func (*Transaction) GetFrom

func (tx *Transaction) GetFrom() (*Address, error)

func (*Transaction) GetGas

func (tx *Transaction) GetGas() int64

func (*Transaction) GetGasPrice

func (tx *Transaction) GetGasPrice() *BigInt

func (*Transaction) GetHash

func (tx *Transaction) GetHash() *Hash

func (*Transaction) GetNonce

func (tx *Transaction) GetNonce() int64

func (*Transaction) GetSigHash

func (tx *Transaction) GetSigHash() *Hash

func (*Transaction) GetTo

func (tx *Transaction) GetTo() *Address

func (*Transaction) GetValue

func (tx *Transaction) GetValue() *BigInt

func (*Transaction) WithSignature

func (tx *Transaction) WithSignature(sig []byte) (*Transaction, error)

type Transactions

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

Transactions represents a slice of transactions.

func (*Transactions) Get

func (t *Transactions) Get(index int) (*Transaction, error)

Get returns the transaction at the given index from the slice.

func (*Transactions) Size

func (t *Transactions) Size() int

Size returns the number of transactions in the slice.

Jump to

Keyboard shortcuts

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