mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 09:42:22 +00:00
keys: reuse address package for address generation
Deduplicates code and makes prefix overridable.
This commit is contained in:
parent
b7702f3a2e
commit
e25133a385
1 changed files with 3 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue