mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-29 23:33:37 +00:00
001a0e601e
* Add RPC Server method ValidateAddress - implement rpc method validateaddress (https://docs.neo.org/en-us/node/cli/2.9.4/api/validateaddress.html) - add tests - add to README.md * revert go.sum * remove break * more tests and C# errors * simplify * fix after master merge
21 lines
590 B
Go
21 lines
590 B
Go
package wrappers
|
|
|
|
import (
|
|
"github.com/CityOfZion/neo-go/pkg/crypto"
|
|
)
|
|
|
|
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(address interface{}) ValidateAddressResponse {
|
|
resp := ValidateAddressResponse{Address: address}
|
|
if address, ok := address.(string); ok {
|
|
_, err := crypto.Uint160DecodeAddress(address)
|
|
resp.IsValid = err == nil
|
|
}
|
|
return resp
|
|
}
|