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

View File

@ -7,14 +7,15 @@ import (
) )
//export doCreateAccount //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, // This is equivalent to creating an account from the command line,
// just modified to handle the function arg passing // 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) fmt.Fprintln(os.Stderr, err)
return -1 return C.CString(""), -1
} }
return 0 return C.CString(address), 0
} }
// export doStartNode // export doStartNode