statusgo

package
v0.26.0-alpha.25 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: MPL-2.0 Imports: 23 Imported by: 0

README

Mobile

Package mobile implements gomobile bindings for status-go. Current implementation servers as a drop-in replacement for lib package.

The framework name is generated from the package name, hence these things are done intentionally: (1) this package's name isn't equal to the directory name (statusgo vs mobile respectively); (2) this package name is statusgo and not status which produces the right framework name.

Usage

For properly using this package, please refer to Makefile in the root of status-go directory.

To manually build library, run following commands:

iOS
gomobile bind -v -target=ios -ldflags="-s -w" github.com/status-im/status-go/mobile

This will produce Statusgo.framework file in the current directory, which can be used in iOS project.

Android
gomobile bind -v -target=android -ldflags="-s -w" github.com/status-im/status-go/mobile

This will generate Statusgo.aar file in the current dir.

Notes

See https://github.com/golang/go/wiki/Mobile for more information on gomobile usage.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPeer

func AddPeer(enode string) string

AddPeer adds an enode as a peer.

func AppStateChange

func AppStateChange(state string)

AppStateChange handles app state changes (background/foreground).

func CallPrivateRPC

func CallPrivateRPC(inputJSON string) string

CallPrivateRPC calls both public and private APIs via RPC.

func CallRPC

func CallRPC(inputJSON string) string

CallRPC calls public APIs via RPC.

func ChaosModeUpdate

func ChaosModeUpdate(on bool) string

ChaosModeUpdate sets the Chaos Mode on or off.

func ConnectionChange

func ConnectionChange(typ string, expensive int)

ConnectionChange handles network state changes as reported by ReactNative (see https://facebook.github.io/react-native/docs/netinfo.html)

func CreateAccount

func CreateAccount(password string) string

CreateAccount is equivalent to creating an account from the command line, just modified to handle the function arg passing.

func CreateChildAccount

func CreateChildAccount(parentAddress, password string) string

CreateChildAccount creates sub-account.

func DisableInstallation

func DisableInstallation(installationID string) string

DisableInstallation disables an installation for multi-device sync.

func EnableInstallation

func EnableInstallation(installationID string) string

EnableInstallation enables an installation for multi-device sync.

func ExportNodeLogs

func ExportNodeLogs() string

ExportNodeLogs reads current node log and returns content to a caller.

func ExtractGroupMembershipSignatures

func ExtractGroupMembershipSignatures(signaturePairsStr string) string

ExtractGroupMembershipSignatures extract public keys from tuples of content/signature.

func GenerateConfig

func GenerateConfig(datadir string, networkID int) string

GenerateConfig for status node.

func GetNodesFromContract

func GetNodesFromContract(rpcEndpoint string, contractAddress string) string

GetNodesFromContract returns a list of nodes from a given contract

func HashMessage

func HashMessage(message string) string

HashMessage calculates the hash of a message to be safely signed by the keycard The hash is calulcated as

keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).

This gives context to the signed message and prevents signing of transactions.

func HashTransaction

func HashTransaction(txArgsJSON string) string

HashTransaction validate the transaction and returns new txArgs and the transaction hash.

func HashTypedData

func HashTypedData(data string) string

HashTypedData unmarshalls data into TypedData, validates it and hashes it.

func LoadFilter

func LoadFilter(chatStr string) string

LoadFilter load a whisper filter

func LoadFilters

func LoadFilters(chatsStr string) string

LoadFilters load all whisper filters

func Login

func Login(address, password string) string

Login loads a key file (for a given address), tries to decrypt it using the password, to verify ownership if verified, purges all the previous identities from Whisper, and injects verified key as shh identity.

func LoginWithKeycard

func LoginWithKeycard(chatKeyData, encryptionKeyData string) string

LoginWithKeycard initializes an account with a chat key and encryption key used for PFS. It purges all the previous identities from Whisper, and injects the key as shh identity.

func Logout

func Logout() string

Logout is equivalent to clearing whisper identities.

func ParseJSONArray

func ParseJSONArray(items string) ([]string, error)

ParseJSONArray parses JSON array into Go array of string.

func Recover

func Recover(rpcParams string) string

Recover unmarshals rpc params {signDataString, signedData} and passes them onto backend.

func RecoverAccount

func RecoverAccount(password, mnemonic string) string

RecoverAccount re-creates master key using given details.

func RemoveFilter

func RemoveFilter(chatStr string) string

RemoveFilter load a whisper filter

func ResetChainData

func ResetChainData() string

ResetChainData removes chain data from data directory.

func SendDataNotification

func SendDataNotification(dataPayloadJSON, tokensArray string) (result string)

