aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil/bytes.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-07-16 19:20:57 +0800
committerobscuren <geffobscura@gmail.com>2014-07-16 19:20:57 +0800
commit14c4f06100d9f06592097c4ee588d0f83f6b17bd (patch)
tree4b71ce319e39584a3a44912ad16186b296026c9b /ethutil/bytes.go
parent8820d4e5ac4db36ac6466fb2ee36bcff9e773558 (diff)
downloaddexon-14c4f06100d9f06592097c4ee588d0f83f6b17bd.tar.gz
dexon-14c4f06100d9f06592097c4ee588d0f83f6b17bd.tar.zst
dexon-14c4f06100d9f06592097c4ee588d0f83f6b17bd.zip
Convert a byte slice to address
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 d68a69433..07584d0bf 100644
--- a/ethutil/bytes.go
+++ b/ethutil/bytes.go
@@ -149,3 +149,13 @@ func LeftPadBytes(slice []byte, l int) []byte {
return padded
}
+
+func Address(slice []byte) []byte {
+ if len(slice) < 20 {
+ slice = LeftPadBytes(slice, 20)
+ } else if len(slice) > 20 {
+ slice = slice[len(slice)-20:]
+ }
+
+ return slice
+}