diff options
author | obscuren <geffobscura@gmail.com> | 2014-07-16 19:20:57 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-07-16 19:20:57 +0800 |
commit | 14c4f06100d9f06592097c4ee588d0f83f6b17bd (patch) | |
tree | 4b71ce319e39584a3a44912ad16186b296026c9b /ethutil/bytes.go | |
parent | 8820d4e5ac4db36ac6466fb2ee36bcff9e773558 (diff) | |
download | dexon-14c4f06100d9f06592097c4ee588d0f83f6b17bd.tar dexon-14c4f06100d9f06592097c4ee588d0f83f6b17bd.tar.gz dexon-14c4f06100d9f06592097c4ee588d0f83f6b17bd.tar.bz2 dexon-14c4f06100d9f06592097c4ee588d0f83f6b17bd.tar.lz dexon-14c4f06100d9f06592097c4ee588d0f83f6b17bd.tar.xz dexon-14c4f06100d9f06592097c4ee588d0f83f6b17bd.tar.zst dexon-14c4f06100d9f06592097c4ee588d0f83f6b17bd.zip |
Convert a byte slice to address
Diffstat (limited to 'ethutil/bytes.go')
-rw-r--r-- | ethutil/bytes.go | 10 |
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 +} |