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"
|
"math/big"
|
||||||
|
|
||||||
"github.com/CityOfZion/neo-go/pkg/crypto/hash"
|
"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/io"
|
||||||
"github.com/CityOfZion/neo-go/pkg/vm/opcode"
|
"github.com/CityOfZion/neo-go/pkg/vm/opcode"
|
||||||
"github.com/pkg/errors"
|
"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.
|
// Address returns a base58-encoded NEO-specific address based on the key hash.
|
||||||
func (p *PublicKey) Address() string {
|
func (p *PublicKey) Address() string {
|
||||||
var b = p.Signature()
|
sig := hash.Hash160(p.GetVerificationScript())
|
||||||
|
|
||||||
b = append([]byte{0x17}, b...)
|
return address.EncodeUint160(sig)
|
||||||
|
|
||||||
return base58.CheckEncode(b)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify returns true if the signature is valid and corresponds
|
// Verify returns true if the signature is valid and corresponds
|
||||||
|
|
Loading…
Reference in a new issue