The lightning network, what is it, how to use it?

This blog post will be about the lightning network (LN). I tried to make this article as newbie-friendly as humanly possible, so i had to leave out and/or simplify several technical aspects.

What is the lightning network?

First things first: the lightning network is NOT an intrisic part of the bitcoin network. You can continue to use your bitcoin wallet exactly as you would have used it before the LN was introduced. If you’re not interested in the LN, you can just forget it ever existed.
The lightning network is a new protocol that uses the bitcoin blockchain in order to record the opening and closing of channels. It is built on top of the bitcoin protocol. So, every lightning wallet is in fact also a bitcoin wallet, while most bitcoin wallets are not lightning-compatible.

The lightning network is basically a protocol that allows users to open payment channels between their lightning wallets or nodes. The opening of a channel is recorded on the bitcoin blockchain. The value of the opening transaction is the value with witch the channel is funded.
After the opening transaction has been confirmed and has a couple confirmations, the 2 people that have a channel opened between them can now send transactions to eachother without recording them on the blockchain. This process is almost instant, and because the transactions are not broadcasted to the bitcoin network, they’re (allmost) free. If several people have open channels between them, it becomes possible for 2 people that are not directly connected to send funds to eachother by using other people’s channels. I’ll give some practical examples in the next section.

Example A: 2 friends saving on miners fees and time by opening a lightning channel between them

situation: friend A and friend B borrow money from eachother all the time, they pay gas money to eachother, they buy eachother lunch from time to time,… So there is a continuous flow of fiat money between them on a daily basis. Up untill now, everything was settled afterwards in FIAT money, which was a petty, because sometimes they forgot to pay money back, leading to discussions.

sollution: friend A and friend B open a channel between them. They fund this channel with 0.05 BTC each. From now on, each time a friend borrows money from the other friend, a lightning invoice is created and payed by the other friend. Technically, both friends just create a new transaction with a different division of the funds and share this transaction between them. At any point, either one of them can broadcast the last transaction… There are technical safeguards implemented to make sure a wallet has to broadcast the last transaction, and not an earlyer transaction that was more beneficial to him… However, this is a very technical discussion i will not post here.

So, as an overview:

  1. funding transaction (onchain): 0.1 BTC
  2. first channel state (offchain) : 0.05 BTC for friend A, 0.05 BTC for friend B
  3. second channel state (offchain): friend A borrows 0.01 BTC =>0.04 BTC for friend A, 0.06 BTC for friend B
  4. thirth channel state (offchain): friend A pays for lunch (0.02 BTC) => 0.06 BTC for friend A, 0.04 for friend B
  5. fourth channel state (offchain): friend B borrows 0.01 BTC => 0.07 BTC for friend A, 0.03 for friend B
  6. fifth channel state (offchain): friend B borrows 0.02 BTC => 0.09 BTC for friend A, 0.01 for friend B
  7. closing transaction (onchain): funding an address of friend A with 0.09 BTC and an address of friend B with 0.01 BTC

In this example, both friends have 2 transactions recorded on bitcoin’s blockchain. If they hadn’t used the lightning network, 4 transactions would have been recorded, and each time the friends would have had to wait untill the transaction was confirmed

Example B: the lightning NETWORK

  1. Person A has a channel with person B => the channel state is 0.05 BTC for person A and 0.05 BTC for person B
  2. Person B has a channel with person C => the channel state is 0.05 BTC for person B and 0.05 BTC for person C
  3. If person A pays an invoice of 0.02 generated by person C, it is routed trough person B. The channel state between A and B is changed to 0.03 for person A and 0.07 for person B. The channel state between B and C is changed to 0.03 for person B and 0.07 for person C
  4. The net result is that person A has one channel that has 0.02 BTC less, person B has the same sum of all values and person C has a channel with 0.02 BTC more. Offcourse, person B can charge a fee to route the transaction, and a technical sollution is implemented to avoid cheating by the participants

Testing out the LN

I’ve actually created a site where you can test these micro-transactions… You can pay 25 satoshi’s to sponsor an unblurring step of an image, this way the maximum stake for you is less than a cent 😉

Leave a Reply