Documentation ¶
Overview ¶
Package geth contains the simplified mobile APIs to go-ethereum.
The scope of this package is *not* to allow writing a custom Ethereum 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 meaningfully 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.
If a method has multiple return values (e.g. some return + an error), those are generated as output arguments in ObjC. To avoid weird generated names like ret_0 for them, please always assign names to output variables if tuples.
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
- func AlfajoresGenesis() string
- func BaklavaGenesis() string
- func DecodeFromHex(s string) ([]byte, error)
- func EncodeToHex(b []byte) string
- func MainnetGenesis() string
- func SendLogsToFile(filename string, level int, format string) bool
- func SetVerbosity(level int)
- type Account
- type Accounts
- type Address
- type Addresses
- type BigInt
- func (bi *BigInt) GetBytes() []byte
- func (bi *BigInt) GetInt64() int64
- func (bi *BigInt) GetString(base int) string
- func (bi *BigInt) SetBytes(buf []byte)
- func (bi *BigInt) SetInt64(x int64)
- func (bi *BigInt) SetString(x string, base int)
- func (bi *BigInt) Sign() int
- func (bi *BigInt) String() string
- type BigInts
- type Binaries
- type Block
- func (b *Block) EncodeJSON() (string, error)
- func (b *Block) EncodeRLP() ([]byte, error)
- func (b *Block) GetBloom() *Bloom
- func (b *Block) GetCoinbase() *Address
- func (b *Block) GetExtra() []byte
- func (b *Block) GetGasUsed() int64
- func (b *Block) GetHash() *Hash
- func (b *Block) GetHeader() *Header
- func (b *Block) GetNumber() int64
- func (b *Block) GetParentHash() *Hash
- func (b *Block) GetReceiptHash() *Hash
- func (b *Block) GetRoot() *Hash
- func (b *Block) GetTime() int64
- func (b *Block) GetTransaction(hash *Hash) *Transaction
- func (b *Block) GetTransactions() *Transactions
- func (b *Block) GetTxHash() *Hash
- type Bloom
- type Bools
- type BoundContract
- func (c *BoundContract) Call(opts *CallOpts, out *Interfaces, method string, args *Interfaces) error
- func (c *BoundContract) GetAddress() *Address
- func (c *BoundContract) GetDeployer() *Transaction
- func (c *BoundContract) RawTransact(opts *TransactOpts, calldata []byte) (tx *Transaction, _ error)
- func (c *BoundContract) Transact(opts *TransactOpts, method string, args *Interfaces) (tx *Transaction, _ error)
- func (c *BoundContract) Transfer(opts *TransactOpts) (tx *Transaction, _ error)
- type CallMsg
- func (msg *CallMsg) GetData() []byte
- func (msg *CallMsg) GetFrom() *Address
- func (msg *CallMsg) GetGas() int64
- func (msg *CallMsg) GetGasPrice() *BigInt
- func (msg *CallMsg) GetTo() *Address
- func (msg *CallMsg) GetValue() *BigInt
- func (msg *CallMsg) SetData(data []byte)
- func (msg *CallMsg) SetFrom(address *Address)
- func (msg *CallMsg) SetGas(gas int64)
- func (msg *CallMsg) SetGasPrice(price *BigInt)
- func (msg *CallMsg) SetTo(address *Address)
- func (msg *CallMsg) SetValue(value *BigInt)
- type CallOpts
- type Context
- type Criteria
- func (c *Criteria) GetMinPow() float64
- func (c *Criteria) GetPrivateKeyID() string
- func (c *Criteria) GetSig() []byte
- func (c *Criteria) GetSymKeyID() string
- func (c *Criteria) SetMinPow(pow float64)
- func (c *Criteria) SetPrivateKeyID(privateKeyID string)
- func (c *Criteria) SetSig(sig []byte)
- func (c *Criteria) SetSymKeyID(symKeyID string)
- type Enode
- type Enodes
- type EthereumClient
- func (ec *EthereumClient) CallContract(ctx *Context, msg *CallMsg, number int64) (output []byte, _ error)
- func (ec *EthereumClient) EstimateGas(ctx *Context, msg *CallMsg) (gas int64, _ error)
- func (ec *EthereumClient) FilterLogs(ctx *Context, query *FilterQuery) (logs *Logs, _ error)
- func (ec *EthereumClient) GetBalanceAt(ctx *Context, account *Address, number int64) (balance *BigInt, _ error)
- func (ec *EthereumClient) GetBlockByHash(ctx *Context, hash *Hash) (block *Block, _ error)
- func (ec *EthereumClient) GetBlockByNumber(ctx *Context, number int64) (block *Block, _ error)
- func (ec *EthereumClient) GetCodeAt(ctx *Context, account *Address, number int64) (code []byte, _ error)
- func (ec *EthereumClient) GetHeaderByHash(ctx *Context, hash *Hash) (header *Header, _ error)
- func (ec *EthereumClient) GetHeaderByNumber(ctx *Context, number int64) (header *Header, _ error)
- func (ec *EthereumClient) GetNonceAt(ctx *Context, account *Address, number int64) (nonce int64, _ error)
- func (ec *EthereumClient) GetPendingBalanceAt(ctx *Context, account *Address) (balance *BigInt, _ error)
- func (ec *EthereumClient) GetPendingCodeAt(ctx *Context, account *Address) (code []byte, _ error)
- func (ec *EthereumClient) GetPendingNonceAt(ctx *Context, account *Address) (nonce int64, _ error)
- func (ec *EthereumClient) GetPendingStorageAt(ctx *Context, account *Address, key *Hash) (storage []byte, _ error)
- func (ec *EthereumClient) GetPendingTransactionCount(ctx *Context) (count int, _ error)
- func (ec *EthereumClient) GetStorageAt(ctx *Context, account *Address, key *Hash, number int64) (storage []byte, _ error)
- func (ec *EthereumClient) GetTransactionByHash(ctx *Context, hash *Hash) (tx *Transaction, _ error)
- func (ec *EthereumClient) GetTransactionCount(ctx *Context, hash *Hash) (count int, _ error)
- func (ec *EthereumClient) GetTransactionInBlock(ctx *Context, hash *Hash, index int) (tx *Transaction, _ error)
- func (ec *EthereumClient) GetTransactionReceipt(ctx *Context, hash *Hash) (receipt *Receipt, _ error)
- func (ec *EthereumClient) GetTransactionSender(ctx *Context, tx *Transaction, blockhash *Hash, index int) (sender *Address, _ error)
- func (ec *EthereumClient) PendingCallContract(ctx *Context, msg *CallMsg) (output []byte, _ error)
- func (ec *EthereumClient) SendTransaction(ctx *Context, tx *Transaction) error
- func (ec *EthereumClient) SubscribeFilterLogs(ctx *Context, query *FilterQuery, handler FilterLogsHandler, buffer int) (sub *Subscription, _ error)
- func (ec *EthereumClient) SubscribeNewHead(ctx *Context, handler NewHeadHandler, buffer int) (sub *Subscription, _ error)
- func (ec *EthereumClient) SuggestGasPrice(ctx *Context) (price *BigInt, _ error)
- func (ec *EthereumClient) SyncProgress(ctx *Context) (progress *SyncProgress, _ error)
- type FilterLogsHandler
- type FilterQuery
- func (fq *FilterQuery) GetAddresses() *Addresses
- func (fq *FilterQuery) GetFromBlock() *BigInt
- func (fq *FilterQuery) GetToBlock() *BigInt
- func (fq *FilterQuery) GetTopics() *Topics
- func (fq *FilterQuery) SetAddresses(addresses *Addresses)
- func (fq *FilterQuery) SetFromBlock(fromBlock *BigInt)
- func (fq *FilterQuery) SetToBlock(toBlock *BigInt)
- func (fq *FilterQuery) SetTopics(topics *Topics)
- type Hash
- type Hashes
- type Header
- func (h *Header) EncodeJSON() (string, error)
- func (h *Header) EncodeRLP() ([]byte, error)
- func (h *Header) GetBloom() *Bloom
- func (h *Header) GetCoinbase() *Address
- func (h *Header) GetExtra() []byte
- func (h *Header) GetGasUsed() int64
- func (h *Header) GetHash() *Hash
- func (h *Header) GetNumber() int64
- func (h *Header) GetParentHash() *Hash
- func (h *Header) GetReceiptHash() *Hash
- func (h *Header) GetRoot() *Hash
- func (h *Header) GetTime() int64
- func (h *Header) GetTxHash() *Hash
- type Headers
- type Info
- type Interface
- func (i *Interface) GetAddress() *Address
- func (i *Interface) GetAddresses() *Addresses
- func (i *Interface) GetBigInt() *BigInt
- func (i *Interface) GetBigInts() *BigInts
- func (i *Interface) GetBinaries() *Binaries
- func (i *Interface) GetBinary() []byte
- func (i *Interface) GetBool() bool
- func (i *Interface) GetBools() *Bools
- func (i *Interface) GetHash() *Hash
- func (i *Interface) GetHashes() *Hashes
- func (i *Interface) GetInt16() int16
- func (i *Interface) GetInt16s() *BigInts
- func (i *Interface) GetInt32() int32
- func (i *Interface) GetInt32s() *BigInts
- func (i *Interface) GetInt64() int64
- func (i *Interface) GetInt64s() *BigInts
- func (i *Interface) GetInt8() int8
- func (i *Interface) GetInt8s() *BigInts
- func (i *Interface) GetString() string
- func (i *Interface) GetStrings() *Strings
- func (i *Interface) GetUint16() *BigInt
- func (i *Interface) GetUint16s() *BigInts
- func (i *Interface) GetUint32() *BigInt
- func (i *Interface) GetUint32s() *BigInts
- func (i *Interface) GetUint64() *BigInt
- func (i *Interface) GetUint64s() *BigInts
- func (i *Interface) GetUint8() *BigInt
- func (i *Interface) GetUint8s() *BigInts
- func (i *Interface) SetAddress(address *Address)
- func (i *Interface) SetAddresses(addrs *Addresses)
- func (i *Interface) SetBigInt(bigint *BigInt)
- func (i *Interface) SetBigInts(bigints *BigInts)
- func (i *Interface) SetBinaries(binaries *Binaries)
- func (i *Interface) SetBinary(binary []byte)
- func (i *Interface) SetBool(b bool)
- func (i *Interface) SetBools(bs *Bools)
- func (i *Interface) SetDefaultAddress()
- func (i *Interface) SetDefaultAddresses()
- func (i *Interface) SetDefaultBigInt()
- func (i *Interface) SetDefaultBigInts()
- func (i *Interface) SetDefaultBinaries()
- func (i *Interface) SetDefaultBinary()
- func (i *Interface) SetDefaultBool()
- func (i *Interface) SetDefaultBools()
- func (i *Interface) SetDefaultHash()
- func (i *Interface) SetDefaultHashes()
- func (i *Interface) SetDefaultInt16()
- func (i *Interface) SetDefaultInt16s()
- func (i *Interface) SetDefaultInt32()
- func (i *Interface) SetDefaultInt32s()
- func (i *Interface) SetDefaultInt64()
- func (i *Interface) SetDefaultInt64s()
- func (i *Interface) SetDefaultInt8()
- func (i *Interface) SetDefaultInt8s()
- func (i *Interface) SetDefaultString()
- func (i *Interface) SetDefaultStrings()
- func (i *Interface) SetDefaultUint16()
- func (i *Interface) SetDefaultUint16s()
- func (i *Interface) SetDefaultUint32()
- func (i *Interface) SetDefaultUint32s()
- func (i *Interface) SetDefaultUint64()
- func (i *Interface) SetDefaultUint64s()
- func (i *Interface) SetDefaultUint8()
- func (i *Interface) SetDefaultUint8s()
- func (i *Interface) SetHash(hash *Hash)
- func (i *Interface) SetHashes(hashes *Hashes)
- func (i *Interface) SetInt16(n int16)
- func (i *Interface) SetInt16s(bigints *BigInts)
- func (i *Interface) SetInt32(n int32)
- func (i *Interface) SetInt32s(bigints *BigInts)
- func (i *Interface) SetInt64(n int64)
- func (i *Interface) SetInt64s(bigints *BigInts)
- func (i *Interface) SetInt8(n int8)
- func (i *Interface) SetInt8s(bigints *BigInts)
- func (i *Interface) SetString(str string)
- func (i *Interface) SetStrings(strs *Strings)
- func (i *Interface) SetUint16(bigint *BigInt)
- func (i *Interface) SetUint16s(bigints *BigInts)
- func (i *Interface) SetUint32(bigint *BigInt)
- func (i *Interface) SetUint32s(bigints *BigInts)
- func (i *Interface) SetUint64(bigint *BigInt)
- func (i *Interface) SetUint64s(bigints *BigInts)
- func (i *Interface) SetUint8(bigint *BigInt)
- func (i *Interface) SetUint8s(bigints *BigInts)
- type Interfaces
- type KeyStore
- func (ks *KeyStore) ComputeECDHSharedSecret(a *Account, publicKey []byte) ([]byte, error)
- func (ks *KeyStore) Decrypt(account *Account, cipher []byte) ([]byte, error)
- func (ks *KeyStore) DeleteAccount(account *Account, passphrase string) error
- func (ks *KeyStore) ExportKey(account *Account, passphrase, newPassphrase string) (key []byte, _ error)
- func (ks *KeyStore) GetAccounts() *Accounts
- func (ks *KeyStore) HasAddress(address *Address) bool
- func (ks *KeyStore) ImportECDSAKey(key []byte, passphrase string) (account *Account, _ error)
- func (ks *KeyStore) ImportKey(keyJSON []byte, passphrase, newPassphrase string) (account *Account, _ error)
- func (ks *KeyStore) ImportPreSaleKey(keyJSON []byte, passphrase string) (ccount *Account, _ error)
- func (ks *KeyStore) Lock(address *Address) error
- func (ks *KeyStore) NewAccount(passphrase string) (*Account, error)
- func (ks *KeyStore) SignHash(address *Address, hash []byte) (signature []byte, _ error)
- func (ks *KeyStore) SignHashPassphrase(account *Account, passphrase string, hash []byte) (signature []byte, _ error)
- func (ks *KeyStore) SignTx(account *Account, tx *Transaction, chainID *BigInt) (*Transaction, error)
- func (ks *KeyStore) SignTxPassphrase(account *Account, passphrase string, tx *Transaction, chainID *BigInt) (*Transaction, error)
- func (ks *KeyStore) SignTypedData(account *Account, typedDataJSON []byte) ([]byte, error)
- func (ks *KeyStore) TimedUnlock(account *Account, passphrase string, timeout int64) error
- func (ks *KeyStore) Unlock(account *Account, passphrase string) error
- func (ks *KeyStore) UpdateAccount(account *Account, passphrase, newPassphrase string) error
- type Log
- type Logs
- type Message
- type Messages
- type MobileSigner
- type NewHeadHandler
- type NewMessage
- func (nm *NewMessage) GetPayload() []byte
- func (nm *NewMessage) GetPowTarget() float64
- func (nm *NewMessage) GetPowTime() int64
- func (nm *NewMessage) GetPublicKey() []byte
- func (nm *NewMessage) GetSig() string
- func (nm *NewMessage) GetSymKeyID() string
- func (nm *NewMessage) GetTTL() int64
- func (nm *NewMessage) GetTargetPeer() string
- func (nm *NewMessage) GetTopic() []byte
- func (nm *NewMessage) SetPayload(payload []byte)
- func (nm *NewMessage) SetPowTarget(powTarget float64)
- func (nm *NewMessage) SetPowTime(powTime int64)
- func (nm *NewMessage) SetPublicKey(publicKey []byte)
- func (nm *NewMessage) SetSig(sig string)
- func (nm *NewMessage) SetSymKeyID(symKeyID string)
- func (nm *NewMessage) SetTTL(ttl int64)
- func (nm *NewMessage) SetTargetPeer(targetPeer string)
- func (nm *NewMessage) SetTopic(topic []byte)
- type NewMessageHandler
- type Node
- func (n *Node) Close() error
- func (n *Node) GetBlockchainStats(stats *Stats) error
- func (n *Node) GetEthereumClient() (client *EthereumClient, _ error)
- func (n *Node) GetGethStats() (*Stats, error)
- func (n *Node) GetNodeInfo() *NodeInfo
- func (n *Node) GetPeerInfos() *PeerInfos
- func (n *Node) Start() error
- func (n *Node) Stop() errordeprecated
- type NodeConfig
- type NodeInfo
- func (ni *NodeInfo) GetDiscoveryPort() int
- func (ni *NodeInfo) GetEnode() string
- func (ni *NodeInfo) GetID() string
- func (ni *NodeInfo) GetIP() string
- func (ni *NodeInfo) GetListenerAddress() string
- func (ni *NodeInfo) GetListenerPort() int
- func (ni *NodeInfo) GetName() string
- func (ni *NodeInfo) GetProtocols() *Strings
- type PeerInfo
- type PeerInfos
- type Receipt
- func (r *Receipt) EncodeJSON() (string, error)
- func (r *Receipt) EncodeRLP() ([]byte, error)
- func (r *Receipt) GetBloom() *Bloom
- func (r *Receipt) GetContractAddress() *Address
- func (r *Receipt) GetCumulativeGasUsed() int64
- func (r *Receipt) GetGasUsed() int64
- func (r *Receipt) GetLogs() *Logs
- func (r *Receipt) GetPostState() []byte
- func (r *Receipt) GetStatus() int
- func (r *Receipt) GetTxHash() *Hash
- type Signer
- type Stats
- func (s *Stats) GetStatsKeys() *Strings
- func (s *Stats) GetValue(key string) string
- func (stats *Stats) SetBool(name string, boolean bool)
- func (stats *Stats) SetFloat(name string, number float64)
- func (stats *Stats) SetInt(name string, number int64)
- func (stats *Stats) SetUInt(name string, number uint64)
- func (stats *Stats) SyncToRegistryStats()
- type Strings
- type Subscription
- type SyncProgress
- type Topics
- type TransactOpts
- func (opts *TransactOpts) GetFrom() *Address
- func (opts *TransactOpts) GetGasLimit() int64
- func (opts *TransactOpts) GetGasPrice() *BigInt
- func (opts *TransactOpts) GetNonce() int64
- func (opts *TransactOpts) GetValue() *BigInt
- func (opts *TransactOpts) SetContext(context *Context)
- func (opts *TransactOpts) SetFrom(from *Address)
- func (opts *TransactOpts) SetGasLimit(limit int64)
- func (opts *TransactOpts) SetGasPrice(price *BigInt)
- func (opts *TransactOpts) SetNonce(nonce int64)
- func (opts *TransactOpts) SetSigner(s Signer)
- func (opts *TransactOpts) SetValue(value *BigInt)
- type Transaction
- func NewContractCreation(nonce int64, amount *BigInt, gasLimit int64, gasPrice *BigInt, data []byte) *Transaction
- func NewTransaction(nonce int64, to *Address, amount *BigInt, gasLimit int64, gasPrice *BigInt, ...) *Transaction
- func NewTransactionFromJSON(data string) (*Transaction, error)
- func NewTransactionFromRLP(data []byte) (*Transaction, error)
- func (tx *Transaction) EncodeJSON() (string, error)
- func (tx *Transaction) EncodeRLP() ([]byte, error)
- func (tx *Transaction) GetCost() *BigInt
- func (tx *Transaction) GetData() []byte
- func (tx *Transaction) GetFrom(chainID *BigInt) (address *Address, _ error)deprecated
- func (tx *Transaction) GetGas() int64
- func (tx *Transaction) GetGasPrice() *BigInt
- func (tx *Transaction) GetHash() *Hash
- func (tx *Transaction) GetNonce() int64
- func (tx *Transaction) GetSigHash() *Hashdeprecated
- func (tx *Transaction) GetTo() *Address
- func (tx *Transaction) GetValue() *BigInt
- func (tx *Transaction) WithSignature(sig []byte, chainID *BigInt) (signedTx *Transaction, _ error)
- type Transactions
- type WhisperClient
- func (wc *WhisperClient) AddPrivateKey(ctx *Context, key []byte) (string, error)
- func (wc *WhisperClient) AddSymmetricKey(ctx *Context, key []byte) (string, error)
- func (wc *WhisperClient) DeleteKeyPair(ctx *Context, id string) (string, error)
- func (wc *WhisperClient) DeleteMessageFilter(ctx *Context, id string) error
- func (wc *WhisperClient) DeleteSymmetricKey(ctx *Context, id string) error
- func (wc *WhisperClient) GenerateSymmetricKeyFromPassword(ctx *Context, passwd string) (string, error)
- func (wc *WhisperClient) GetFilterMessages(ctx *Context, id string) (*Messages, error)
- func (wc *WhisperClient) GetInfo(ctx *Context) (info *Info, _ error)
- func (wc *WhisperClient) GetPrivateKey(ctx *Context, id string) ([]byte, error)
- func (wc *WhisperClient) GetPublicKey(ctx *Context, id string) ([]byte, error)
- func (wc *WhisperClient) GetSymmetricKey(ctx *Context, id string) ([]byte, error)
- func (wc *WhisperClient) GetVersion(ctx *Context) (version string, _ error)
- func (wc *WhisperClient) HasKeyPair(ctx *Context, id string) (bool, error)
- func (wc *WhisperClient) HasSymmetricKey(ctx *Context, id string) (bool, error)
- func (wc *WhisperClient) MarkTrustedPeer(ctx *Context, enode string) error
- func (wc *WhisperClient) NewKeyPair(ctx *Context) (string, error)
- func (wc *WhisperClient) NewMessageFilter(ctx *Context, criteria *Criteria) (string, error)
- func (wc *WhisperClient) NewSymmetricKey(ctx *Context) (string, error)
- func (wc *WhisperClient) Post(ctx *Context, message *NewMessage) (string, error)
- func (wc *WhisperClient) SetMaxMessageSize(ctx *Context, size int32) error
- func (wc *WhisperClient) SetMinimumPoW(ctx *Context, pow float64) error
- func (wc *WhisperClient) SubscribeMessages(ctx *Context, criteria *Criteria, handler NewMessageHandler, buffer int) (*Subscription, error)
Constants ¶
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(keystore.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(keystore.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(keystore.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(keystore.LightScryptP) )
const LightestSync = 5
const SyncModeDeprecatedSync = 4
Deprecated: This used to be SyncModeCeloLatestSync. Geth will panic if started in this mode. Use LightestSync instead.
const SyncModeFastSync = 2
const SyncModeFullSync = 1
const SyncModeLightSync = 3
const SyncModeUnset = 0 // will be treated as SyncModeLightSync
I am intentionally duplicating these constants different from downloader.SyncMode integer values, to ensure the backwards compatibility where the mobile node defaults to LightSync.
Variables ¶
This section is empty.
Functions ¶
func AlfajoresGenesis ¶
func AlfajoresGenesis() string
func BaklavaGenesis ¶
func BaklavaGenesis() string
func DecodeFromHex ¶
DecodeFromHex decodes a hex string with 0x prefix.
func EncodeToHex ¶
EncodeToHex encodes b as a hex string with 0x prefix.
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 SendLogsToFile ¶
Note: A call to SetVerbosity after a call to SendLogsToFile will disable file logging. That's just how currently the code is structured. It is not an issue since we are going to make the calls sequentially at the time of initialization and can choose a particular order. Logs will be sent to this file along with the logcat. format has to be term or json. Anything else will cause the app to panic.
func SetVerbosity ¶
func SetVerbosity(level int)
SetVerbosity sets the global verbosity level (between 0 and 6 - see logger/verbosity.go).
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
Account represents a stored key.
func (*Account) GetAddress ¶
GetAddress retrieves the address associated with the account.
type Accounts ¶
type Accounts struct {
// contains filtered or unexported fields
}
Accounts represents a slice of accounts.
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
Address represents the 20 byte address of an Ethereum account.
func NewAddressFromBytes ¶
NewAddressFromBytes converts a slice of bytes to a hash value.
func NewAddressFromHex ¶
NewAddressFromHex converts a hex string to a address value.
type Addresses ¶
type Addresses struct {
// contains filtered or unexported fields
}
Addresses represents a slice of addresses.
func NewAddresses ¶
NewAddresses creates a slice of uninitialized addresses.
func NewAddressesEmpty ¶
func NewAddressesEmpty() *Addresses
NewAddressesEmpty creates an empty slice of Addresses values.
type BigInt ¶
type BigInt struct {
// contains filtered or unexported fields
}
A BigInt represents a signed multi-precision integer.
func (*BigInt) GetInt64 ¶
GetInt64 returns the int64 representation of x. If x cannot be represented in an int64, the result is undefined.
func (*BigInt) GetString ¶
GetString returns the value of x as a formatted string in some number base.
func (*BigInt) SetBytes ¶
SetBytes interprets buf as the bytes of a big-endian unsigned integer and sets the big int to that value.
func (*BigInt) SetString ¶
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.
type BigInts ¶
type BigInts struct {
// contains filtered or unexported fields
}
BigInts represents a slice of big ints.
func NewBigInts ¶
NewBigInts creates a slice of uninitialized big numbers.
type Binaries ¶
type Binaries struct {
// contains filtered or unexported fields
}
Binaries represents a slice of byte slice
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block represents an entire block in the Ethereum blockchain.
func NewBlockFromJSON ¶
NewBlockFromJSON parses a block from a JSON data dump.
func NewBlockFromRLP ¶
NewBlockFromRLP parses a block from an RLP data dump.
func (*Block) EncodeJSON ¶
EncodeJSON encodes a block into a JSON data dump.
func (*Block) GetCoinbase ¶
func (*Block) GetGasUsed ¶
func (*Block) GetParentHash ¶
func (*Block) GetReceiptHash ¶
func (*Block) GetTransaction ¶
func (b *Block) GetTransaction(hash *Hash) *Transaction
func (*Block) GetTransactions ¶
func (b *Block) GetTransactions() *Transactions
type Bloom ¶
type Bloom struct {
// contains filtered or unexported fields
}
Bloom represents a 256 bit bloom filter.
type Bools ¶
type Bools struct {
// contains filtered or unexported fields
}
Bools represents a slice of bool.
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) (contract *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) (contract *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) RawTransact ¶
func (c *BoundContract) RawTransact(opts *TransactOpts, calldata []byte) (tx *Transaction, _ error)
RawTransact invokes the (paid) contract method with raw calldata as input values.
func (*BoundContract) Transact ¶
func (c *BoundContract) Transact(opts *TransactOpts, method string, args *Interfaces) (tx *Transaction, _ error)
Transact invokes the (paid) contract method with params as input values.
func (*BoundContract) Transfer ¶
func (c *BoundContract) Transfer(opts *TransactOpts) (tx *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) GetGasPrice ¶
func (*CallMsg) SetGasPrice ¶
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 (*CallOpts) SetContext ¶
func (*CallOpts) SetGasLimit ¶
func (*CallOpts) SetPending ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context carries a deadline, a cancellation 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 ¶
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 ¶
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 ¶
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 Criteria ¶
type Criteria struct {
// contains filtered or unexported fields
}
Criteria holds various filter options for inbound messages.
func NewCriteria ¶
func (*Criteria) GetPrivateKeyID ¶
func (*Criteria) GetSymKeyID ¶
func (*Criteria) SetPrivateKeyID ¶
func (*Criteria) SetSymKeyID ¶
type Enode ¶
type Enode struct {
// contains filtered or unexported fields
}
Enode represents a host on the network.
func NewEnode ¶
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 NewEnodesEmpty ¶
func NewEnodesEmpty() *Enodes
NewEnodesEmpty creates an empty slice of Enode values.
type EthereumClient ¶
type EthereumClient struct {
// contains filtered or unexported fields
}
EthereumClient provides access to the Ethereum APIs.
func NewEthereumClient ¶
func NewEthereumClient(rawurl string) (client *EthereumClient, _ error)
NewEthereumClient connects a client to the given URL.
func (*EthereumClient) CallContract ¶
func (ec *EthereumClient) CallContract(ctx *Context, msg *CallMsg, number int64) (output []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) (gas int64, _ 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 *Logs, _ error)
FilterLogs executes a filter query.
func (*EthereumClient) GetBalanceAt ¶
func (ec *EthereumClient) GetBalanceAt(ctx *Context, account *Address, number int64) (balance *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 *Block, _ error)
GetBlockByHash returns the given full block.
func (*EthereumClient) GetBlockByNumber ¶
func (ec *EthereumClient) GetBlockByNumber(ctx *Context, number int64) (block *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) (code []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 *Header, _ error)
GetHeaderByHash returns the block header with the given hash.
func (*EthereumClient) GetHeaderByNumber ¶
func (ec *EthereumClient) GetHeaderByNumber(ctx *Context, number int64) (header *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) (nonce 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) (balance *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) (code []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) (nonce 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) (storage []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) (count 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) (storage []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) (tx *Transaction, _ error)
GetTransactionByHash returns the transaction with the given hash.
func (*EthereumClient) GetTransactionCount ¶
func (ec *EthereumClient) GetTransactionCount(ctx *Context, hash *Hash) (count 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) (tx *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 *Receipt, _ error)
GetTransactionReceipt returns the receipt of a transaction by transaction hash. Note that the receipt is not available for pending transactions.
func (*EthereumClient) GetTransactionSender ¶
func (ec *EthereumClient) GetTransactionSender(ctx *Context, tx *Transaction, blockhash *Hash, index int) (sender *Address, _ error)
GetTransactionSender returns the sender address of a transaction. The transaction must be included in blockchain at the given block and index.
func (*EthereumClient) PendingCallContract ¶
func (ec *EthereumClient) PendingCallContract(ctx *Context, msg *CallMsg) (output []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) (sub *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) (sub *Subscription, _ error)
SubscribeNewHead subscribes to notifications about the current blockchain head on the given channel.
func (*EthereumClient) SuggestGasPrice ¶
func (ec *EthereumClient) SuggestGasPrice(ctx *Context) (price *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) (progress *SyncProgress, _ error)
SyncProgress retrieves the current progress of the sync algorithm. If there's no sync currently running, it returns nil.
type FilterLogsHandler ¶
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 contract log filtering.
func NewFilterQuery ¶
func NewFilterQuery() *FilterQuery
NewFilterQuery creates an empty filter query for contract 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
func (*FilterQuery) SetAddresses ¶
func (fq *FilterQuery) SetAddresses(addresses *Addresses)
func (*FilterQuery) SetFromBlock ¶
func (fq *FilterQuery) SetFromBlock(fromBlock *BigInt)
func (*FilterQuery) SetToBlock ¶
func (fq *FilterQuery) SetToBlock(toBlock *BigInt)
func (*FilterQuery) SetTopics ¶
func (fq *FilterQuery) SetTopics(topics *Topics)
type Hash ¶
type Hash struct {
// contains filtered or unexported fields
}
Hash represents the 32 byte Keccak256 hash of arbitrary data.
func NewHashFromBytes ¶
NewHashFromBytes converts a slice of bytes to a hash value.
func NewHashFromHex ¶
NewHashFromHex converts a hex string to a hash value.
type Hashes ¶
type Hashes struct {
// contains filtered or unexported fields
}
Hashes represents a slice of hashes.
func NewHashesEmpty ¶
func NewHashesEmpty() *Hashes
NewHashesEmpty creates an empty slice of Hashes values.
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
Header represents a block header in the Ethereum blockchain.
func NewHeaderFromJSON ¶
NewHeaderFromJSON parses a header from a JSON data dump.
func NewHeaderFromRLP ¶
NewHeaderFromRLP parses a header from an RLP data dump.
func (*Header) EncodeJSON ¶
EncodeJSON encodes a header into a JSON data dump.
func (*Header) GetCoinbase ¶
func (*Header) GetGasUsed ¶
func (*Header) GetParentHash ¶
func (*Header) GetReceiptHash ¶
type Headers ¶
type Headers struct {
// contains filtered or unexported fields
}
Headers represents a slice of headers.
type Info ¶
type Info struct {
// contains filtered or unexported fields
}
Info represents a diagnostic information about the whisper node.
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 (*Interface) GetAddresses ¶
func (*Interface) GetBigInts ¶
func (*Interface) GetBinaries ¶
func (*Interface) GetStrings ¶
func (*Interface) GetUint16s ¶
func (*Interface) GetUint32s ¶
func (*Interface) GetUint64s ¶
func (*Interface) SetAddress ¶
func (*Interface) SetAddresses ¶
func (*Interface) SetBigInts ¶
func (*Interface) SetBinaries ¶
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) SetDefaultInt16s ¶
func (i *Interface) SetDefaultInt16s()
func (*Interface) SetDefaultInt32 ¶
func (i *Interface) SetDefaultInt32()
func (*Interface) SetDefaultInt32s ¶
func (i *Interface) SetDefaultInt32s()
func (*Interface) SetDefaultInt64 ¶
func (i *Interface) SetDefaultInt64()
func (*Interface) SetDefaultInt64s ¶
func (i *Interface) SetDefaultInt64s()
func (*Interface) SetDefaultInt8 ¶
func (i *Interface) SetDefaultInt8()
func (*Interface) SetDefaultInt8s ¶
func (i *Interface) SetDefaultInt8s()
func (*Interface) SetDefaultString ¶
func (i *Interface) SetDefaultString()
func (*Interface) SetDefaultStrings ¶
func (i *Interface) SetDefaultStrings()
func (*Interface) SetDefaultUint16 ¶
func (i *Interface) SetDefaultUint16()
func (*Interface) SetDefaultUint16s ¶
func (i *Interface) SetDefaultUint16s()
func (*Interface) SetDefaultUint32 ¶
func (i *Interface) SetDefaultUint32()
func (*Interface) SetDefaultUint32s ¶
func (i *Interface) SetDefaultUint32s()
func (*Interface) SetDefaultUint64 ¶
func (i *Interface) SetDefaultUint64()
func (*Interface) SetDefaultUint64s ¶
func (i *Interface) SetDefaultUint64s()
func (*Interface) SetDefaultUint8 ¶
func (i *Interface) SetDefaultUint8()
func (*Interface) SetDefaultUint8s ¶
func (i *Interface) SetDefaultUint8s()
func (*Interface) SetStrings ¶
func (*Interface) SetUint16s ¶
func (*Interface) SetUint32s ¶
func (*Interface) SetUint64s ¶
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) (iface *Interface, _ error)
Get returns the bigint at the given index from the slice. Notably the returned value can be changed without affecting the interfaces itself.
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 KeyStore ¶
type KeyStore struct {
// contains filtered or unexported fields
}
KeyStore manages a key storage directory on disk.
func NewKeyStore ¶
NewKeyStore creates a keystore for the given directory.
func (*KeyStore) ComputeECDHSharedSecret ¶
ComputeECDHSharedSecret computes an ECDH shared secret between the given account's private key and the public key provided. The account has to be unlocked first. The public key format is a 65 byte array, with byte[0] == 4, 32 bytes for X, and 32 bytes for Y (encoded in base256).
func (*KeyStore) DeleteAccount ¶
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 (*KeyStore) ExportKey ¶
func (ks *KeyStore) ExportKey(account *Account, passphrase, newPassphrase string) (key []byte, _ error)
ExportKey exports as a JSON key, encrypted with newPassphrase.
func (*KeyStore) GetAccounts ¶
GetAccounts returns all key files present in the directory.
func (*KeyStore) HasAddress ¶
HasAddress reports whether a key with the given address is present.
func (*KeyStore) ImportECDSAKey ¶
ImportECDSAKey stores the given encrypted JSON key into the key directory.
func (*KeyStore) ImportKey ¶
func (ks *KeyStore) ImportKey(keyJSON []byte, passphrase, newPassphrase string) (account *Account, _ error)
ImportKey stores the given encrypted JSON key into the key directory.
func (*KeyStore) ImportPreSaleKey ¶
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 (*KeyStore) NewAccount ¶
NewAccount generates a new key and stores it into the key directory, encrypting it with the passphrase.
func (*KeyStore) SignHash ¶
SignHash calculates a ECDSA signature for the given hash. The produced signature is in the [R || S || V] format where V is 0 or 1.
func (*KeyStore) SignHashPassphrase ¶
func (ks *KeyStore) SignHashPassphrase(account *Account, passphrase string, hash []byte) (signature []byte, _ error)
SignHashPassphrase signs hash if the private key matching the given address can be decrypted with the given passphrase. The produced signature is in the [R || S || V] format where V is 0 or 1.
func (*KeyStore) SignTx ¶
func (ks *KeyStore) SignTx(account *Account, tx *Transaction, chainID *BigInt) (*Transaction, error)
SignTx signs the given transaction with the requested account.
func (*KeyStore) SignTxPassphrase ¶
func (ks *KeyStore) SignTxPassphrase(account *Account, passphrase string, tx *Transaction, chainID *BigInt) (*Transaction, error)
SignTxPassphrase signs the transaction if the private key matching the given address can be decrypted with the given passphrase.
func (*KeyStore) SignTypedData ¶
SignTypedData signs EIP-712 conformant typed data hash = keccak256("\x19${byteVersion}${domainSeparator}${hashStruct(message)}")
func (*KeyStore) TimedUnlock ¶
TimedUnlock unlocks the given account with the passphrase. The account stays unlocked for the duration of timeout (nanoseconds). 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.
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 (*Log) GetBlockHash ¶
func (*Log) GetBlockNumber ¶
func (*Log) GetTxIndex ¶
type Logs ¶
type Logs struct {
// contains filtered or unexported fields
}
Logs represents a slice of VM logs.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message represents a whisper message.
func (*Message) GetPayload ¶
func (*Message) GetTimestamp ¶
type Messages ¶
type Messages struct {
// contains filtered or unexported fields
}
Messages represents an array of messages.
type MobileSigner ¶
type MobileSigner struct {
// contains filtered or unexported fields
}
func (*MobileSigner) Sign ¶
func (s *MobileSigner) Sign(addr *Address, unsignedTx *Transaction) (signedTx *Transaction, _ error)
type NewHeadHandler ¶
NewHeadHandler is a client-side subscription callback to invoke on events and subscription failure.
type NewMessage ¶
type NewMessage struct {
// contains filtered or unexported fields
}
NewMessage represents a new whisper message that is posted through the RPC.
func NewNewMessage ¶
func NewNewMessage() *NewMessage
func (*NewMessage) GetPayload ¶
func (nm *NewMessage) GetPayload() []byte
func (*NewMessage) GetPowTarget ¶
func (nm *NewMessage) GetPowTarget() float64
func (*NewMessage) GetPowTime ¶
func (nm *NewMessage) GetPowTime() int64
func (*NewMessage) GetPublicKey ¶
func (nm *NewMessage) GetPublicKey() []byte
func (*NewMessage) GetSig ¶
func (nm *NewMessage) GetSig() string
func (*NewMessage) GetSymKeyID ¶
func (nm *NewMessage) GetSymKeyID() string
func (*NewMessage) GetTTL ¶
func (nm *NewMessage) GetTTL() int64
func (*NewMessage) GetTargetPeer ¶
func (nm *NewMessage) GetTargetPeer() string
func (*NewMessage) GetTopic ¶
func (nm *NewMessage) GetTopic() []byte
func (*NewMessage) SetPayload ¶
func (nm *NewMessage) SetPayload(payload []byte)
func (*NewMessage) SetPowTarget ¶
func (nm *NewMessage) SetPowTarget(powTarget float64)
func (*NewMessage) SetPowTime ¶
func (nm *NewMessage) SetPowTime(powTime int64)
func (*NewMessage) SetPublicKey ¶
func (nm *NewMessage) SetPublicKey(publicKey []byte)
func (*NewMessage) SetSig ¶
func (nm *NewMessage) SetSig(sig string)
func (*NewMessage) SetSymKeyID ¶
func (nm *NewMessage) SetSymKeyID(symKeyID string)
func (*NewMessage) SetTTL ¶
func (nm *NewMessage) SetTTL(ttl int64)
func (*NewMessage) SetTargetPeer ¶
func (nm *NewMessage) SetTargetPeer(targetPeer string)
func (*NewMessage) SetTopic ¶
func (nm *NewMessage) SetTopic(topic []byte)
type NewMessageHandler ¶
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) (stack *Node, _ error)
NewNode creates and configures a new Geth node.
func (*Node) Close ¶
Close terminates a running node along with all it's services, tearing internal state down. It is not possible to restart a closed node.
func (*Node) GetBlockchainStats ¶
func (*Node) GetEthereumClient ¶
func (n *Node) GetEthereumClient() (client *EthereumClient, _ error)
GetEthereumClient retrieves a client to access the Ethereum subsystem.
func (*Node) GetGethStats ¶
func (*Node) GetNodeInfo ¶
GetNodeInfo gathers and returns a collection of metadata known about the host.
func (*Node) GetPeerInfos ¶
GetPeerInfos returns an array of metadata objects describing connected peers.
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 // NoDiscovery indicates whether the node should not participate in p2p discovery NoDiscovery bool // 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 int64 // uint64 in truth, but Java can't handle that... // 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 // EthereumDatabaseCache is the system memory in MB to allocate for database caching. // A minimum of 16MB is always reserved. EthereumDatabaseCache int // EthereumNetStats is a netstats connection string to use to report various // chain, transaction and node stats to a monitoring server. // // It has the form "nodename:secret@host:port" EthereumNetStats string // HTTPHost is the host interface on which to start the HTTP RPC server. If this // field is empty, no HTTP API endpoint will be started. HTTPHost string // HTTPPort is the TCP port number on which to start the HTTP RPC server. The // default zero value is/ valid and will pick a port number randomly (useful // for ephemeral nodes). HTTPPort int // HTTPVirtualHosts is a comma separated list of virtual hostnames which are allowed on incoming requests. // This is by default {'localhost'}. Using this prevents attacks like // DNS rebinding, which bypasses SOP by simply masquerading as being within the same // origin. These attacks do not utilize CORS, since they are not cross-domain. // By explicitly checking the Host-header, the server will not allow requests // made against the server with a malicious host domain. // Requests using ip address directly are not affected HTTPVirtualHosts string // HTTPModules is a comma separated list of API modules to expose via the HTTP RPC interface. // If the module list is empty, all RPC API endpoints designated public will be // exposed. HTTPModules string // WhisperEnabled specifies whether the node should run the Whisper protocol. WhisperEnabled bool // Listening address of pprof server. PprofAddress string // Sync mode for the node (eth/downloader/modes.go) // This has to be integer since Enum exports to Java are not supported by "gomobile" // See getSyncMode(syncMode int) SyncMode int // UseLightweightKDF lowers the memory and CPU requirements of the key store // scrypt KDF at the expense of security. // See https://geth.ethereum.org/doc/Mobile_Account-management for reference UseLightweightKDF bool // IPCPath is the requested location to place the IPC endpoint. If the path is // a simple file name, it is placed inside the data directory (or on the root // pipe path on Windows), whereas if it's a resolvable path name (absolute or // relative), then that specific path is enforced. An empty path disables IPC. IPCPath string }
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 (*NodeInfo) GetListenerAddress ¶
func (*NodeInfo) GetListenerPort ¶
func (*NodeInfo) GetProtocols ¶
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) GetLocalAddress ¶
func (*PeerInfo) GetPurposes ¶
func (*PeerInfo) GetRemoteAddress ¶
type PeerInfos ¶
type PeerInfos struct {
// contains filtered or unexported fields
}
PeerInfos represents a slice of infos about remote peers.
type Receipt ¶
type Receipt struct {
// contains filtered or unexported fields
}
Receipt represents the results of a transaction.
func NewReceiptFromJSON ¶
NewReceiptFromJSON parses a transaction receipt from a JSON data dump.
func NewReceiptFromRLP ¶
NewReceiptFromRLP parses a transaction receipt from an RLP data dump.
func (*Receipt) EncodeJSON ¶
EncodeJSON encodes a transaction receipt into a JSON data dump.
func (*Receipt) GetContractAddress ¶
func (*Receipt) GetCumulativeGasUsed ¶
func (*Receipt) GetGasUsed ¶
func (*Receipt) GetPostState ¶
type Signer ¶
type Signer interface {
Sign(addr *Address, unsignedTx *Transaction) (tx *Transaction, _ error)
}
Signer is an interface defining the callback when a contract requires a method to sign the transaction before submission.
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
func (*Stats) GetStatsKeys ¶
func (*Stats) SyncToRegistryStats ¶
func (stats *Stats) SyncToRegistryStats()
type Strings ¶
type Strings struct {
// contains filtered or unexported fields
}
Strings represents s slice of strs.
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 NewTopicsEmpty ¶
func NewTopicsEmpty() *Topics
NewTopicsEmpty creates an empty slice of Topics values.
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 NewKeyedTransactOpts ¶
func NewKeyedTransactOpts(keyJson []byte, passphrase string) (*TransactOpts, error)
NewKeyedTransactOpts is a utility method to easily create a transaction signer from a single private key.
func NewTransactOpts ¶
func NewTransactOpts() *TransactOpts
NewTransactOpts creates a new option set for contract 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 NewContractCreation ¶
func NewContractCreation(nonce int64, amount *BigInt, gasLimit int64, gasPrice *BigInt, data []byte) *Transaction
NewContractCreation creates a new transaction for deploying a new contract with the given properties.
func NewTransaction ¶
func NewTransaction(nonce int64, to *Address, amount *BigInt, gasLimit int64, gasPrice *BigInt, feeCurrency, gatewayFeeRecipient *Address, gatewayFee *BigInt, data []byte) *Transaction
NewTransaction creates a new transaction with the given properties.
func NewTransactionFromJSON ¶
func NewTransactionFromJSON(data string) (*Transaction, error)
NewTransactionFromJSON parses a transaction from a JSON data dump.
func NewTransactionFromRLP ¶
func NewTransactionFromRLP(data []byte) (*Transaction, error)
NewTransactionFromRLP parses a transaction from an RLP data dump.
func (*Transaction) EncodeJSON ¶
func (tx *Transaction) EncodeJSON() (string, error)
EncodeJSON encodes a transaction into a JSON data dump.
func (*Transaction) EncodeRLP ¶
func (tx *Transaction) EncodeRLP() ([]byte, error)
EncodeRLP encodes a transaction into an RLP data dump.
func (*Transaction) GetCost ¶
func (tx *Transaction) GetCost() *BigInt
func (*Transaction) GetData ¶
func (tx *Transaction) GetData() []byte
func (*Transaction) GetFrom
deprecated
func (tx *Transaction) GetFrom(chainID *BigInt) (address *Address, _ error)
Deprecated: use EthereumClient.TransactionSender
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
deprecated
func (tx *Transaction) GetSigHash() *Hash
Deprecated: GetSigHash cannot know which signer to use.
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, chainID *BigInt) (signedTx *Transaction, _ error)
type Transactions ¶
type Transactions struct {
// contains filtered or unexported fields
}
Transactions represents a slice of transactions.
func (*Transactions) Get ¶
func (txs *Transactions) Get(index int) (tx *Transaction, _ error)
Get returns the transaction at the given index from the slice.
func (*Transactions) Size ¶
func (txs *Transactions) Size() int
Size returns the number of transactions in the slice.
type WhisperClient ¶
type WhisperClient struct {
// contains filtered or unexported fields
}
WhisperClient provides access to the Ethereum APIs.
func NewWhisperClient ¶
func NewWhisperClient(rawurl string) (client *WhisperClient, _ error)
NewWhisperClient connects a client to the given URL.
func (*WhisperClient) AddPrivateKey ¶
func (wc *WhisperClient) AddPrivateKey(ctx *Context, key []byte) (string, error)
AddPrivateKey stored the key pair, and returns its ID.
func (*WhisperClient) AddSymmetricKey ¶
func (wc *WhisperClient) AddSymmetricKey(ctx *Context, key []byte) (string, error)
AddSymmetricKey stores the key, and returns its identifier.
func (*WhisperClient) DeleteKeyPair ¶
func (wc *WhisperClient) DeleteKeyPair(ctx *Context, id string) (string, error)
DeleteKeyPair delete the specifies key.
func (*WhisperClient) DeleteMessageFilter ¶
func (wc *WhisperClient) DeleteMessageFilter(ctx *Context, id string) error
DeleteMessageFilter removes the filter associated with the given id.
func (*WhisperClient) DeleteSymmetricKey ¶
func (wc *WhisperClient) DeleteSymmetricKey(ctx *Context, id string) error
DeleteSymmetricKey deletes the symmetric key associated with the given identifier.
func (*WhisperClient) GenerateSymmetricKeyFromPassword ¶
func (wc *WhisperClient) GenerateSymmetricKeyFromPassword(ctx *Context, passwd string) (string, error)
GenerateSymmetricKeyFromPassword generates the key from password, stores it, and returns its identifier.
func (*WhisperClient) GetFilterMessages ¶
func (wc *WhisperClient) GetFilterMessages(ctx *Context, id string) (*Messages, error)
GetFilterMessages retrieves all messages that are received between the last call to this function and match the criteria that where given when the filter was created.
func (*WhisperClient) GetInfo ¶
func (wc *WhisperClient) GetInfo(ctx *Context) (info *Info, _ error)
Info returns diagnostic information about the whisper node.
func (*WhisperClient) GetPrivateKey ¶
func (wc *WhisperClient) GetPrivateKey(ctx *Context, id string) ([]byte, error)
GetPrivateKey return the private key for a key ID.
func (*WhisperClient) GetPublicKey ¶
func (wc *WhisperClient) GetPublicKey(ctx *Context, id string) ([]byte, error)
GetPublicKey return the public key for a key ID.
func (*WhisperClient) GetSymmetricKey ¶
func (wc *WhisperClient) GetSymmetricKey(ctx *Context, id string) ([]byte, error)
GetSymmetricKey returns the symmetric key associated with the given identifier.
func (*WhisperClient) GetVersion ¶
func (wc *WhisperClient) GetVersion(ctx *Context) (version string, _ error)
GetVersion returns the Whisper sub-protocol version.
func (*WhisperClient) HasKeyPair ¶
func (wc *WhisperClient) HasKeyPair(ctx *Context, id string) (bool, error)
HasKeyPair returns an indication if the node has a private key or key pair matching the given ID.
func (*WhisperClient) HasSymmetricKey ¶
func (wc *WhisperClient) HasSymmetricKey(ctx *Context, id string) (bool, error)
HasSymmetricKey returns an indication if the key associated with the given id is stored in the node.
func (*WhisperClient) MarkTrustedPeer ¶
func (wc *WhisperClient) MarkTrustedPeer(ctx *Context, enode string) error
Marks specific peer trusted, which will allow it to send historic (expired) messages. Note This function is not adding new nodes, the node needs to exists as a peer.
func (*WhisperClient) NewKeyPair ¶
func (wc *WhisperClient) NewKeyPair(ctx *Context) (string, error)
NewKeyPair generates a new public and private key pair for message decryption and encryption. It returns an identifier that can be used to refer to the key.
func (*WhisperClient) NewMessageFilter ¶
func (wc *WhisperClient) NewMessageFilter(ctx *Context, criteria *Criteria) (string, error)
NewMessageFilter creates a filter within the node. This filter can be used to poll for new messages (see FilterMessages) that satisfy the given criteria. A filter can timeout when it was polled for in whisper.filterTimeout.
func (*WhisperClient) NewSymmetricKey ¶
func (wc *WhisperClient) NewSymmetricKey(ctx *Context) (string, error)
NewSymmetricKey generates a random symmetric key and returns its identifier. Can be used encrypting and decrypting messages where the key is known to both parties.
func (*WhisperClient) Post ¶
func (wc *WhisperClient) Post(ctx *Context, message *NewMessage) (string, error)
Post a message onto the network.
func (*WhisperClient) SetMaxMessageSize ¶
func (wc *WhisperClient) SetMaxMessageSize(ctx *Context, size int32) error
SetMaxMessageSize sets the maximal message size allowed by this node. Incoming and outgoing messages with a larger size will be rejected. Whisper message size can never exceed the limit imposed by the underlying P2P protocol (10 Mb).
func (*WhisperClient) SetMinimumPoW ¶
func (wc *WhisperClient) SetMinimumPoW(ctx *Context, pow float64) error
SetMinimumPoW (experimental) sets the minimal PoW required by this node. This experimental function was introduced for the future dynamic adjustment of PoW requirement. If the node is overwhelmed with messages, it should raise the PoW requirement and notify the peers. The new value should be set relative to the old value (e.g. double). The old value could be obtained via shh_info call.
func (*WhisperClient) SubscribeMessages ¶
func (wc *WhisperClient) SubscribeMessages(ctx *Context, criteria *Criteria, handler NewMessageHandler, buffer int) (*Subscription, error)
SubscribeMessages subscribes to messages that match the given criteria. This method is only supported on bi-directional connections such as websockets and IPC. NewMessageFilter uses polling and is supported over HTTP.