aboutsummaryrefslogtreecommitdiffstats
path: root/console/console.go
diff options
context:
space:
mode:
authorbas-vk <bas-vk@users.noreply.github.com>2016-10-29 03:25:49 +0800
committerFelix Lange <fjl@twurst.com>2016-10-29 03:25:49 +0800
commitb59c8399fbe42390a3d41e945d03b1f21c1a9b8d (patch)
treee7fd68d7619ef4cc2f7739c6fb85096238ae7a17 /console/console.go
parent289b30715d097edafd5562f66cb3567a70b2d330 (diff)
downloadgo-tangerine-b59c8399fbe42390a3d41e945d03b1f21c1a9b8d.tar
go-tangerine-b59c8399fbe42390a3d41e945d03b1f21c1a9b8d.tar.gz
go-tangerine-b59c8399fbe42390a3d41e945d03b1f21c1a9b8d.tar.bz2
go-tangerine-b59c8399fbe42390a3d41e945d03b1f21c1a9b8d.tar.lz
go-tangerine-b59c8399fbe42390a3d41e945d03b1f21c1a9b8d.tar.xz
go-tangerine-b59c8399fbe42390a3d41e945d03b1f21c1a9b8d.tar.zst
go-tangerine-b59c8399fbe42390a3d41e945d03b1f21c1a9b8d.zip
internal/ethapi: add personal_sign and fix eth_sign to hash message (#2940)
This commit includes several API changes: - The behavior of eth_sign is changed. It now accepts an arbitrary message, prepends the well-known string \x19Ethereum Signed Message:\n<length of message> hashes the result using keccak256 and calculates the signature of the hash. This breaks backwards compatability! - personal_sign(hash, address [, password]) is added. It has the same semantics as eth_sign but also accepts a password. The private key used to sign the hash is temporarily unlocked in the scope of the request. - personal_recover(message, signature) is added and returns the address for the account that created a signature.
Diffstat (limited to 'console/console.go')
-rw-r--r--console/console.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/console/console.go b/console/console.go
index f224f0c2e..3cde9b8f5 100644
--- a/console/console.go
+++ b/console/console.go
@@ -156,10 +156,9 @@ func (c *Console) init(preload []string) error {
if err != nil {
return err
}
- // Override the unlockAccount and newAccount methods since these require user interaction.
- // Assign the jeth.unlockAccount and jeth.newAccount in the Console the original web3 callbacks.
- // These will be called by the jeth.* methods after they got the password from the user and send
- // the original web3 request to the backend.
+ // Override the unlockAccount, newAccount and sign methods since these require user interaction.
+ // Assign these method in the Console the original web3 callbacks. These will be called by the jeth.*
+ // methods after they got the password from the user and send the original web3 request to the backend.
if obj := personal.Object(); obj != nil { // make sure the personal api is enabled over the interface
if _, err = c.jsre.Run(`jeth.unlockAccount = personal.unlockAccount;`); err != nil {
return fmt.Errorf("personal.unlockAccount: %v", err)
@@ -167,8 +166,12 @@ func (c *Console) init(preload []string) error {
if _, err = c.jsre.Run(`jeth.newAccount = personal.newAccount;`); err != nil {
return fmt.Errorf("personal.newAccount: %v", err)
}
+ if _, err = c.jsre.Run(`jeth.sign = personal.sign;`); err != nil {
+ return fmt.Errorf("personal.sign: %v", err)
+ }
obj.Set("unlockAccount", bridge.UnlockAccount)
obj.Set("newAccount", bridge.NewAccount)
+ obj.Set("sign", bridge.Sign)
}
}
// The admin.sleep and admin.sleepBlocks are offered by the console and not by the RPC layer.