diff options
author | Ales Katona <ales@coinbase.com> | 2016-04-26 01:23:40 +0800 |
---|---|---|
committer | Ales Katona <ales@coinbase.com> | 2016-04-28 23:11:40 +0800 |
commit | 572da73d4d475db0443f457d9383a3d513f189ee (patch) | |
tree | e5a13000b505ebc2576e58e6c371da8838d56f40 /eth/api.go | |
parent | 70b8b54cd2413fb01e279890b2ddb5eb9bc227c2 (diff) | |
download | go-tangerine-572da73d4d475db0443f457d9383a3d513f189ee.tar go-tangerine-572da73d4d475db0443f457d9383a3d513f189ee.tar.gz go-tangerine-572da73d4d475db0443f457d9383a3d513f189ee.tar.bz2 go-tangerine-572da73d4d475db0443f457d9383a3d513f189ee.tar.lz go-tangerine-572da73d4d475db0443f457d9383a3d513f189ee.tar.xz go-tangerine-572da73d4d475db0443f457d9383a3d513f189ee.tar.zst go-tangerine-572da73d4d475db0443f457d9383a3d513f189ee.zip |
eth: add personal_importRawKey for runtime private key import
Diffstat (limited to 'eth/api.go')
-rw-r--r-- | eth/api.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/eth/api.go b/eth/api.go index a0b1f8ac2..4ebc9b2a0 100644 --- a/eth/api.go +++ b/eth/api.go @@ -18,6 +18,7 @@ package eth import ( "bytes" + "encoding/hex" "encoding/json" "errors" "fmt" @@ -439,6 +440,16 @@ func (s *PrivateAccountAPI) NewAccount(password string) (common.Address, error) return common.Address{}, err } +func (s *PrivateAccountAPI) ImportRawKey(privkey string, password string) (common.Address, error) { + hexkey, err := hex.DecodeString(privkey) + if err != nil { + return common.Address{}, err + } + + acc, err := s.am.ImportECDSA(crypto.ToECDSA(hexkey), password) + return acc.Address, err +} + // UnlockAccount will unlock the account associated with the given address with // the given password for duration seconds. If duration is nil it will use a // default of 300 seconds. It returns an indication if the account was unlocked. |