Samples and disams cmd for evm code

This commit is contained in:
obscuren
2015-01-29 14:46:59 +01:00
parent 84adf77bf3
commit ddf17d93ac
4 changed files with 103 additions and 5 deletions

View File

@ -35,6 +35,19 @@ import (
"github.com/ethereum/go-ethereum/xeth"
)
func toHex(b []byte) string {
return "0x" + ethutil.Bytes2Hex(b)
}
func fromHex(s string) []byte {
if len(s) > 1 {
if s[0:2] == "0x" {
s = s[2:]
}
return ethutil.Hex2Bytes(s)
}
return nil
}
type RpcServer interface {
Start()
Stop()
@ -163,7 +176,7 @@ func (p *EthereumApi) GetCodeAt(args *GetCodeAtArgs, reply *interface{}) error {
}
func (p *EthereumApi) Sha3(args *Sha3Args, reply *interface{}) error {
*reply = ethutil.Bytes2Hex(crypto.Sha3(ethutil.Hex2Bytes(args.Data)))
*reply = toHex(crypto.Sha3(fromHex(args.Data)))
return nil
}