statusgo

package
v0.89.14 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: MPL-2.0 Imports: 27 Imported by: 1

README

Mobile

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

Individual bindings and their descriptions are available in status.go.

The primary consumer of this package is status-react project.

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 ChangeDatabasePassword added in v0.80.2

func ChangeDatabasePassword(keyUID, password, newPassword string) string

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 ConvertToKeycardAccount added in v0.83.0

func ConvertToKeycardAccount(keyStoreDir, accountData, settingsJSON, password, newPassword string) string

func DeleteImportedKey added in v0.83.12

func DeleteImportedKey(address, password, keyStoreDir string) string

DeleteImportedKey

func DeleteMultiaccount added in v0.55.2

func DeleteMultiaccount(keyUID, keyStoreDir string) string

DeleteMultiaccount

func ExportNodeLogs

func ExportNodeLogs() string

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

func ExportUnencryptedDatabase added in v0.69.0

func ExportUnencryptedDatabase(accountData, password, databasePath string) string

ExportUnencryptedDatabase exports the database unencrypted to the given path

func ExtractGroupMembershipSignatures

func ExtractGroupMembershipSignatures(signaturePairsStr string) string

ExtractGroupMembershipSignatures extract public keys from tuples of content/signature.

func GenerateAlias

func GenerateAlias(pk string) string

func GetNodeConfig added in v0.77.1

func GetNodeConfig() string

GetNodeConfig returns the current config of the Status node

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 HashTypedDataV4 added in v0.76.4

func HashTypedDataV4(data string) string

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

func Identicon

func Identicon(pk string) string

func ImportUnencryptedDatabase added in v0.69.0

func ImportUnencryptedDatabase(accountData, password, databasePath string) string

ImportUnencryptedDatabase imports the database unencrypted to the given directory

func InitKeystore

func InitKeystore(keydir string) string

InitKeystore initialize keystore before doing any operations with keys.

func Login

