@@ -25,6 +25,7 @@ import (
25
25
26
26
"github.com/ethereum/go-ethereum/accounts"
27
27
"github.com/ethereum/go-ethereum/accounts/keystore"
28
+ "github.com/ethereum/go-ethereum/crypto"
28
29
)
29
30
30
31
const (
@@ -176,6 +177,11 @@ func (ks *KeyStore) NewAccount(passphrase string) (*Account, error) {
176
177
return & Account {account }, nil
177
178
}
178
179
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
+
179
185
// ExportKey exports as a JSON key, encrypted with newPassphrase.
180
186
func (ks * KeyStore ) ExportKey (account * Account , passphrase , newPassphrase string ) (key []byte , _ error ) {
181
187
return ks .keystore .Export (account .account , passphrase , newPassphrase )
@@ -190,9 +196,17 @@ func (ks *KeyStore) ImportKey(keyJSON []byte, passphrase, newPassphrase string)
190
196
return & Account {acc }, nil
191
197
}
192
198
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
196
210
}
197
211
198
212
// ImportPreSaleKey decrypts the given Ethereum presale wallet and stores
0 commit comments