- Peers are the nodes connected to each other through the internet (TCP/IP layer).
- A channel is a payment channel between two peers established on the Lightning Network.
- To open a channel to any node the peer connection needs to be established first.
- The publicly accessible nodes can be connected to automatically.
- If a node is not publicly accessible the peer connection needs to be initiated manually from the non-public side even if the other peer is opening the channel.
To be able to receive payments on the Lightning Network a node needs:
- "inbound liquidity" (aka remote balance) which means that some satoshis need to be on the side of the other peer in a channel.
- a channel to a well connected node or a direct channel from the paying peer to make sure there is a possible payment route.
The max amount of the incoming payment is determined by the highest inbound liquidity of a single channel (not additive between channels).
- There is no hard number, but in general it is recommended to avoid opening channels below 200K-500K sats.
- A channel too small will result in being unable to close when on-chain fees are high. This will leave the channel vulnerable in a case, when the counterparty would try to close with a previous state (the funds in the channel can be cheated out).
- The max size of the available payment made or routed is determined by the highest directional liquidity of a single channel (not additive between channels).
- One big channel to a well connected and stable node is more useful than many small ones.
- It is beneficial to connect to nodes where the operator can be contacted in case of a problem.
- Opening or closing a Lightning channel is an on-chain bitcoin transaction (settled on the blockchain)
- Use a custom fee and choose the lowest number with a good chance for an acceptable confirmation time.
- At least 141 bytes need to be covered by fees, but this number is often higher depending on the transaction inputs, script and signatures used.
- A Lightning node behind Tor can connect and open a channel to any other node.
- The nodes running on clearnet are not able to see behind Tor.
- The clearnet node needs to be added as a peer first by the Tor node to be able to open a channel.
- Once the channel is established the connection will persist, but might take some more time to come back online after either peer restarts.
- If both nodes restart in the same time or the clearnet node`s IP address is changed while both offline the peer connection need to be added manually again.
- Imagine a node
- The channels of
Bare set up so that there is inbound capacity (remote balance) from
Aand outgoing capacity (local balance) to
Awants to pay
Cthere will be 1 hop in the route.
- Under the hood:
Asends the satoshis to
B(the routing node) which will pay to
- The capacity of the channels do not change, only move.
- The whole payment can only go through if they can send a hash image (a message) through from the other direction first.
- The process is all or nothing, the payment cannot get stuck en route.
- better to be called an "unannounced" channel
- won't be advertised in the channel graph (network gossip)
- more useful to send payments
- to receive payments need to have a route hint included in the invoice:
lncli addinvoice <amount> --private
- the route hint is the identifier of the funding transaction (exposes the channel to the anyone knowing the invoice)
- possible to receive keysend payments if the route hint is known
- does not route payments (unless used in parallel with a public channel to the same node - aka shadow liquidity)
Unlike with on-chain transactions (where the fee is paid for the bytes the transaction takes up in a block) Lightning Network fees are related to the amount routed. There are two fee components:
- base fee (base_fee_msat). The default is 1000 millisat, which means 1 satoshi fee per every routed payment.
- proportional fee (fee_rate) which is by default in lnd: 0.000001. This means there is an additional 1 sat charged for every million satoshis in the routed payment.
There is no LN fee for payments in a direct channel between two peers.
- Can reduce the base fee to 500 msat and increase the proportinal fee to 100ppm/0.01% with this command:
$ lncli updatechanpolicy 500 0.0001 144
- the default setting is (1 sat per payment + 1 ppm/0.0001%):
$ lncli updatechanpolicy 1000 0.000001 144
The channels are best to be balanced with funds on each side to maximize the ability to route payments (allows bidirectional traffic).
A feature rich tool to work with LND balances. Has an experimental feature to connect to a personal Telegram bot and notify about the node activity.
An automated manager for C-Lightning forwarding nodes.
A command-line tool for advanced channel management of an LND node written in python.
- Install with:# activate virtual environmentsudo apt install -y python3-venvpython3 -m venv venvsource venv/bin/activate# get dependenciessudo apt install -y python3-dev libatlas-base-devpip3 install wheelpython3 -m pip install lndmanage
- Start the interactive mode (do this at every new start):$ source venv/bin/activate(venv) $ lndmanage
- To display the status of the channels:
$ lndmanage status
$ lndmanage listchannels
- Example rebalance command:
$ lndmanage rebalance --max-fee-sat 20 --max-fee-rate 0.0001 CHANNEL_ID --reckless
Using this python script you can easily rebalance individual channels of your lnd node.
- To install run in the terminal of the lnd node:
$ git clone https://github.com/C-Otto/rebalance-lnd
$ cd rebalance-lnd
$ pip install -r requirements.txt
- Perform a trusted onchain to offchain swap.
- Open a dual funded, balanced channel with a trusted peer using the command line requiring an Lightning and an on-chain transaction.
An LND Lightning Node Manager in your Browser.
A lightning wallet for desktop, iOS and Android - can connect to your LND node remotely through the GRPC interface (port 10009)
lntop is an interactive text-mode channels viewer for Unix systems.
Spark is a minimalistic wallet GUI for c-lightning, accessible over the web or through mobile and desktop apps (for Android, Linux, macOS and Windows). It is currently oriented for technically advanced users and is not an all-in-one package, but rather a "remote control" interface for a c-lightning node that has to be managed separately.