Author

Topic: How do LN channels work? (Read 150 times)

hero member
Activity: 714
Merit: 1010
Crypto Swap Exchange
June 16, 2023, 02:33:53 PM
#8
All I want to do is to facilitate the network in being better connected.

How would you accomplish that? Is what I said above enough to do that?

I doubt that you can accomplish this with such small channels. And sorry, I have no recipe to find channel partners where the flow of sats between those Lightning nodes would benefit if you connect them with your own channels to them.

I have a few channels open to Lightning nodes that suit my own transfer needs. It happens that there's barely any routing traffic through my Lightning node. So be it, I'm fine with that as long as I can do my own Lightning transfers.
hero member
Activity: 560
Merit: 1060
June 16, 2023, 10:13:51 AM
#7
In addition to my question to achow101 above, apart from opening channels with larger nodes, should I also make sure to have Remote_Capacity > 0, in order for me to be able to route payments?

Before your transfer to your friend all your three channels had only send capacity, but no receive capacity. Thus your channel partners could not send you any sats or route sats through your channels, because at that moment you can't receive any sats yet.

After your payment to your friend your channel C has roughly 27,400sat receive capacity, thus that much can be routed by your channel partner of channel C through your node as long as there's a route through your channels A or B to the destination of the routed payment.

Someone else can also pay you via LN with at most 27,400sat if there's a route to your node via solely your channel partner C.

Balancing your channels, which are pretty small btw, would open up the possibility to route payments. Equal balancing means, giving each channel roughly the same local and remote capacity. What kind of balancing is preferable depends on if and how payments will flow through your Lightning node.

Don't expect too much of routing fees, three channels isn't much and your channels are pretty much too small. Some nodes would even refuse to open a channel that small with you, even if you're the one who opens the channel to them. A more suitable channel size is likely something of 2M with 1M minimum. If I were to open a new channel, it'll be 2M minimum.

You will have a hard time to earn back the channel opening fees by routing fees. I don't want to cut your dreams of routing payments but I speak of some experience with my own Lightning node. And rebalancing does cost you fees, too. You would be very lucky if you can manage the balance of your channels by tweaking routing fees of your channels only.

Hello mate. Your answer has been very helpful

I am not interested in earning sats. All I want to do is to facilitate the network in being better connected.

How would you accomplish that? Is what I said above enough to do that?
hero member
Activity: 714
Merit: 1010
Crypto Swap Exchange
June 11, 2023, 03:06:52 PM
#6
In addition to my question to achow101 above, apart from opening channels with larger nodes, should I also make sure to have Remote_Capacity > 0, in order for me to be able to route payments?

Before your transfer to your friend all your three channels had only send capacity, but no receive capacity. Thus your channel partners could not send you any sats or route sats through your channels, because at that moment you can't receive any sats yet.

After your payment to your friend your channel C has roughly 27,400sat receive capacity, thus that much can be routed by your channel partner of channel C through your node as long as there's a route through your channels A or B to the destination of the routed payment.

Someone else can also pay you via LN with at most 27,400sat if there's a route to your node via solely your channel partner C.

Balancing your channels, which are pretty small btw, would open up the possibility to route payments. Equal balancing means, giving each channel roughly the same local and remote capacity. What kind of balancing is preferable depends on if and how payments will flow through your Lightning node.

Don't expect too much of routing fees, three channels isn't much and your channels are pretty much too small. Some nodes would even refuse to open a channel that small with you, even if you're the one who opens the channel to them. A more suitable channel size is likely something of 2M with 1M minimum. If I were to open a new channel, it'll be 2M minimum.

You will have a hard time to earn back the channel opening fees by routing fees. I don't want to cut your dreams of routing payments but I speak of some experience with my own Lightning node. And rebalancing does cost you fees, too. You would be very lucky if you can manage the balance of your channels by tweaking routing fees of your channels only.
hero member
Activity: 560
Merit: 1060
June 01, 2023, 01:46:19 AM
#5
...

Very very helpful explanation.

Payments get routed through other nodes on the channels that they have open. In order for you to have paid your friend, they need to have a channel open with someone else, who has a channel open with another node, etc. until you get to someone that has a channel open with you. Payments work through forwarding - you paid node C, who used funds that they have in a channel with someone else, to pay another node, and so on, until your friend gets paid. Each node on this route can take a fee for routing your payment, so the amount that leaves your wallet will generally be a bit more than the amount that your friend receives.

Thank you, this routing process is what I was ignoring. I though that in order to pay someone, I had to have established an open channel with them directly.

There could be a number of different reasons. It could be that node C is the only one that has a route between you and your friend. It could be that the route through node C was the shortest or cheapest and chosen over other routes. In general, the channel used for payments depends on the route chosen for the payment to take.

So, considering that I want to support the network, could I establish channels with large nodes, in order to help routing payments? Would it be beneficial for the network? If not, could you give me ideas of what I could do in order to support?

Something useful to note here is that prior to you sending the funds to your friend, Node C could not route any transfers through you.  If Node C wanted to send to Node A (or B) and you were the ONLY path between them, then they wouldn't be able to send. This is because they didn't have any Cap on their side of the channel to send to you (for you to forward in your channel with A or B).

Now that you have sent to your friend, there are 27,410 available on Node C's side of that channel.  They would now be able to route that much to Node A (or Node B) through your node, transferring up to that amount back into your side of the channel that you have with C, while you transfer the same amount to whichever of the two nodes (A or B) that they are wanting to route to.

