mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-06 09:55:09 +00:00
Add RPC Server method ValidateAddress (#134)
* 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
This commit is contained in:
parent
763452fe33
commit
001a0e601e
4 changed files with 64 additions and 9 deletions
21
pkg/rpc/wrappers/validate_address.go
Normal file
21
pkg/rpc/wrappers/validate_address.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue