August 18, 2022

Lightning Network Local and Remote Reserve Balance

Another lesson learned today... If you don't have much experience with Lightning Network, you may find this behavior strange, and think that something is broken...

Imagine you have two nodes, and you open a channel from one node to the other, say 100000 sats... You have 100000 local and 0 remote... Then to test if everything is okay you send 1000 sats through the channel, and it works instantly and with 0 fee... Excellent, you think to yourself, and you try to move those 1000 sats back...

"failure reason": "FAILURE_REASON_NO_ROUTE"

What? It's connected directly... What do you mean, stupid program?..
You type payinvoice again, this time you set the output channel directly...

"failure reason": "FAILURE_REASON_INSUFFICIENT_BALANCE"

Ummm, what?.. Then you type listchannels, find the channel, and look closely...

"local_chan_reserve_sat": "1000"
"remote_chan_reserve_sat": "1000"

Yes, it will not let you do a transaction if it results in either of the ends of the channel to fall below the reserved amount (1% of the channel capacity)...

You send another 1000 sats, and try to get 1000 sats back... That should work, right?..

"failure reason": "FAILURE_REASON_INSUFFICIENT_BALANCE"

Ah, right, it also will not let the channel go below the commitment fee (that depends on current on-chain fees)... At the time it was 2005 sats...

Okay, you send 1100 sats in the same direction, it is now [96900 local - 3100 remote] and try to pay that 1000 sats invoice from the remote node again... And it finally succeeds because the resulting balance (2100) was above both the reserved amount (1000) and the commit fee (2005)...

Now the question is: what if I want to close a channel with all the funds on one side, and no leftover balance on the other side?.. Is there a way to do it?.. Is it possible to make the channel [100000 local - 0 remote] again?.. According to Lightning protocol - no...

Not until eltoo is implemented: https://www.youtube.com/watch?v=cVML_uQxvwg
It will also make watchtowers much simpler and cheaper, but that's another story…

No comments:

Post a Comment