diff options
author | Martin Holst Swende <martin@swende.se> | 2019-02-05 18:23:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-05 18:23:57 +0800 |
commit | 43e8efe8955b8bb1fab7bfced33a6302fb69e48e (patch) | |
tree | 3db96494c913b31be950f5580bf49a82141b9255 /node/config.go | |
parent | 520024dfd689d264807b7fe1fc28deba51d6ab20 (diff) | |
download | go-tangerine-43e8efe8955b8bb1fab7bfced33a6302fb69e48e.tar go-tangerine-43e8efe8955b8bb1fab7bfced33a6302fb69e48e.tar.gz go-tangerine-43e8efe8955b8bb1fab7bfced33a6302fb69e48e.tar.bz2 go-tangerine-43e8efe8955b8bb1fab7bfced33a6302fb69e48e.tar.lz go-tangerine-43e8efe8955b8bb1fab7bfced33a6302fb69e48e.tar.xz go-tangerine-43e8efe8955b8bb1fab7bfced33a6302fb69e48e.tar.zst go-tangerine-43e8efe8955b8bb1fab7bfced33a6302fb69e48e.zip |
accounts, eth, clique, signer: support for external signer API (#18079)
* accounts, eth, clique: implement external backend + move sighash calc to backend
* signer: implement account_Version on external API
* accounts/external: enable ipc, add copyright
* accounts, internal, signer: formatting
* node: go fmt
* flags: disallow --dev in combo with --externalsigner
* accounts: remove clique-specific signing method, replace with more generic
* accounts, consensus: formatting + fix error in tests
* signer/core: remove (test-) import cycle
* clique: remove unused import
* accounts: remove CliqueHash and avoid dependency on package crypto
* consensus/clique: unduplicate header encoding
Diffstat (limited to 'node/config.go')
-rw-r--r-- | node/config.go | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/node/config.go b/node/config.go index 99f325840..ff0725aab 100644 --- a/node/config.go +++ b/node/config.go @@ -27,6 +27,7 @@ import ( "sync" "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/accounts/external" "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/accounts/usbwallet" "github.com/ethereum/go-ethereum/common" @@ -80,6 +81,9 @@ type Config struct { // is created by New and destroyed when the node is stopped. KeyStoreDir string `toml:",omitempty"` + // ExternalSigner specifies an external URI for a clef-type signer + ExternalSigner string `toml:"omitempty"` + // UseLightweightKDF lowers the memory and CPU requirements of the key store // scrypt KDF at the expense of security. UseLightweightKDF bool `toml:",omitempty"` @@ -462,23 +466,37 @@ func makeAccountManager(conf *Config) (*accounts.Manager, string, error) { return nil, "", err } // Assemble the account manager and supported backends - backends := []accounts.Backend{ - keystore.NewKeyStore(keydir, scryptN, scryptP), - } - if !conf.NoUSB { - // Start a USB hub for Ledger hardware wallets - if ledgerhub, err := usbwallet.NewLedgerHub(); err != nil { - log.Warn(fmt.Sprintf("Failed to start Ledger hub, disabling: %v", err)) + backends := []accounts.Backend{} + if len(conf.ExternalSigner) > 0 { + log.Info("Using external signer", "url", conf.ExternalSigner) + if extapi, err := external.NewExternalBackend(conf.ExternalSigner); err == nil { + backends = append(backends, extapi) } else { - backends = append(backends, ledgerhub) + log.Info("Error configuring external signer", "error", err) } - // Start a USB hub for Trezor hardware wallets - if trezorhub, err := usbwallet.NewTrezorHub(); err != nil { - log.Warn(fmt.Sprintf("Failed to start Trezor hub, disabling: %v", err)) - } else { - backends = append(backends, trezorhub) + } + if len(backends) == 0 { + // For now, we're using EITHER external signer OR local signers. + // If/when we implement some form of lockfile for USB and keystore wallets, + // we can have both, but it's very confusing for the user to see the same + // accounts in both externally and locally, plus very racey. + backends = append(backends, keystore.NewKeyStore(keydir, scryptN, scryptP)) + if !conf.NoUSB { + // Start a USB hub for Ledger hardware wallets + if ledgerhub, err := usbwallet.NewLedgerHub(); err != nil { + log.Warn(fmt.Sprintf("Failed to start Ledger hub, disabling: %v", err)) + } else { + backends = append(backends, ledgerhub) + } + // Start a USB hub for Trezor hardware wallets + if trezorhub, err := usbwallet.NewTrezorHub(); err != nil { + log.Warn(fmt.Sprintf("Failed to start Trezor hub, disabling: %v", err)) + } else { + backends = append(backends, trezorhub) + } } } + return accounts.NewManager(backends...), ephemeral, nil } |