From fda4d02f946dcef8b6896c8798c318876de0138d Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Tue, 10 Mar 2015 18:08:31 -0500 Subject: Left-pad odd length hex inputs and tests --- rpc/util.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'rpc/util.go') diff --git a/rpc/util.go b/rpc/util.go index fb4efdb45..a0d858a67 100644 --- a/rpc/util.go +++ b/rpc/util.go @@ -132,6 +132,9 @@ func fromHex(s string) []byte { if s[0:2] == "0x" { s = s[2:] } + if len(s)%2 == 1 { + s = "0" + s + } return ethutil.Hex2Bytes(s) } return nil -- cgit v1.2.3 From 499f816e3034c3e781f8ad35da070c9989cf6e3c Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Tue, 10 Mar 2015 19:10:02 -0500 Subject: Output hex should be prepended with 0x --- rpc/util.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'rpc/util.go') diff --git a/rpc/util.go b/rpc/util.go index a0d858a67..8ff3c6d31 100644 --- a/rpc/util.go +++ b/rpc/util.go @@ -91,7 +91,7 @@ func UnmarshalRawMessages(b []byte, iface interface{}, number *int64) (err error func (self JsonWrapper) Send(writer io.Writer, v interface{}) (n int, err error) { var payload []byte - payload, err = json.Marshal(v) + payload, err = json.MarshalIndent(v, "", "\t") if err != nil { rpclogger.Fatalln("Error marshalling JSON", err) return 0, err @@ -127,6 +127,7 @@ func toHex(b []byte) string { } return "0x" + hex } + func fromHex(s string) []byte { if len(s) > 1 { if s[0:2] == "0x" { -- cgit v1.2.3