aboutsummaryrefslogtreecommitdiffstats
path: root/node
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-02-07 18:47:34 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-02-13 20:00:07 +0800
commitfad5eb0a87abfc12812647344a26de8a43830182 (patch)
treea679f37933a85edade15ee69b385b6705cc94043 /node
parentb3c0e9d3ccb0bb326646aea47dda391a9552b122 (diff)
downloaddexon-fad5eb0a87abfc12812647344a26de8a43830182.tar.gz
dexon-fad5eb0a87abfc12812647344a26de8a43830182.tar.zst
dexon-fad5eb0a87abfc12812647344a26de8a43830182.zip
accounts, cmd, eth, internal, miner, node: wallets and HD APIs
Diffstat (limited to 'node')
-rw-r--r--node/config.go30
1 files changed, 25 insertions, 5 deletions
diff --git a/node/config.go b/node/config.go
index 9ae9406a9..9dc1642a5 100644
--- a/node/config.go
+++ b/node/config.go
@@ -402,7 +402,7 @@ func (c *Config) parsePersistentNodes(path string) []*discover.Node {
return nodes
}
-func makeAccountManager(conf *Config) (am *accounts.Manager, ephemeralKeystore string, err error) {
+func makeAccountManager(conf *Config) (*accounts.Manager, string, error) {
scryptN := keystore.StandardScryptN
scryptP := keystore.StandardScryptP
if conf.UseLightweightKDF {
@@ -410,7 +410,11 @@ func makeAccountManager(conf *Config) (am *accounts.Manager, ephemeralKeystore s
scryptP = keystore.LightScryptP
}
- var keydir string
+ var (
+ keydir string
+ ephemeral string
+ err error
+ )
switch {
case filepath.IsAbs(conf.KeyStoreDir):
keydir = conf.KeyStoreDir
@@ -425,7 +429,7 @@ func makeAccountManager(conf *Config) (am *accounts.Manager, ephemeralKeystore s
default:
// There is no datadir.
keydir, err = ioutil.TempDir("", "go-ethereum-keystore")
- ephemeralKeystore = keydir
+ ephemeral = keydir
}
if err != nil {
return nil, "", err
@@ -433,7 +437,6 @@ func makeAccountManager(conf *Config) (am *accounts.Manager, ephemeralKeystore s
if err := os.MkdirAll(keydir, 0700); err != nil {
return nil, "", err
}
-
// Assemble the account manager and supported backends
backends := []accounts.Backend{
keystore.NewKeyStore(keydir, scryptN, scryptP),
@@ -443,5 +446,22 @@ func makeAccountManager(conf *Config) (am *accounts.Manager, ephemeralKeystore s
} else {
backends = append(backends, ledgerhub)
}
- return accounts.NewManager(backends...), ephemeralKeystore, nil
+ am := accounts.NewManager(backends...)
+
+ // Start some logging for the user
+ changes := make(chan accounts.WalletEvent, 16)
+ am.Subscribe(changes)
+ go func() {
+ for event := range changes {
+ if event.Arrive {
+ glog.V(logger.Info).Infof("New %s wallet appeared: %s", event.Wallet.Type(), event.Wallet.URL())
+ if err := event.Wallet.Open(""); err != nil {
+ glog.V(logger.Warn).Infof("Failed to open %s wallet %s: %v", event.Wallet.Type(), event.Wallet.URL(), err)
+ }
+ } else {
+ glog.V(logger.Info).Infof("Old %s wallet disappeared: %s", event.Wallet.Type(), event.Wallet.URL())
+ }
+ }
+ }()
+ return am, ephemeral, nil
}