MCPcopy Create free account
hub / github.com/DOSNetwork/core / ReadEthKey

Function ReadEthKey

onchain/eth_helpers.go:137–153  ·  view source on GitHub ↗

ReadEthKey is a utility function to read a keystore file

(credentialPath, passphrase string)

Source from the content-addressed store, hash-verified

135
136//ReadEthKey is a utility function to read a keystore file
137func ReadEthKey(credentialPath, passphrase string) (key *keystore.Key, err error) {
138 newKeyStore := keystore.NewKeyStore(credentialPath, keystore.StandardScryptN, keystore.StandardScryptP)
139 if len(newKeyStore.Accounts()) < 1 {
140 return nil, errors.New("No Account")
141 }
142 usrKeyPath := newKeyStore.Accounts()[0].URL.Path
143
144 keyJson, err := ioutil.ReadFile(usrKeyPath)
145 if err != nil {
146 return
147 }
148
149 key, err = keystore.DecryptKey(keyJson, passphrase)
150
151 return
152
153}
154func reporeResult(ctx context.Context, out chan DialResult, result DialResult) {
155 select {
156 case <-ctx.Done():

Callers 1

TestReadEthKeyFunction · 0.85

Calls 1

NewMethod · 0.65

Tested by 1

TestReadEthKeyFunction · 0.68