Skip to content

sdk: receive will always pick an LSP or fail #652

@nepet

Description

@nepet

The documentation of receive states:

...
///The invoice includes negotiation of an LSPS2 / JIT
/// channel, meaning that if there is no channel sufficient to
/// receive the requested funds, the node will negotiate an
/// opening
, ...

For me this sounds like calling receive will only result in a new channel if we either
a.) Don't have a channel or
b.) Don't have enough inbound liquidity for the requested invoice amount.

Looking at the code, the following happens:
receive calls the gRPC method LspInvoice which on the
service side -- to be found in gl-plugin -- will call get_lsps_offers to ask all
peers for an lsps2 offer. If get_lsps_offers fails or does not return a single lsp
offer, lsp_invoice will return an error.

This contradicts the statement above. When trying to recieve a payment, we
don't check for any funds, try to request a jit-channel in any case and fail if
we can't find an offer.

We should check for sufficient inbound liquidity first, before requesting a
jit-channel offer.

Who is responsible for this check tho?

The SDK is aware of LspInvoice, Invioce and Listpeerchannels so
we can decide inside of receive with some margin:
If $amount\_msat + margin > \sum listpeerchannels.channels. receivable\_msat $
use LspInvoice, otherwise use Invoice

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions