From 14c4f06100d9f06592097c4ee588d0f83f6b17bd Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Wed, 16 Jul 2014 13:20:57 +0200
Subject: [PATCH] Convert a byte slice to address

---
 ethutil/bytes.go | 10 ++++++++++
 1 file changed, 10 insertions(+)

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
+}
-- 
GitLab