aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil/bytes.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-28 19:14:56 +0800
committerobscuren <geffobscura@gmail.com>2014-05-28 19:14:56 +0800
commit65722aeeca0fed685a00d660ddd7bb667ac3be9b (patch)
treec64f7024224eb6d2e45eefff6c9074fcc5ad1e05 /ethutil/bytes.go
parent8278ba5e45bc02c8d21416f343b0ae38b5a6431c (diff)
downloaddexon-65722aeeca0fed685a00d660ddd7bb667ac3be9b.tar
dexon-65722aeeca0fed685a00d660ddd7bb667ac3be9b.tar.gz
dexon-65722aeeca0fed685a00d660ddd7bb667ac3be9b.tar.bz2
dexon-65722aeeca0fed685a00d660ddd7bb667ac3be9b.tar.lz
dexon-65722aeeca0fed685a00d660ddd7bb667ac3be9b.tar.xz
dexon-65722aeeca0fed685a00d660ddd7bb667ac3be9b.tar.zst
dexon-65722aeeca0fed685a00d660ddd7bb667ac3be9b.zip
Added StringToBytesFunc
Diffstat (limited to 'ethutil/bytes.go')
-rw-r--r--ethutil/bytes.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/ethutil/bytes.go b/ethutil/bytes.go
index b298675a2..075e40b4c 100644
--- a/ethutil/bytes.go
+++ b/ethutil/bytes.go
@@ -88,3 +88,13 @@ func IsHex(str string) bool {
l := len(str)
return l >= 4 && l%2 == 0 && str[0:2] == "0x"
}
+
+func StringToByteFunc(str string, cb func(str string) []byte) (ret []byte) {
+ if str[0:2] == "0x" {
+ ret = FromHex(str[2:])
+ } else {
+ ret = cb(str)
+ }
+
+ return
+}