Suppose you’ve given the Lightning Network a go using a custodial wallet or a third-party Lightning node, and you’ve enjoyed the slick instant payments. In that case, you might not realise how much work goes into ensuring those payments are settled.
Unlike the bitcoin base chain, where all you need is the private keys to sign, and you can move a UTXO to a wallet, the Lightning Network is a far more hands-on approach should you wish to manage it non-custodial.
Even if you’re running a private channel, have a few small channels for payments, or plan to run a routing node, you’ll eventually have to face the task of keeping channels balanced.
What are channel balances?
When you lock up a bitcoin UTXO into an HTLC, you unlock those funds on the Lightning Network, and you pair those funds with a specific channel peer. You can now make payments on the Lightning Network via the peers you’ve connected with, and they can pay you.
It sounds simple enough, but there is one catch, once you’ve established a channel and broadcast the state to the network, you’ve only told the Lighting Network the size of the channel, and you’re not yet open for business and throughput.
For that, you need to have inbound or outbound capacity.
Keeping liquidity flowing in the right direction
To operate your own Lightning Node, you need liquidity; to send Lightning payments, you need outbound liquidity, and to receive Lightning payments, you need inbound liquidity.
- Send payments ==>Outbound Liquidity – My Balance – Local Balance
- Receive payments ==> Inbound liquidity – (Foreign) balance of the other node – Remote balance
Once you’ve connected with various peers, you’ll start to see the channels you’ve set up start to update their balances as bitcoin flows through your node to settle payments.
Occasionally, routing nodes will be left without sufficient funds to route payments on the inbound or outbound side of the channel. This happens because every time a node routes a payment, the balance with the receiver decreases while the balance with the sender increases.
Although the total amount remains the same, her money is more unevenly distributed.
Why are balanced channels better?
Unbalanced channels become an issue for Lightning nodes because only the counterparties in a channel know about the internal state of a channel (local vs remote balances). So when a node constructs a route via which to send a payment, they hope each channel along the route will have sufficient local balance to pass the payment onward.
If one channel is a chink in the chain, that hop needs to be diverted to another node, or the payment will fail. In addition, you, as a routing node, will miss out on fees earned for your liquidity because your Lightning node cannot pass on the payment.
If all of your node’s channels are equally balanced, then there’s a better chance that another node will succeed in routing a payment through your node. This is better for the health of the network, and also it’s better for you because you can collect routing fees.
Another reason to balance your channels is to give your node more options when making your own payments. For example, if many of your channels have zero or very low local balances, your node won’t be able to use those channels to send payments, and you’ll have to rebalance or create a new channel.
How do I rebalance my channels?
There are several ways to rebalance your channels, all with their own trade-offs and costs. You will need to learn about all the available options to make the best decision for securing the cheapest channel capacity.
Balancing channels is time intensive and comes at a cost. It requires careful consideration and planning, or you will run an unprofitable operation. When rebalancing your channels, you should ensure that it does not cost more than you earned routing through this channel since the last rebalancing.
When rebalancing your channel, you can choose to:
- Rebalance between your channels
- Rebalance with a submarine swap
- Rebalance with a new channel
- Rebalance by purchasing liquidity
Rebalance with your own channels
To balance manually, you must first identify the two channels you want to balance.
- The first channel should have an excess local balance.
- The second channel should have an excess remote balance.
You will use these two channels to pay yourself though sometimes referred to as a “channel cycle” or circular rebalance. Generate a new payment request so that you can pay yourself the amount that you wish to rebalance.
If you don’t have a channel that would fit your rebalancing, you could create a new channel and use that to rebalance.
Rebalance with Lightning Loop
Loop is a service that allows you to make a Lightning payment to an on-chain address or make an on-chain Bitcoin payment to refill your channels. Loop Out is useful for sending earnings from your channels to cold storage or refilling your channels without the need to open new channels.
In the context of inbound capacity, Loop Out can be used to empty your Lightning channel into a bitcoin address and then use that new UTXO to open a new channel. After two channel openings, you are left with both inbound and outbound capacity and the ability to route payments.
Rebalance with a Liquidity marketplace
Pool, along with Magma, are both non-custodial, peer-to-peer marketplaces for Lightning node operators to buy and sell channels. You can use either liquidity marketplace to find others to open channels with you and acquire inbound capacity or collect fees to open channels with others.
Alternatively, you can use a centralised marketplace like Thor and purchase capacity through a service like Bitrefill.
Calculate the cost of rebalancing
The rebalancing of channels will be the single biggest factor in your ability to run a profitable lightning node. There is no right or wrong way to manage your channels, and there is no done for your service; you will have to learn to manage it yourself.
Yes, there will be improvements like better dashboards and UIs that can recommend rebalancing actions, and this will help along with other improvements to the protocol. For example, though splices, you can get far more convenient rebalancing than closing and opening channels separately, but they still involve broadcasting transactions and paying on-chain fees.
While channel factories could make it far cheaper to rebalance channels without touching the base chain.
Are you a bitcoin and lightning fan?
Have you been using Lightning to make micro-payments? Stream sats or engage with apps? Which app is your favourite? Do you run a Lightning node? How do you handle channel rebalancing? Have you tried all the forms of Lightning payments? Which one do you prefer?
Let us know in the comments down below.