neoneo-go/pkg/rpc/wrappers/validate_address.go
Roman Khimov e685e9bf9a address: move into its own package
Doesn't really belong to the crypto.
2019-12-25 15:22:02 +03:00

22 lines
652 B
Go

package wrappers
import (
"github.com/CityOfZion/neo-go/pkg/encoding/address"
)
// ValidateAddressResponse represents response to validate address call.
type ValidateAddressResponse struct {
Address interface{} `json:"address"`
IsValid bool `json:"isvalid"`
}
// ValidateAddress verifies that the address is a correct NEO address
// see https://docs.neo.org/en-us/node/cli/2.9.4/api/validateaddress.html
func ValidateAddress(addr interface{}) ValidateAddressResponse {
resp := ValidateAddressResponse{Address: addr}
if addr, ok := addr.(string); ok {
_, err := address.DecodeUint160(addr)
resp.IsValid = err == nil
}
return resp
}