Skip to content

Notes on Bindings

Victor Farazdagi edited this page Aug 28, 2016 · 18 revisions

Status Bindings Notes

Main Account creation

// 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)

Sub-account creation

// 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)

Recover account details

// 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)

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

UnlockAccount(address, password string, seconds int)

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/go-ethereum/issues/15).

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