SendDataNotification sends push notifications by given tokens. dataPayloadJSON is a JSON string that looks like this:

{
	"data": {
		"msg-v2": {
			"from": "0x2cea3bd5", // hash of sender (first 10 characters/4 bytes of sha3 hash)
			"to": "0xb1f89744", // hash of recipient (first 10 characters/4 bytes of sha3 hash)
			"id": "0x872653ad", // message ID hash (first 10 characters/4 bytes of sha3 hash)
		}
	}
}

func SendTransaction

func SendTransaction(txArgsJSON, password string) string

SendTransaction converts RPC args and calls backend.SendTransaction.

func SendTransactionWithSignature

func SendTransactionWithSignature(txArgsJSON, sigString string) string

SendTransactionWithSignature converts RPC args and calls backend.SendTransactionWithSignature

func SetMobileSignalHandler

func SetMobileSignalHandler(handler SignalHandler)

SetMobileSignalHandler setup geth callback to notify about new signal used for gomobile builds

func SetSignalEventCallback

func SetSignalEventCallback(cb unsafe.Pointer)

SetSignalEventCallback setup geth callback to notify about new signal

func SignGroupMembership

func SignGroupMembership(content string) string

SignGroupMembership signs a string containing group membership information.

func SignHash

func SignHash(hexEncodedHash string) string

SignHash exposes vanilla ECDSA signing required for Swarm messages

func SignMessage

func SignMessage(rpcParams string) string

SignMessage unmarshals rpc params {data, address, password} and passes them onto backend.SignMessage.

func SignTypedData

func SignTypedData(data, password string) string

SignTypedData unmarshall data into TypedData, validate it and signs with selected account, if password matches selected account.

func StartCPUProfile

func StartCPUProfile(dataDir string) string

StartCPUProfile runs pprof for CPU.

func StartNode

func StartNode(configJSON string) string

StartNode starts the Ethereum Status node.

func StopCPUProfiling

func StopCPUProfiling() string

StopCPUProfiling stops pprof for cpu.

func StopNode

func StopNode() string

StopNode stops the Ethereum Status node.

func UpdateMailservers

func UpdateMailservers(data string) string

UpdateMailservers updates mail servers in status backend.

func ValidateNodeConfig

func ValidateNodeConfig(configJSON string) string

ValidateNodeConfig validates config for the Status node.

func VerifyAccountPassword

func VerifyAccountPassword(keyStoreDir, address, password string) string

VerifyAccountPassword verifies account password.

func WriteHeapProfile

func WriteHeapProfile(dataDir string) string

WriteHeapProfile starts pprof for heap

Types

type APIDetailedResponse

type APIDetailedResponse struct {
	Status      bool            `json:"status"`
	Message     string          `json:"message,omitempty"`
	FieldErrors []APIFieldError `json:"field_errors,omitempty"`
}

APIDetailedResponse represents a generic response with possible errors.

func (APIDetailedResponse) Error

func (r APIDetailedResponse) Error() string

Error string representation of APIDetailedResponse.

type APIError

type APIError struct {
	Message string `json:"message"`
}

APIError represents a single error.

func (APIError) Error

func (e APIError) Error() string

Error string representation of APIError.

type APIFieldError

type APIFieldError struct {
	Parameter string     `json:"parameter,omitempty"`
	Errors    []APIError `json:"errors"`
}

APIFieldError represents a set of errors related to a parameter.

func (APIFieldError) Error

func (e APIFieldError) Error() string

Error string representation of APIFieldError.

type APIResponse

type APIResponse struct {
	Error string `json:"error"`
}

APIResponse generic response from API.

type AccountInfo

type AccountInfo struct {
	Address       string `json:"address"` // DEPRECATED
	PubKey        string `json:"pubkey"`  // DEPRECATED
	WalletAddress string `json:"walletAddress"`
	WalletPubKey  string `json:"walletPubKey"`
	ChatAddress   string `json:"chatAddress"`
	ChatPubKey    string `json:"chatPubKey"`
	Mnemonic      string `json:"mnemonic"`
	Error         string `json:"error"`
}

AccountInfo represents account's info.

type NotifyResult

type NotifyResult struct {
	Status bool   `json:"status"`
	Error  string `json:"error,omitempty"`
}

NotifyResult is a JSON returned from notify message.

type SendDataNotificationResult

type SendDataNotificationResult struct {
	Status bool   `json:"status"`
	Error  string `json:"error,omitempty"`
}

SendDataNotificationResult is a JSON returned from notify message.

type SignalHandler

type SignalHandler interface {
	HandleSignal(string)
}

SignalHandler defines a minimal interface a signal handler needs to implement.

Jump to

Keyboard shortcuts

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