Skip to content

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

@coyotte508

Description

@coyotte508

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions