diff options
author | bas-vk <bas-vk@users.noreply.github.com> | 2016-10-29 03:25:49 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-10-29 03:25:49 +0800 |
commit | b59c8399fbe42390a3d41e945d03b1f21c1a9b8d (patch) | |
tree | e7fd68d7619ef4cc2f7739c6fb85096238ae7a17 /common | |
parent | 289b30715d097edafd5562f66cb3567a70b2d330 (diff) | |
download | dexon-b59c8399fbe42390a3d41e945d03b1f21c1a9b8d.tar dexon-b59c8399fbe42390a3d41e945d03b1f21c1a9b8d.tar.gz dexon-b59c8399fbe42390a3d41e945d03b1f21c1a9b8d.tar.bz2 dexon-b59c8399fbe42390a3d41e945d03b1f21c1a9b8d.tar.lz dexon-b59c8399fbe42390a3d41e945d03b1f21c1a9b8d.tar.xz dexon-b59c8399fbe42390a3d41e945d03b1f21c1a9b8d.tar.zst dexon-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 'common')
-rw-r--r-- | common/bytes.go | 2 | ||||
-rw-r--r-- | common/registrar/ethreg/api.go | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/common/bytes.go b/common/bytes.go index 4fb016a97..b9fb3b2da 100644 --- a/common/bytes.go +++ b/common/bytes.go @@ -37,7 +37,7 @@ func ToHex(b []byte) string { func FromHex(s string) []byte { if len(s) > 1 { - if s[0:2] == "0x" { + if s[0:2] == "0x" || s[0:2] == "0X" { s = s[2:] } if len(s)%2 == 1 { diff --git a/common/registrar/ethreg/api.go b/common/registrar/ethreg/api.go index 6dd0ef46f..10050a545 100644 --- a/common/registrar/ethreg/api.go +++ b/common/registrar/ethreg/api.go @@ -257,7 +257,7 @@ func (be *registryAPIBackend) Transact(fromStr, toStr, nonceStr, valueStr, gasSt tx = types.NewTransaction(nonce, to, value, gas, price, data) } - signature, err := be.am.Sign(from, tx.SigHash().Bytes()) + signature, err := be.am.SignEthereum(from, tx.SigHash().Bytes()) if err != nil { return "", err } |