forked from cerc-io/plugeth
Convert a byte slice to address
This commit is contained in:
parent
8820d4e5ac
commit
14c4f06100
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user