func Login(accountData, 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(accountData, password, keyHex 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 MigrateKeyStoreDir added in v0.55.1

func MigrateKeyStoreDir(accountData, password, oldDir, newDir string) string

MigrateKeyStoreDir migrates key files to a new directory

func MultiAccountDeriveAddresses

func MultiAccountDeriveAddresses(paramsJSON string) string

MultiAccountDeriveAddresses derive addresses from an account selected by ID, without storing them.

func MultiAccountGenerate

func MultiAccountGenerate(paramsJSON string) string

MultiAccountGenerate generates account in memory without storing them.

func MultiAccountGenerateAndDeriveAddresses

func MultiAccountGenerateAndDeriveAddresses(paramsJSON string) string

MultiAccountGenerateAndDeriveAddresses combines Generate and DeriveAddresses in one call.

func MultiAccountImportMnemonic

func MultiAccountImportMnemonic(paramsJSON string) string

MultiAccountImportMnemonic imports an account derived from the mnemonic phrase and the Bip39Passphrase storing it.

func MultiAccountImportPrivateKey

func MultiAccountImportPrivateKey(paramsJSON string) string

MultiAccountImportPrivateKey imports a raw private key without storing it.

func MultiAccountLoadAccount

func MultiAccountLoadAccount(paramsJSON string) string

MultiAccountLoadAccount loads in memory the account specified by address unlocking it with password.

func MultiAccountReset

func MultiAccountReset() string

MultiAccountReset remove all the multi-account keys from memory.

func MultiAccountStoreAccount

func MultiAccountStoreAccount(paramsJSON string) string

MultiAccountStoreAccount stores the select account.

func MultiAccountStoreDerivedAccounts

func MultiAccountStoreDerivedAccounts(paramsJSON string) string

MultiAccountStoreDerivedAccounts derive accounts from the specified key and store them encrypted with the specified password.

func MultiformatDeserializePublicKey added in v0.55.1

func MultiformatDeserializePublicKey(key, outBase string) string

DeserializePublicKey decompresses a compressed multibase encoded multicodec identified EC public key For details on usage see specs https://specs.status.im/spec/2#public-key-serialization

func MultiformatSerializePublicKey added in v0.55.1

func MultiformatSerializePublicKey(key, outBase string) string

SerializePublicKey compresses an uncompressed multibase encoded multicodec identified EC public key For details on usage see specs https://specs.status.im/spec/2#public-key-serialization

func OpenAccounts

func OpenAccounts(datadir string) string

OpenAccounts opens database and returns accounts list.

func Recover

func Recover(rpcParams string) string

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

func ResetChainData

func ResetChainData() string

ResetChainData removes chain data from data directory.

func SaveAccountAndLogin

func SaveAccountAndLogin(accountData, password, settingsJSON, configJSON, subaccountData string) string

SaveAccountAndLogin saves account in status-go database..

func SaveAccountAndLoginWithKeycard

func SaveAccountAndLoginWithKeycard(accountData, password, settingsJSON, configJSON, subaccountData string, keyHex string) string

SaveAccountAndLoginWithKeycard saves account in status-go database..

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, address, password string) string

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

func SignTypedDataV4 added in v0.76.4

func SignTypedDataV4(data, address, password string) string

SignTypedDataV4 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 StartLocalNotifications added in v0.62.16

func StartLocalNotifications() string

StartLocalNotifications

func StopCPUProfiling

func StopCPUProfiling() string

StopCPUProfiling stops pprof for cpu.

func StopLocalNotifications added in v0.62.16

func StopLocalNotifications() string

StopLocalNotifications

func ValidateMnemonic added in v0.38.1

func ValidateMnemonic(mnemonic string) string

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 VerifyDatabasePassword added in v0.83.0

func VerifyDatabasePassword(keyUID, password string) string

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 MultiAccountDeriveAddressesParams

type MultiAccountDeriveAddressesParams struct {
	AccountID string   `json:"accountID"`
	Paths     []string `json:"paths"`
}

MultiAccountDeriveAddressesParams are the params sent to MultiAccountDeriveAddresses.

type MultiAccountGenerateAndDeriveAddressesParams

type MultiAccountGenerateAndDeriveAddressesParams struct {
	MultiAccountGenerateParams
	Paths []string `json:"paths"`
}

MultiAccountGenerateAndDeriveAddressesParams are the params sent to MultiAccountGenerateAndDeriveAddresses.

type MultiAccountGenerateParams

type MultiAccountGenerateParams struct {
	N                    int    `json:"n"`
	MnemonicPhraseLength int    `json:"mnemonicPhraseLength"`
	Bip39Passphrase      string `json:"bip39Passphrase"`
}

MultiAccountGenerateParams are the params sent to MultiAccountGenerate.

type MultiAccountImportMnemonicParams

type MultiAccountImportMnemonicParams struct {
	MnemonicPhrase  string `json:"mnemonicPhrase"`
	Bip39Passphrase string `json:"Bip39Passphrase"`
}

MultiAccountImportMnemonicParams are the params sent to MultiAccountImportMnemonic.

type MultiAccountImportPrivateKeyParams

type MultiAccountImportPrivateKeyParams struct {
	PrivateKey string `json:"privateKey"`
}

MultiAccountImportPrivateKeyParams are the params sent to MultiAccountImportPrivateKey.

type MultiAccountLoadAccountParams

type MultiAccountLoadAccountParams struct {
	Address  string `json:"address"`
	Password string `json:"password"`
}

MultiAccountLoadAccountParams are the params sent to MultiAccountLoadAccount.

type MultiAccountStoreAccountParams

type MultiAccountStoreAccountParams struct {
	AccountID string `json:"accountID"`
	Password  string `json:"password"`
}

MultiAccountStoreAccountParams are the params sent to MultiAccountStoreAccount.

type MultiAccountStoreDerivedAccountsParams

type MultiAccountStoreDerivedAccountsParams struct {
	MultiAccountDeriveAddressesParams
	Password string `json:"password"`
}

MultiAccountStoreDerivedAccountsParams are the params sent to MultiAccountStoreDerivedAccounts.

type NotifyResult

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

NotifyResult is a JSON returned from notify message.

type OnboardingAccount

type OnboardingAccount struct {
	ID            string `json:"id"`
	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"`
}

OnboardingAccount represents accounts info generated for the onboarding.

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