return address from create account function

This commit is contained in:
Daniel Whitenack 2016-06-21 09:07:24 -05:00
parent 7399ea5b83
commit 0ebf2b7648
2 changed files with 11 additions and 8 deletions

View File

@ -13,7 +13,8 @@ var (
scryptP = 1
)
func createAccount(password, keydir string) error {
// createAccount creates an internal geth account
func createAccount(password, keydir string) (string, error) {
var sync *[]node.Service
w := true
@ -21,15 +22,16 @@ func createAccount(password, keydir string) error {
account, err := accman.NewAccount(password, w)
if err != nil {
return err
return "", err
}
address := fmt.Sprintf("{%x}", account.Address)
fmt.Println(address)
return nil
return address, nil
}
// createAndStartNode creates a node entity and starts the
// node running locally
func createAndStartNode(datadir string) error {
currentNode := MakeNode(datadir)

View File

@ -7,14 +7,15 @@ import (
)
//export doCreateAccount
func doCreateAccount(password, keydir *C.char) C.int {
func doCreateAccount(password, keydir *C.char) (*C.char, C.int) {
// This is equivalent to creating an account from the command line,
// just modified to handle the function arg passing
if err := createAccount(C.GoString(password), C.GoString(keydir)); err != nil {
address, err := createAccount(C.GoString(password), C.GoString(keydir))
if err != nil {
fmt.Fprintln(os.Stderr, err)
return -1
return C.CString(""), -1
}
return 0
return C.CString(address), 0
}
// export doStartNode