In addition to my question to achow101 above, apart from opening channels with larger nodes, should I also make sure to have Remote_Capacity > 0, in order for me to be able to route payments?




legendary
Activity: 3514
Merit: 4895
May 31, 2023, 04:42:29 PM
#4
Does node C also have the ability to spend the sats I sent to my friend? Because it looks like the sats are on the other end of the channel I have with node C.
Kind of, for some definitions of "spend". Also keep in mind that there are no actual "sats" objects, nor are they uniquely identified or separable.

They can "spend" it insofar as they have the literal funds that you sent them. However they also sent their own funds to the next node in the route so that your friend could get paid. It could be argued that they already spent those funds in order to forward the payment.

Something useful to note here is that prior to you sending the funds to your friend, Node C could not route any transfers through you.  If Node C wanted to send to Node A (or B) and you were the ONLY path between them, then they wouldn't be able to send. This is because they didn't have any Cap on their side of the channel to send to you (for you to forward in your channel with A or B).

Now that you have sent to your friend, there are 27,410 available on Node C's side of that channel.  They would now be able to route that much to Node A (or Node B) through your node, transferring up to that amount back into your side of the channel that you have with C, while you transfer the same amount to whichever of the two nodes (A or B) that they are wanting to route to.
staff
Activity: 3458
Merit: 6793
Just writing some code
May 31, 2023, 04:33:56 PM
#3
Since I haven't opened a channel with my friend, how did my friend receive the funds?
Payments get routed through other nodes on the channels that they have open. In order for you to have paid your friend, they need to have a channel open with someone else, who has a channel open with another node, etc. until you get to someone that has a channel open with you. Payments work through forwarding - you paid node C, who used funds that they have in a channel with someone else, to pay another node, and so on, until your friend gets paid. Each node on this route can take a fee for routing your payment, so the amount that leaves your wallet will generally be a bit more than the amount that your friend receives.

Why did my sats get moved from channel C and not from another channel?
There could be a number of different reasons. It could be that node C is the only one that has a route between you and your friend. It could be that the route through node C was the shortest or cheapest and chosen over other routes. In general, the channel used for payments depends on the route chosen for the payment to take.

Does node C also have the ability to spend the sats I sent to my friend? Because it looks like the sats are on the other end of the channel I have with node C.
Kind of, for some definitions of "spend". Also keep in mind that there are no actual "sats" objects, nor are they uniquely identified or separable.

They can "spend" it insofar as they have the literal funds that you sent them. However they also sent their own funds to the next node in the route so that your friend could get paid. It could be argued that they already spent those funds in order to forward the payment.
legendary
Activity: 3514
Merit: 4895
May 31, 2023, 04:33:15 PM
#2
In addition to your 3 channels:
NodeLocalRemote
A100,0000
B200,0000
C150,0000

Imagine that your friend has 3 channels:
NodeLocalRemote
D30,00030,000
E40,00040,000
F50,00050,000

You don't have a channel directly to your friend.


However, imagine now that Node C has a single channel with Node F
Node C CapNode F Cap
300,000250,000

After you send the sats, it will look something like this.

You
NodeLocalRemote
A100,0000
B200,0000
C122,59027,410

Your friend
NodeLocalRemote
D30,00030,000
E40,00040,000
F77,41022,590

Channel between Node C and Node F
Node C CapNode F Cap
272,590277,410

So, yes, Node C now has access to an additional 27,410 in the channel that you have with them, BUT they have access to 27,410 LESS in the channel that they have with Node F. The net result is that the total value that they have access to across all their channels is unchanged.  Likewise, Node F now has access to an additional 27,410 in the channel that you have with Node C, BUT they have access to 27,410 LESS in the channel that they have with your friend. Node C and node F have acted as intermediaries between you and your friend, passing along the amount being sent from channel to channel gaining some in one channel while losing the same amount in another.

Not that, depending on the fee policies, each intermediary may actually have gained a bit in one of their channels. So if you sent 27,400 with fees of 10, then you would have 27,410 less in your channel with C, and your friend would have 27,400 more in their channel with F, and C and F would each potentially have sent a bit less down the chain of channels than they received (giving them a net gain from the fee).
hero member
Activity: 560
Merit: 1060
May 31, 2023, 02:47:03 PM
#1
Hello, I have been successfully running an LN Node (LND).

I have also created 3 channels with 3 random nodes (not really random, because I checked their stats). I found the nodes here: https://1ml.com/

Without going into tiring details, when I created the channels, the situation was the following:

ChannelLocal CapRemote Cap
A100,0000
B200,0000
C150,0000

Then, I decided to send some sats to a friend of mine, with whom I haven't opened a channel. Suddenly, the channels looked as follows:

ChannelLocal CapRemote Cap
A100,0000
B200,0000
C122,59027,400

Obviously my sats were moved from my last channel and there was a 10sat fee.

Now, my questions are:
  • Why did my sats get moved from channel C and not from another channel?
  • Since I haven't opened a channel with my friend, how did my friend receive the funds?
  • Does node C also have the ability to spend the sats I sent to my friend? Because it looks like the sats are on the other end of the channel I have with node C.

Note: I may sound extremely ignorant, but I am in the process of learning about LN.


Jump to: