diff options
Diffstat (limited to 'rpc/packages.go')
-rw-r--r-- | rpc/packages.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/rpc/packages.go b/rpc/packages.go index 4302f6018..b25660b25 100644 --- a/rpc/packages.go +++ b/rpc/packages.go @@ -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 } |