From 0ebf2b764876df936bcd3f5a4d4ccd0bba829427 Mon Sep 17 00:00:00 2001 From: Daniel Whitenack Date: Tue, 21 Jun 2016 09:07:24 -0500 Subject: [PATCH] return address from create account function --- src/gethdep.go | 10 ++++++---- src/library.go | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/gethdep.go b/src/gethdep.go index 0bdcb4ff7..a0bba2c85 100644 --- a/src/gethdep.go +++ b/src/gethdep.go @@ -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) diff --git a/src/library.go b/src/library.go index d5c7df18f..910af9b77 100644 --- a/src/library.go +++ b/src/library.go @@ -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