status-go/src/library.go

42 lines
1.1 KiB
Go
Raw Normal View History

package main
import "C"
import (
"fmt"
"os"
)
2016-06-20 02:01:28 +00:00
//export doCreateAccount
2016-06-21 14:34:38 +00:00
func doCreateAccount(password, keydir *C.char) (*C.char, *C.char, C.int) {
2016-06-20 01:46:13 +00:00
// This is equivalent to creating an account from the command line,
// just modified to handle the function arg passing
2016-06-21 14:34:38 +00:00
address, pubKey, err := createAccount(C.GoString(password), C.GoString(keydir))
if err != nil {
fmt.Fprintln(os.Stderr, err)
2016-06-21 14:34:38 +00:00
return C.CString(""), C.CString(""), -1
}
2016-06-21 14:34:38 +00:00
return C.CString(address), C.CString(pubKey), 0
}
2016-06-20 15:21:45 +00:00
2016-06-21 18:29:38 +00:00
//export doUnlockAccount
func doUnlockAccount(address, password *C.char) C.int {
// This is equivalent to unlocking an account from the command line,
// just modified to unlock the account for the currently running geth node
// based on the provided arguments
if err := unlockAccount(C.GoString(address), C.GoString(password)); err != nil {
fmt.Fprintln(os.Stderr, err)
return -1
}
return 0
}
2016-06-20 15:21:45 +00:00
// export doStartNode
func doStartNode(datadir *C.char) C.int {
// This starts a geth node with the given datadir
if err := createAndStartNode(C.GoString(datadir)); err != nil {
fmt.Fprintln(os.Stderr, err)
return -1
}
return 0
}