When Satoshi Nakamoto introduced Bitcoin in 2008, they envisioned a world where Bitcoin a new form of digital money. However most people today consider Bitcoin as a digital store of value rather than a currency. As Bitcoin grew in popularity, its low transaction throughput and high transaction cost became more impractical for everyday small payments. The Lightning Network proposed by Joseph Poon and Thaddeus Dryja in 2015 aims to provide the solution to these problems.
What is Lightning Network
The Lightning Network is a second layer payment network built on top of the Bitcoin blockchain that enables instant payments between connected users at extremely low fees.
How does it work
In the below example we will illustrate how Adam can purchase a cup of coffee using bitcoin (BTC) via the Lightning Network.
- Adam first opens a payment channel with the coffee shop by depositing BTC into a multi-signature wallet. A multi-signature wallet requires more than one user to authorize a transaction. In this case between Adam and the coffee shop owner. This transaction is publicly recorded on the blockchain for each party to see.
- To pay for a coffee, Adam subtracts the cost from his balance and adds it to the coffee shop’s balance. Both parties then sign a signature on the updated balance sheet with their private keys to confirm the balance. This transaction simply updates the state of the balance sheet and will not be recorded on the blockchain. This can happen an unlimited number of times as long as there is sufficient balance.
- When either person wants to close the channel, they can broadcast the latest balance sheet (signed by both parties’ private keys) to the blockchain. Other network nodes will then validate the signature on the balance sheet and the funds will be released accordingly. While hundreds of transactions could happen on the payment channel. Only two transactions (opening and closing of the payment channel) will be recorded on the main blockchain. This significantly eases the transaction load on the Bitcoin network.
- You can make payments in the Lightning Network without a direct payment channel between two parties. For example, if Charlie wants to buy a coffee and has an existing payment channel with Adam. He can transfer the fee to Adam who will then transfer it to the coffee shop. Users can transact with anyone with a network of payment channels through multiple hops. Which further reduces the number of transactions on the main blockchain.
How it prevents Double spending
Suppose Adam is a bad actor and tries to double spend by broadcasting an earlier state of the balance to the main network (one where he has more BTC than he really has). The coffee shop owner can then broadcast the latest state of the balance to prove that Adam was being dishonest, funds in escrow would then be paid to the coffee shop owner as a penalty.
However if the coffee shop owner is offline for a few days and does not respond in time, it is possible for Adam to steal the funds. To mitigate this, third parties called Watchtowers will monitor channels to prevent bad actors by informing users when someone is trying to close the channel. By preventing dishonest transactions, they will be paid a portion of the penalty.
Transaction fees in Lightning Network
Nodes facilitating as a route for payment channels between two parties have an option to charge a small fee (zero at default) as a percentage of the payment. Also as mentioned above, there will be a transaction fee for miners on the main network when broadcasting the opening and closing of payment channels.
Disclaimer: Please conduct thorough research when experimenting with new Lightning wallets. Some recent wallets might be scams!
Written by Peter Chan
Trader @Genesis Block
For any queries please contact firstname.lastname@example.org