lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.63k stars 2.07k forks source link

[feature]: allow settlement of an invoice to yourself without routing the payment #7419

Open AndySchroder opened 1 year ago

AndySchroder commented 1 year ago

Describe the solution you'd like

Allow settlement of an invoice to yourself without routing the payment through the lightning network. There are many cases where you'd want to be able to accept a payment from yourself. Currently people seem mostly interested in doing this for re-balancing channels, but there are cases where you may want to do so without re balancing channels.

Describe alternatives you've considered

  1. Running 2 nodes: total waste of resources and complexity. Requires periodic channel re-balancing because of https://github.com/lightningnetwork/lnd/issues/7417.
  2. Routing payments through other nodes using allow_self_payment: Works, but causes unnecessary fees, capacity requirements, latency, network traffic, channel unbalancing, etc..
  3. Creating a private channel back to yourself on the same node: Can't do this, and even if you could https://github.com/lightningnetwork/lnd/issues/7417 probably would make this not work anyway.

Additional context

Anyone trying to use their own service can't. For example, a user of Distributed Charge - EV (http://andyschroder.com/DistributedCharge/) can't use their own charging station.

AndySchroder commented 1 year ago

Another use case for this is the LND Accounts feature (https://docs.lightning.engineering/lightning-network-tools/lightning-terminal/accounts) . Currently invoices are not able to be paid between two accounts using the same LND node.

AndySchroder commented 1 year ago

Putting this in a greater context on why this should be a standard feature: On all computers we have the loopback address, 127.0.0.1, which can be used to reach ourselves with internet protocol. The same functionality should exist for lightning.

tlindi commented 5 months ago

While you are fixing this, could you carefully consider parameter / setting naming too, please.

If I understand correctly "enable paying to my self" setting is in config: allow-circular-route=true

And commanline parameter is needed from payment to route circularily: --allow_self_payment

Right?

Allow-circular-route makes sense. Cause currently paying to myself (without others) doesn't work. But after issue is fixed setting name should be something else. If any setting is needed at all.

And --allow_self_payment for command line is IMHO wrong currently, cause it doesn't enable paying to myself as "localhost" style either.

AndySchroder commented 5 months ago

You need to set --allow-circular-route on your node to allow htlc forwards that arrive and depart on the same channel. This is a setting for lnd.

You need to set --allow_self_payment when sending a payment to allow sending a circular payment to self using the RPC.

I believe that the difference is that --allow-circular-route is for any payment that your node routes, regardless of whether you are sending it or someone else is. --allow_self_payment is for a payment you are sending.

AndySchroder commented 5 months ago

The other thing is that --allow_self_payment is something you can do without a circular route if you have the payment going in and out different channels (3 hops minimum). --allow-circular-route allows you to make a self payment with just 2 hops.

MichaelAntonFischer commented 3 months ago

Hi, I find it a bit wild that this feature is still not implemented. It is very common that users have several services like BTCPayServer and LNbits connected to the same node. It should really be possible to send payments from one such system to the other without routing through the lightning network.

I constantly find myself building workarounds for this missing feature.

thespielplatz commented 3 months ago

@MichaelAntonFischer As long as the feature is not implemented you could use lndhub as account layer (connected to the node) and connect lnbits & btcpay to lndhub

MichaelAntonFischer commented 3 months ago

This is precisely what I mean with building workarounds.

thespielplatz commented 3 months ago

Ok - it seems I am missing a point? - I thought with LNDHub as middleware-layer you had todo the workaround only one time. At least in my case, I setup up LNDHub one time and selfpayment problem gone.

MichaelAntonFischer commented 3 months ago

No. LNbits doesn't natively support LND Hub as funding source. LNBits has LND hub built in, so this would be a workaround, but really it is annoying that all this has to happen.

LND surpassed CLN by adding Kubernetes natively, but what is the use of Kubernetes, when you then can't natively deploy a ton of services on top?

AndySchroder commented 3 months ago

"Lightning Terminal" provides the "groundwork" for a far superior middle ware than LNbits for providing accounts and other constraints because it uses an identical macaroon authentication scheme and gRPC with regular LND, as if the middle ware did not even exist. That way an application can interact with LND directly or through the "Lightning Terminal" middle ware with more limited abilities and the application won't even know it.

However, this low level bug makes it impractical to use.

Does anyone know of CLN has this same issue?

MichaelAntonFischer commented 3 months ago

I don’t think middleware shouldn’t be necessary at all. The only feature I really need is self_payments, but also limiting what grpc connected services can do and access are both must haves that I feel should be in lnd.