2016-06-15 19:50:35 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-06-20 15:21:45 +00:00
|
|
|
"errors"
|
2016-06-15 19:50:35 +00:00
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/accounts"
|
|
|
|
"github.com/ethereum/go-ethereum/node"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
scryptN = 262144
|
|
|
|
scryptP = 1
|
|
|
|
)
|
|
|
|
|
2016-06-20 02:01:28 +00:00
|
|
|
func createAccount(password, keydir string) error {
|
2016-06-15 19:50:35 +00:00
|
|
|
|
|
|
|
var sync *[]node.Service
|
|
|
|
w := true
|
2016-06-20 02:01:28 +00:00
|
|
|
accman := accounts.NewManager(keydir, scryptN, scryptP, sync)
|
2016-06-15 19:50:35 +00:00
|
|
|
|
2016-06-20 02:01:28 +00:00
|
|
|
account, err := accman.NewAccount(password, w)
|
2016-06-15 19:50:35 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
address := fmt.Sprintf("{%x}", account.Address)
|
|
|
|
fmt.Println(address)
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
2016-06-20 15:21:45 +00:00
|
|
|
|
|
|
|
func createAndStartNode(datadir string) error {
|
|
|
|
|
|
|
|
currentNode := MakeNode(datadir)
|
|
|
|
if currentNode != nil {
|
|
|
|
StartNode(currentNode)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return errors.New("Could not create the in-memory node object")
|
|
|
|
|
|
|
|
}
|