Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
1c20313a
Commit
1c20313a
authored
Apr 29, 2016
by
Felix Lange
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2493 from almindor/develop
eth: add personal_importRawKey
parents
cfa999f0
572da73d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
7 deletions
+38
-7
account_manager.go
accounts/account_manager.go
+6
-1
api.go
eth/api.go
+11
-0
web3ext.go
internal/web3ext/web3ext.go
+21
-6
No files found.
accounts/account_manager.go
View file @
1c20313a
...
...
@@ -284,7 +284,12 @@ func (am *Manager) Import(keyJSON []byte, passphrase, newPassphrase string) (Acc
// ImportECDSA stores the given key into the key directory, encrypting it with the passphrase.
func
(
am
*
Manager
)
ImportECDSA
(
priv
*
ecdsa
.
PrivateKey
,
passphrase
string
)
(
Account
,
error
)
{
return
am
.
importKey
(
newKeyFromECDSA
(
priv
),
passphrase
)
key
:=
newKeyFromECDSA
(
priv
)
if
am
.
cache
.
hasAddress
(
key
.
Address
)
{
return
Account
{},
fmt
.
Errorf
(
"account already exists"
)
}
return
am
.
importKey
(
key
,
passphrase
)
}
func
(
am
*
Manager
)
importKey
(
key
*
Key
,
passphrase
string
)
(
Account
,
error
)
{
...
...
eth/api.go
View file @
1c20313a
...
...
@@ -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.
...
...
internal/web3ext/web3ext.go
View file @
1c20313a
...
...
@@ -18,12 +18,13 @@
package
web3ext
var
Modules
=
map
[
string
]
string
{
"txpool"
:
TxPool_JS
,
"admin"
:
Admin_JS
,
"eth"
:
Eth_JS
,
"miner"
:
Miner_JS
,
"debug"
:
Debug_JS
,
"net"
:
Net_JS
,
"txpool"
:
TxPool_JS
,
"admin"
:
Admin_JS
,
"personal"
:
Personal_JS
,
"eth"
:
Eth_JS
,
"miner"
:
Miner_JS
,
"debug"
:
Debug_JS
,
"net"
:
Net_JS
,
}
const
TxPool_JS
=
`
...
...
@@ -175,6 +176,20 @@ web3._extend({
});
`
const
Personal_JS
=
`
web3._extend({
property: 'personal',
methods:
[
new web3._extend.Method({
name: 'importRawKey',
call: 'personal_importRawKey',
params: 2
})
]
});
`
const
Eth_JS
=
`
web3._extend({
property: 'eth',
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment