2019-02-25 22:44:14 +00:00
|
|
|
package address
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/hex"
|
|
|
|
|
|
|
|
"github.com/CityOfZion/neo-go/pkg/crypto/base58"
|
|
|
|
)
|
|
|
|
|
2019-03-17 18:26:35 +00:00
|
|
|
// ToScriptHash converts an address to a script hash
|
2019-02-25 22:44:14 +00:00
|
|
|
func ToScriptHash(address string) string {
|
|
|
|
|
|
|
|
decodedAddressAsBytes, err := base58.Decode(address)
|
|
|
|
if err != nil {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
decodedAddressAsHex := hex.EncodeToString(decodedAddressAsBytes)
|
|
|
|
scriptHash := (decodedAddressAsHex[2:42])
|
|
|
|
return scriptHash
|
|
|
|
}
|