ReadEthKey is a utility function to read a keystore file
(credentialPath, passphrase string)
| 135 | |
| 136 | //ReadEthKey is a utility function to read a keystore file |
| 137 | func 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 | } |
| 154 | func reporeResult(ctx context.Context, out chan DialResult, result DialResult) { |
| 155 | select { |
| 156 | case <-ctx.Done(): |