From c64a460ba0fcf13aa27493b23fc455db32e5c898 Mon Sep 17 00:00:00 2001 From: Lorenzo Manacorda Date: Thu, 15 Mar 2018 20:00:13 +0100 Subject: [PATCH] common: document Address conversion functions The documentation is especially supposed to clarify which function users should call to convert a string containing an address into an Address struct. --- common/types.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/types.go b/common/types.go index fdc67480c2..56676ac0b6 100644 --- a/common/types.go +++ b/common/types.go @@ -143,9 +143,15 @@ func BytesToAddress(b []byte) Address { a.SetBytes(b) return a } + +// StringToAddress converts an arbitrary string into an Address. func StringToAddress(s string) Address { return BytesToAddress([]byte(s)) } -func BigToAddress(b *big.Int) Address { return BytesToAddress(b.Bytes()) } -func HexToAddress(s string) Address { return BytesToAddress(FromHex(s)) } + +// BigToAddress converts an arbitary *big.Int into an Address. +func BigToAddress(b *big.Int) Address { return BytesToAddress(b.Bytes()) } + +// HexToAddress converts a string containing an address into an Address. +func HexToAddress(s string) Address { return BytesToAddress(FromHex(s)) } // IsHexAddress verifies whether a string can represent a valid hex-encoded // Ethereum address or not.