2019-02-13 18:18:47 +00:00
|
|
|
package wrappers
|
|
|
|
|
|
|
|
import (
|
2019-12-25 12:22:02 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/encoding/address"
|
2019-02-13 18:18:47 +00:00
|
|
|
)
|
|
|
|
|
2019-09-03 14:51:37 +00:00
|
|
|
// ValidateAddressResponse represents response to validate address call.
|
2019-02-13 18:18:47 +00:00
|
|
|
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
|
2019-12-25 12:22:02 +00:00
|
|
|
func ValidateAddress(addr interface{}) ValidateAddressResponse {
|
|
|
|
resp := ValidateAddressResponse{Address: addr}
|
|
|
|
if addr, ok := addr.(string); ok {
|
|
|
|
_, err := address.DecodeUint160(addr)
|
2019-02-13 18:18:47 +00:00
|
|
|
resp.IsValid = err == nil
|
|
|
|
}
|
|
|
|
return resp
|
|
|
|
}
|