aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil
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
parent8820d4e5ac4db36ac6466fb2ee36bcff9e773558 (diff)
downloadgo-tangerine-14c4f06100d9f06592097c4ee588d0f83f6b17bd.tar
go-tangerine-14c4f06100d9f06592097c4ee588d0f83f6b17bd.tar.gz
go-tangerine-14c4f06100d9f06592097c4ee588d0f83f6b17bd.tar.bz2
go-tangerine-14c4f06100d9f06592097c4ee588d0f83f6b17bd.tar.lz
go-tangerine-14c4f06100d9f06592097c4ee588d0f83f6b17bd.tar.xz
go-tangerine-14c4f06100d9f06592097c4ee588d0f83f6b17bd.tar.zst
go-tangerine-14c4f06100d9f06592097c4ee588d0f83f6b17bd.zip
Convert a byte slice to address
Diffstat (limited to 'ethutil')
-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
+}