Skip to content

Notes on Bindings

Victor Farazdagi edited this page Sep 12, 2016 · 18 revisions

Status Bindings Notes

1. Main Account creation

Exported method:

func CreateAccount(password *C.char) *C.char

Internally relies on:

// createAccount creates an internal geth account
// BIP44-compatible keys are generated: CKD#1 is stored as account key, CKD#2 stored as sub-account root
// Public key of CKD#1 is returned, with CKD#2 securely encoded into account key file (to be used for
// sub-account derivations)
func createAccount(password string) (address, pubKey, mnemonic string, err error)

Sample response:

{
  "Address": "0xdeadbeef..",
  "PubKey": "0xdeadbeef..",
  "Mnemonic": "stupid lazy fox jump crazy..",
  "Error": ""
}

2. Sub-account creation

Exported method:

func CreateChildAccount(parentAddress, password *C.char) *C.char

Internally relies on:

// createChildAccount creates sub-account for an account identified by parent address.
// CKD#2 is used as root for master accounts (when parentAddress is "").
// Otherwise (when parentAddress != ""), child is derived directly from parent.
func createChildAccount(parentAddress, password string) (address, pubKey string, err error)

Sample Response:

{
  "Address": "0xdeadbeef..",
  "PubKey": "0xdeadbeef..",
  "Error": ""
}

3. Recover account details

Exported Method:

func RecoverAccount(password, mnemonic *C.char) *C.char

Internally relies on:

// recoverAccount re-creates master key using given details.
// Once master key is re-generated, it is inserted into keystore (if not already there).
func recoverAccount(password, mnemonic string) (address, pubKey string, err error)

Sample Response: (same as on main account creation)

{
  "Address": "0xdeadbeef..",
  "PubKey": "0xdeadbeef..",
  "Mnemonic": "stupid lazy fox jump crazy..",
  "Error": ""
}

Login (select active/current account)

Binding:

func Login(address, password *C.char) *C.char

Internally:

// selectAccount selects current account, by verifying that address has corresponding account which can be decrypted
// using provided password. Once verification is done, decrypted key is injected into Whisper (as a single identity,
// all previous identities are removed).
func selectAccount(address, password string) error

How to Unlock Account?

Every time somebody unlocks Ethereum account Cthulhu kills kittens (🐱 😸 ), dozens of them. So, don't use this method.

This method is deprecated, and will return error, asking you to rely Login() instead (if kittens weren't enough for you!)

Transaction handling

Every time transaction is sent to geth node (via SendTransaction) it is intercepted and queued (more on queues will be added to this doc once we implement our twisted logic in https://github.com/status-im/status-go/issues/26).

Anyway, in order to complete transaction

CompleteTransaction(hash, password string)

needs to be called. Transaction is signed with password, and if this signing works transaction is executed (sent to execution pool).

Node Management

StartNode(datadir string) // starts node with a given data directory
addPeer(url string) // adds peer geth will listen to

Whisper

To manage observers:

addWhisperFilter(filterJson string)
removeWhisperFilter(id int)
cleanWhisperFilters()
Clone this wiki locally