aboutsummaryrefslogtreecommitdiffstats
path: root/eth/api.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-04-30 05:09:37 +0800
committerFelix Lange <fjl@twurst.com>2016-04-30 05:09:37 +0800
commit1c20313a6a1a35d5f540f878e7c263327c2ccfc1 (patch)
tree4835cd7f3085edb6c6ed41b62edf15be9f9e42dc /eth/api.go
parentcfa999f006c30613aa4acce42d8edad056f39c10 (diff)
parent572da73d4d475db0443f457d9383a3d513f189ee (diff)
downloadgo-tangerine-1c20313a6a1a35d5f540f878e7c263327c2ccfc1.tar.gz
go-tangerine-1c20313a6a1a35d5f540f878e7c263327c2ccfc1.tar.zst
go-tangerine-1c20313a6a1a35d5f540f878e7c263327c2ccfc1.zip
Merge pull request #2493 from almindor/develop
eth: add personal_importRawKey
Diffstat (limited to 'eth/api.go')
-rw-r--r--eth/api.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/eth/api.go b/eth/api.go
index 02b34541f..2c84cf471 100644
--- a/eth/api.go
+++ b/eth/api.go
@@ -18,6 +18,7 @@ package eth
import (
"bytes"
+ "encoding/hex"
"encoding/json"
"errors"
"fmt"
@@ -448,6 +449,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.