Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verifyaddress returns a poorly-formatted JSON response in v2. #226

Closed
NotoriousPyro opened this issue Jan 8, 2018 · 1 comment
Closed

Comments

@NotoriousPyro
Copy link

If you query a valid address:
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"validateaddress","params":["MBH5mtwPvNFqMqb6S9HN5hNCG5Wbu8WaCb"],"id":1}' http://127.0.0.1:8820/rpc/v2
You get the expected:

{
        "id" : 1,
        "jsonrpc" : "2.0",
        "result" :
        {
                "address-type" : "p2kh(main-net)",
                "is-valid" : true,
                "message" : "valid address ",
                "test-net" : false
        }
}

Which is useful for when you're creating a struct like so:

type ValidateAddress struct {
	IsValid		bool		`json:"is-valid"`
	TestNet		bool		`json:"test-net"`
}

However, the struct becomes somewhat useless because of the response when you query an invalid address (as it doesn't just switch is-valid to false...):
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"validateaddress","params":["MBH5mtwPvNFqMqb6S9HN5hNCG5Wbu8WaCc"],"id":1}' http://127.0.0.1:8820/rpc/v2

{
        "error" :
        {
                "code" : 1021,
                "message" : "the argument ('MBH5mtwPvNFqMqb6S9HN5hNCG5Wbu8WaCc') for option '--PAYMENT_ADDRESS' is invalid"
        },
        "id" : 1,
        "jsonrpc" : "2.0"
}
jowenshaw pushed a commit to jowenshaw/metaverse that referenced this issue Jan 10, 2018
jowenshaw pushed a commit to jowenshaw/metaverse that referenced this issue Jan 12, 2018
ventfang added a commit that referenced this issue Jan 12, 2018
jowenshaw pushed a commit to jowenshaw/metaverse that referenced this issue Jan 15, 2018
jowenshaw pushed a commit to jowenshaw/metaverse that referenced this issue Jan 15, 2018
@NotoriousPyro NotoriousPyro changed the title verifyaddress returns a poorly JSON-formatted response verifyaddress returns a poorly-formatted JSON response in v2. Jan 23, 2018
@jowenshaw
Copy link
Contributor

fixed, now the response for invalid address is:

{
	"id" : 1,
	"jsonrpc" : "2.0",
	"result" : 
	{
		"address-type" : "none",
		"is-valid" : false,
		"message" : "invalid address!",
		"test-net" : true
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants