frostfs-api-go/chain/address.go

31 lines
563 B
Go
Raw Normal View History

2019-11-18 13:34:06 +00:00
package chain
import (
"crypto/ecdsa"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
2019-11-18 13:34:06 +00:00
)
// WalletAddress implements NEO address.
type WalletAddress [AddressLength]byte
const (
// AddressLength contains size of address,
// 1 byte of address version + 20 bytes of ScriptHash + 4 bytes of checksum.
2019-11-18 13:34:06 +00:00
AddressLength = 25
)
// KeyToAddress returns NEO address composed from public key.
func KeyToAddress(key *ecdsa.PublicKey) string {
if key == nil {
2019-11-18 13:34:06 +00:00
return ""
}
neoPublicKey := keys.PublicKey{
X: key.X,
Y: key.Y,
2019-11-18 13:34:06 +00:00
}
return neoPublicKey.Address()
2019-11-18 13:34:06 +00:00
}