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

/payinvoice and /sendtoaddress return HTTP 200 status code when erroring #42

Open
coyotte508 opened this issue Apr 26, 2024 · 0 comments

Comments

@coyotte508
Copy link

coyotte508 commented Apr 26, 2024

For example:

curl -v -X 'POST' 'http://localhost:9740/sendtoaddress' \
  -u :phoenixd_api_password \
  -d 'amountSat=100000' \
  -d 'address=invalid_address' \
  -d 'feerateSatByte=12'

I get this error:

* Connected to localhost (127.0.0.1) port 9740 (#0)
* Server auth using Basic with user ''
> POST /sendtoaddress HTTP/1.1
> Host: localhost:9740
> Authorization: Basic ...
> User-Agent: curl/7.81.0
> Accept: */*
> Content-Length: 58
> Content-Type: application/x-www-form-urlencoded
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Length: 15
< Content-Type: text/plain; charset=UTF-8
< 
* Connection #0 to host localhost left intact
invalid address%   

I get a 200 error code instead of a 400 (or 422)

For the /payinvoice endpoint, same thing.

Code change

is ChannelCommand.Commitment.Splice.Response.Failure -> call.respondText(r.toString())
, add , status = ... probably in the respondText?

Workarounds

  • for the /sendtoaddress endpoint, I can check if the text reponse is a valid TX id
  • for the /payinvoice endpoint, I can check if the JSON response contains a reason field
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

1 participant