statusgo

package
v0.110.3 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MPL-2.0 Imports: 37 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-mobile 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 ColorHash added in v0.96.0

func ColorHash(pk string) string

func ColorID added in v0.98.3

func ColorID(pk 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 CreateAccountFromMnemonic added in v0.106.3

func CreateAccountFromMnemonic(paramsJSON string) string

CreateAccountFromMnemonic returns an account derived from the mnemonic phrase and the Bip39Passphrase without storing it.

func DecodeParameters added in v0.109.4

func DecodeParameters(decodeParamJSON 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 EmojiHash added in v0.96.0

func EmojiHash(pk string) string

func EncodeFunctionCall added in v0.109.4

func EncodeFunctionCall(method string, paramsJSON string) string

func EncodeTransfer added in v0.109.4

func EncodeTransfer(to string, value string) string

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 GenerateImages added in v0.98.3

func GenerateImages(filepath string, aX, aY, bX, bY int) string

func GetConnectionStringForBeingBootstrapped added in v0.109.1

func GetConnectionStringForBeingBootstrapped(configJSON string) string

GetConnectionStringForBeingBootstrapped starts a server.Receiving server.PairingServer then generates a server.ConnectionParams. Used when the device is Logged out or has no Account keys and the device has no camera to read a QR code with

Example: A desktop device (device without camera) receiving account data from mobile (device with camera)

func GetConnectionStringForBootstrappingAnotherDevice added in v0.109.1

func GetConnectionStringForBootstrappingAnotherDevice(configJSON string) string

GetConnectionStringForBootstrappingAnotherDevice starts a server.Sending server.PairingServer then generates a server.ConnectionParams. Used when the device is Logged in and therefore has Account keys and the device might not have a camera

Example: A mobile or desktop device (devices that MAY have a camera but MUST have a screen) sending account data to a mobile (device with camera)

func GetNodeConfig added in v0.77.1

func GetNodeConfig() string

GetNodeConfig returns the current config of the Status node

func GetPasswordStrength added in v0.96.0

func GetPasswordStrength(paramsJSON string) string

GetPasswordStrength uses zxcvbn module and generates a JSON containing information about the quality of the given password (Entropy, CrackTime, CrackTimeDisplay, Score, MatchSequence and CalcTime). userInputs argument can be whatever list of strings like user's personal info or site-specific vocabulary that zxcvbn will make use to determine the result. For more details on usage see https://github.com/status-im/zxcvbn-go

func GetPasswordStrengthScore added in v0.96.4

func GetPasswordStrengthScore(paramsJSON string) string

GetPasswordStrengthScore uses zxcvbn module and gets the score information about the given password. userInputs argument can be whatever list of strings like user's personal info or site-specific vocabulary that zxcvbn will make use to determine the result. For more details on usage see https://github.com/status-im/zxcvbn-go

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 HexToNumber added in v0.109.4

func HexToNumber(hex string) string

func Identicon

func Identicon(pk string) string

func ImageServerTLSCert added in v0.94.0

func ImageServerTLSCert() 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 InputConnectionStringForBootstrapping added in v0.109.1

func InputConnectionStringForBootstrapping(cs, configJSON string) string

InputConnectionStringForBootstrapping starts a server.PairingClient The given server.ConnectionParams string will determine the server.Mode

server.Mode = server.Sending Used when the device is Logged in and therefore has Account keys and the has a camera to read a QR code

Example: A mobile (device with camera) sending account data to a desktop device (device without camera)

server.Mode = server.Receiving Used when the device is Logged out or has no Account keys and has a camera to read a QR code

Example: A mobile device (device with a camera) receiving account data from a device with a screen (mobile or desktop devices)

func IsAlias added in v0.94.12

func IsAlias(value string) string

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 LoginWithConfig added in v0.92.6

func LoginWithConfig(accountData, password, configJSON 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. It then updates the accounts node db configuration mergin the values received in the configJSON parameter

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 NumberToHex added in v0.109.4

func NumberToHex(numString string) string

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 SendTransactionWithChainID added in v0.101.1

func SendTransactionWithChainID(chainID int, txArgsJSON, password string) string

SendTransactionWithChainID converts RPC args and calls backend.SendTransactionWithChainID.

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 SwitchFleet added in v0.96.4

func SwitchFleet(fleet string, configJSON string) string

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 GetPasswordStrengthRequest added in v0.96.4

type GetPasswordStrengthRequest struct {
	Password   string   `json:"password"`
	UserInputs []string `json:"userInputs"`
}

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 PasswordScoreResponse added in v0.96.4

type PasswordScoreResponse struct {
	Score int `json:"score"`
}

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