@@ -25,6 +25,7 @@ import (
2525
2626 "github.com/ethereum/go-ethereum/accounts"
2727 "github.com/ethereum/go-ethereum/accounts/keystore"
28+ "github.com/ethereum/go-ethereum/crypto"
2829)
2930
3031const (
@@ -176,6 +177,11 @@ func (ks *KeyStore) NewAccount(passphrase string) (*Account, error) {
176177 return & Account {account }, nil
177178}
178179
180+ // UpdateAccount changes the passphrase of an existing account.
181+ func (ks * KeyStore ) UpdateAccount (account * Account , passphrase , newPassphrase string ) error {
182+ return ks .keystore .Update (account .account , passphrase , newPassphrase )
183+ }
184+
179185// ExportKey exports as a JSON key, encrypted with newPassphrase.
180186func (ks * KeyStore ) ExportKey (account * Account , passphrase , newPassphrase string ) (key []byte , _ error ) {
181187 return ks .keystore .Export (account .account , passphrase , newPassphrase )
@@ -190,9 +196,17 @@ func (ks *KeyStore) ImportKey(keyJSON []byte, passphrase, newPassphrase string)
190196 return & Account {acc }, nil
191197}
192198
193- // UpdateAccount changes the passphrase of an existing account.
194- func (ks * KeyStore ) UpdateAccount (account * Account , passphrase , newPassphrase string ) error {
195- return ks .keystore .Update (account .account , passphrase , newPassphrase )
199+ // ImportECDSAKey stores the given encrypted JSON key into the key directory.
200+ func (ks * KeyStore ) ImportECDSAKey (key []byte , passphrase string ) (account * Account , _ error ) {
201+ privkey , err := crypto .ToECDSA (key )
202+ if err != nil {
203+ return nil , err
204+ }
205+ acc , err := ks .keystore .ImportECDSA (privkey , passphrase )
206+ if err != nil {
207+ return nil , err
208+ }
209+ return & Account {acc }, nil
196210}
197211
198212// ImportPreSaleKey decrypts the given Ethereum presale wallet and stores
0 commit comments