diff options
author | Guillaume Ballet <gballet@gmail.com> | 2019-06-05 21:27:37 +0800 |
---|---|---|
committer | Martin Holst Swende <martin@swende.se> | 2019-06-05 21:27:37 +0800 |
commit | b8ca3cb7d2063911bb4e0a28fcb746e7e27d145d (patch) | |
tree | d8915e2c2ccebe083936fb52ec91f0cc4176bad5 /signer/core/api.go | |
parent | 7c9307c683702b5be4ab2c409cef45e017d6c62d (diff) | |
download | go-tangerine-b8ca3cb7d2063911bb4e0a28fcb746e7e27d145d.tar go-tangerine-b8ca3cb7d2063911bb4e0a28fcb746e7e27d145d.tar.gz go-tangerine-b8ca3cb7d2063911bb4e0a28fcb746e7e27d145d.tar.bz2 go-tangerine-b8ca3cb7d2063911bb4e0a28fcb746e7e27d145d.tar.lz go-tangerine-b8ca3cb7d2063911bb4e0a28fcb746e7e27d145d.tar.xz go-tangerine-b8ca3cb7d2063911bb4e0a28fcb746e7e27d145d.tar.zst go-tangerine-b8ca3cb7d2063911bb4e0a28fcb746e7e27d145d.zip |
cmd/clef: enable smartcard hub (#19649)
* cmd/clef: Enable smartcard hub
* clef: don't error is pcsc is not installed
Diffstat (limited to 'signer/core/api.go')
-rw-r--r-- | signer/core/api.go | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/signer/core/api.go b/signer/core/api.go index 9798ff2b5..251ee55dc 100644 --- a/signer/core/api.go +++ b/signer/core/api.go @@ -22,11 +22,13 @@ import ( "errors" "fmt" "math/big" + "os" "reflect" "strings" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts/keystore" + "github.com/ethereum/go-ethereum/accounts/scwallet" "github.com/ethereum/go-ethereum/accounts/usbwallet" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -124,7 +126,7 @@ type Metadata struct { Origin string `json:"Origin"` } -func StartClefAccountManager(ksLocation string, nousb, lightKDF bool) *accounts.Manager { +func StartClefAccountManager(ksLocation string, nousb, lightKDF bool, scpath string) *accounts.Manager { var ( backends []accounts.Backend n, p = keystore.StandardScryptN, keystore.StandardScryptP @@ -159,6 +161,26 @@ func StartClefAccountManager(ksLocation string, nousb, lightKDF bool) *accounts. log.Debug("Trezor support enabled via WebUSB") } } + + // Start a smart card hub + if len(scpath) > 0 { + // Sanity check that the smartcard path is valid + fi, err := os.Stat(scpath) + if err != nil { + log.Info("Smartcard socket file missing, disabling", "err", err) + } else { + if fi.Mode()&os.ModeType != os.ModeSocket { + log.Error("Invalid smartcard socket file type", "path", scpath, "type", fi.Mode().String()) + } else { + if schub, err := scwallet.NewHub(scpath, scwallet.Scheme, ksLocation); err != nil { + log.Warn(fmt.Sprintf("Failed to start smart card hub, disabling: %v", err)) + } else { + backends = append(backends, schub) + } + } + } + } + // Clef doesn't allow insecure http account unlock. return accounts.NewManager(&accounts.Config{InsecureUnlockAllowed: false}, backends...) } |