Skip to content

L402: streaming response gRPC calls don't support creating L402 token #191

@guggero

Description

@guggero

For some reason, when the server sends back the 402 payment required response code if the user doesn't already have an L402 token, the client interceptor code doesn't detect that properly and doesn't attempt to create a token, resulting in a terminal error.

It is yet unclear where exactly the problem lies, the following possibilities come to mind:

  • The server's response status fields aren't set correctly for the client interceptor to recognize:
    func sendDirectResponse(w http.ResponseWriter, r *http.Request,
    . Perhaps the gRPC/HTTP/2 specific trailer fields need to be used?
  • The client library just doesn't look for the response code in the right place (it interprets the error from the stream interceptor, but perhaps it needs to look at response header/trailer fields?)
  • This is a limitation of the gRPC Golang library itself and cannot be fixed easily.

In any case, it should be pretty straightforward to set up a new unit test (taking

func TestProxyGRPC(t *testing.T) {
as a template) that executes the streaming case and allows for local debugging of the issue.

Workarounds

The current workaround in most Lightning Labs application is to make sure we call a non-streaming (unary) gRPC method first, which then triggers the L402 token creation and allows subsequent streaming gRPC methods to work.

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