aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil/common.go
diff options
context:
space:
mode:
Diffstat (limited to 'ethutil/common.go')
-rw-r--r--ethutil/common.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/ethutil/common.go b/ethutil/common.go
index 3ade7fd16..29854c882 100644
--- a/ethutil/common.go
+++ b/ethutil/common.go
@@ -64,6 +64,19 @@ func DefaultDataDir() string {
return path.Join(usr.HomeDir, ".ethereum")
}
}
+
+func FromHex(s string) []byte {
+ if len(s) > 1 {
+ if s[0:2] == "0x" {
+ s = s[2:]
+ }
+ if len(s)%2 == 1 {
+ s = "0" + s
+ }
+ return Hex2Bytes(s)
+ }
+ return nil
+}
func IsWindows() bool {
return runtime.GOOS == "windows"
}