Skip to content

track and send payment API endpoints should send consistent responses indicating payment state. #6751

@razorman8669

Description

@razorman8669

Background

When interacting with the API endpoints for /v2/router/track and /v2/router/send, it's particularly difficult to determine if a payment actually failed, or if some other type of error occured, due to the inconsistent response structures returned for various error states.

For instance, when trying to create multiple failure states, I have received many different response formats from these endpoints, such as:

  • {"code":3,"message":"unexpected EOF","details": []}
  • {"code":3,"message":"type mismatch, parameter: payment_hash, error: illegal base64 data at input byte 0","details":[]}
  • {"error":{"code":2,"message":"invoice expired. Valid until 2022-07-05 09:07:39 +0000 UTC","details":[]}}
  • {"error":{"code":6,"message":"invoice is already paid","details":[]}}
  • {"error":{"code":5,"message":"payment isn't initiated","details":[]}}
  • {"result": {..., "status":"FAILED","failure_reason":"FAILURE_REASON_ERROR",...}}

As you can see, there are 3 different formats that I have discovered thus far, and theres most likely many others that I haven't yet seen. This makes it difficult to determine, with 100% certainty, that a payment did indeed FAILED or if something else is going on (connection/networking issues, lnd hiccups, malformed request params, etc). as it is, clients that consume these responses need to have handlers for every type of possible "error message" to determine if it's actually "FAILED" (like "payment isn't initiated") or if there's some networking issue where the request itself failed, but the payment DID NOT (like "unexpected EOF" or "type mismatch, parameter: payment_hash, error: illegal base64 data at input byte 0")

Your environment

  • version of lnd
    • v0.15.0-beta
  • which operating system (uname -a on *Nix)
    • Ubuntu 18.04.6 LTS
  • version of btcd, bitcoind, or other backend
    • btcd version 0.22.0-beta

Steps to reproduce

send bad requests to the /v2/router/track and /v2/router/send endpoints.

Expected behaviour

I would expect the payment responses to tell me, with certainty, that either the payment is "FAILED", "SUCCEDED", or "INFLIGHT".

Actual behaviour

I get error messages wrapped in error properties, or in top level objects, or in the result property, and am required to know every possible error state that could happen in order to handle payments responses properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions