aboutsummaryrefslogtreecommitdiffstats
path: root/node
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-02-13 21:03:16 +0800
committerGitHub <noreply@github.com>2017-02-13 21:03:16 +0800
commitf8f428cc18c5f70814d7b3937128781bac14bffd (patch)
treed93d285d2ec22bd8ed646695c3db116c69fa3329 /node
parente23e86921b55cb1ee2fca6b6fb9ed91f5532f9fd (diff)
parente99c788155ddd754c73d2c81b6051dcbd42e6575 (diff)
downloaddexon-f8f428cc18c5f70814d7b3937128781bac14bffd.tar
dexon-f8f428cc18c5f70814d7b3937128781bac14bffd.tar.gz
dexon-f8f428cc18c5f70814d7b3937128781bac14bffd.tar.bz2
dexon-f8f428cc18c5f70814d7b3937128781bac14bffd.tar.lz
dexon-f8f428cc18c5f70814d7b3937128781bac14bffd.tar.xz
dexon-f8f428cc18c5f70814d7b3937128781bac14bffd.tar.zst
dexon-f8f428cc18c5f70814d7b3937128781bac14bffd.zip
Merge pull request #3592 from karalabe/hw-wallets
accounts: initial support for Ledger hardware wallets
Diffstat (limited to 'node')
-rw-r--r--node/config.go32
1 files changed, 23 insertions, 9 deletions
diff --git a/node/config.go b/node/config.go
index 8d75e441b..c09f51747 100644
--- a/node/config.go
+++ b/node/config.go
@@ -27,6 +27,8 @@ import (
"strings"
"github.com/ethereum/go-ethereum/accounts"
+ "github.com/ethereum/go-ethereum/accounts/keystore"
+ "github.com/ethereum/go-ethereum/accounts/usbwallet"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/logger"
@@ -400,15 +402,19 @@ func (c *Config) parsePersistentNodes(path string) []*discover.Node {
return nodes
}
-func makeAccountManager(conf *Config) (am *accounts.Manager, ephemeralKeystore string, err error) {
- scryptN := accounts.StandardScryptN
- scryptP := accounts.StandardScryptP
+func makeAccountManager(conf *Config) (*accounts.Manager, string, error) {
+ scryptN := keystore.StandardScryptN
+ scryptP := keystore.StandardScryptP
if conf.UseLightweightKDF {
- scryptN = accounts.LightScryptN
- scryptP = accounts.LightScryptP
+ scryptN = keystore.LightScryptN
+ scryptP = keystore.LightScryptP
}
- var keydir string
+ var (
+ keydir string
+ ephemeral string
+ err error
+ )
switch {
case filepath.IsAbs(conf.KeyStoreDir):
keydir = conf.KeyStoreDir
@@ -423,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
@@ -431,6 +437,14 @@ func makeAccountManager(conf *Config) (am *accounts.Manager, ephemeralKeystore s
if err := os.MkdirAll(keydir, 0700); err != nil {
return nil, "", err
}
-
- return accounts.NewManager(keydir, scryptN, scryptP), ephemeralKeystore, nil
+ // Assemble the account manager and supported backends
+ backends := []accounts.Backend{
+ keystore.NewKeyStore(keydir, scryptN, scryptP),
+ }
+ if ledgerhub, err := usbwallet.NewLedgerHub(); err != nil {
+ glog.V(logger.Warn).Infof("Failed to start Ledger hub, disabling: %v", err)
+ } else {
+ backends = append(backends, ledgerhub)
+ }
+ return accounts.NewManager(backends...), ephemeral, nil
}