From e25133a3859aa05cd0eebf3c4fbf08620e7dec75 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 25 Dec 2019 16:03:39 +0300 Subject: [PATCH] keys: reuse address package for address generation Deduplicates code and makes prefix overridable. --- pkg/crypto/keys/publickey.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/crypto/keys/publickey.go b/pkg/crypto/keys/publickey.go index 64cbb3f54..13aba0106 100644 --- a/pkg/crypto/keys/publickey.go +++ b/pkg/crypto/keys/publickey.go @@ -10,7 +10,7 @@ import ( "math/big" "github.com/CityOfZion/neo-go/pkg/crypto/hash" - "github.com/CityOfZion/neo-go/pkg/encoding/base58" + "github.com/CityOfZion/neo-go/pkg/encoding/address" "github.com/CityOfZion/neo-go/pkg/io" "github.com/CityOfZion/neo-go/pkg/vm/opcode" "github.com/pkg/errors" @@ -242,11 +242,9 @@ func (p *PublicKey) Signature() []byte { // Address returns a base58-encoded NEO-specific address based on the key hash. func (p *PublicKey) Address() string { - var b = p.Signature() + sig := hash.Hash160(p.GetVerificationScript()) - b = append([]byte{0x17}, b...) - - return base58.CheckEncode(b) + return address.EncodeUint160(sig) } // Verify returns true if the signature is valid and corresponds