neo-go/pkg/crypto/address.go
2019-12-06 12:16:55 +03:00

23 lines
598 B
Go

package crypto
import (
"github.com/CityOfZion/neo-go/pkg/util"
)
// AddressFromUint160 returns the "NEO address" from the given
// Uint160.
func AddressFromUint160(u util.Uint160) string {
// Dont forget to prepend the Address version 0x17 (23) A
b := append([]byte{0x17}, u.BytesBE()...)
return Base58CheckEncode(b)
}
// Uint160DecodeAddress attempts to decode the given NEO address string
// into an Uint160.
func Uint160DecodeAddress(s string) (u util.Uint160, err error) {
b, err := Base58CheckDecode(s)
if err != nil {
return u, err
}
return util.Uint160DecodeBytesBE(b[1:21])
}