RECAP
In our previous Article, "The Locker Room - A Bitcoin Wallet", we explained what Bitcoin wallets are and how Bitcoin transactions are carried out from wallet to wallet in relation to the Bitcoin blockchain, where actual Bitcoins are stored. In that write-up, we referred to the Bitcoin Blockchain as the "School Cafeteria".
In this article, we will take a deep dive into the Lightning Network, while still sticking to our school cafeteria analogy. You may need to read the first article so you can easily follow up and understand this one and the connections.
Read here: #1049161
Booting....
INTRODUCTION:
It is important to reiterate that Bitcoin runs on a public ledger called the "Blockchain". In the first article, we illustratively referred to the Bitcoin blockchain as a school cafeteria where provisions are kept, and these provisions are assigned to various owners who can access their portion of provisions with a public/private key pair that is always stored in their lockers (wallet).
We also highlighted that if you want to transfer the ownership of your provision(s), you'll have to sign it with your private key, publish it, and everyone using the Cafeteria (Blockchain) would be able to see that you have now assigned your provisions (Bitcoin) to someone else.
But we intentionally did not tell you that each time you do this, a group of chefs (Bitcoin Miners) must verify the transaction you published, and confirm that you own enough provisions on the Cafeteria to publish that transfer order, and that you have signed that transfer order with the correct private keys to which the provisions (Bitcoins) were initially assigned.
Their ultimate job is to ensure that all the provisions in the Cafeteria belong to the rightful owners and there's no fraud or cheating when sending and receiving provisions.
The activities of these chefs also bring about the addition of new provisions (Bitcoins) into the Cafeteria. The process by which this is done is called "Bitcoin Mining".
BITCOIN MINING IN A NUTSHELL- The Chefs
We will not go deep into what Bitcoin Mining entails, but we'll quickly summarize what is happening in Bitcoin Mining and highlight its importance.
A group of chefs (Bitcoin Miners) who own and run a specialized type of ovens (Mining Machines) are vested with the responsibility of verifying that all the exchanges of provisions from one owner to another in the cafeteria (Blockchain) are valid.
They do this by checking that:
1. A sender has enough provisions that would cover the amount they want to send, plus the fees they'll pay (transaction fee).
2. You have signed and published that transfer order (transaction) with the right private key belonging to the public key to which the provisions you want to transfer were initially assigned. (If you did not understand this line, then you need to read our first article here: #1049161)
3. All other required tiny technical conditions are met.
There are thousands or even millions of chefs who do these checks and balances (and yes, anyone can become a chef, a.k.a. Bitcoin Miner). When several transfers of provisions (Bitcoin transactions) are published by different people on the Cafeteria, these chefs collect them one after the other and confirm that they meet the right conditions.
For each transaction they check and verify, they put it into a provision container (a block). All the chefs use provision containers of equal size (equal block size), and they're all in a competition to be the first to fill their containers with valid transactions, while doing some difficult cooking in the background (proof of work mathematical puzzle).
The first chef to publish the accurate result from the difficult cooking (math puzzle) wins the competition, and then all the transactions they included in their provision container will generally be accepted as approved by everyone, and it is added to the history book in the cafeteria, and the marathon starts again. This marathon happens every 10 minutes. (We'll dive deeply into Bitcoin mining in a separate article.)
It is important to note that these chefs can choose a transaction to include in their provision box based on the amount the publisher is willing to pay in transaction fees.
But there's a problem....
The problem is that "Each of those provision containers (transaction blocks) has a limited number of transactions that can be fitted into it at a time, and out of all the possible number of chefs doing the marathon, only one chef's provision container can be published and added to the history of the cafeteria every 10 minutes." This was intentionally designed thus for a very important reason.
The current number of transactions that can be fitted into a Bitcoin block (chefs’ provision container) is approximately 2500 transactions. This suggests that if, say, 1 million people publish their transactions within a 10-minute time frame, the provision boxes (the block) can only hold 2500 transactions, which'd then mean that only 2500 transactions get approved every 10 minutes.
This is a problem because it'd mean that just a few number of Bitcoin transactions can be approved every 10 minutes despite the number of people making transactions per time. It would also result in incredibly high transaction fees, because everyone will be fighting to have their transaction included in the next available block.
The average number of transactions processed by the Bitcoin network per day is standing at around 400k+ transactions. Now imagine when the whole world, or even 1/10 of the world, is using Bitcoin for daily transactions, this would mean that:
1. Most transactions will take days, even weeks, to get approved
2. Transaction fees will be too high, so much so that it'd be useless to send transactions of small amounts using Bitcoin, because the fees you will need to pay might be twice or thrice as high as the amount you want to transact.
This problem is called "The Scalability Problem" in the technology world. For years, Bitcoin developers sought a way to mitigate this problem without giving up Bitcoin's security.
THE LIGHTNING NETWORK: - The Solution
Bitcoin is money, and as money, it is meant to serve three important purposes:
- Medium of Storage
- Medium of Exchange
- Medium of Accounting
As a medium of storage, it means that you can store or preserve Value in Bitcoin. With just the Bitcoin blockchain, Bitcoin can comfortably serve its function as a medium of storage.
On the other hand, as a medium of exchange, Bitcoin is expected to be used for the exchange of value, even for as little as paying for a cup of coffee. But this will be very hard due to the scalability problem we described above. When so many people are hustling for the limited block size (provision containers), which in turn increases the transaction fees, this would mean that you cannot pay for a cup of coffee worth 2 Cents with Bitcoin because the transaction fee you'll need to pay to get your 2-cent payment approved might be up to $3. This automatically makes it economically useless to use Bitcoin as a medium of exchange.
This is where the "Bitcoin Lightning Network" comes into play.
The Lightning Network was designed to solve the problem of scalability associated with the main Bitcoin network. It enables the seamless onboarding of millions (even billions) of users on the Bitcoin Network at once, at the same time offering consistent transaction speed, ability to send very small amounts, cheap/affordable fees, and robust privacy (the core of Bitcoin technology). The Lightning network is built on top of the Bitcoin Blockchain, and it is popularly referred to as "Layer 2," while the main Bitcoin Blockchain (The cafeteria) is referred to as *"Layer 1".
Going back to our analogy, the Lightning network could be likened to a Canteen built right in front of the school cafeteria, where users can frequently interact and exchange provisions without having to always move their real provisions to and from the cafeteria.
Let’s break this down!
LIGHTNING NODES - Individual Spots in the Canteen:
Every user can always create a spot for themselves in the canteen. This is called "A Lightning Node". From their spot, they can easily connect to any other person's spot. This is called creating "Lightning channels."
For instance, to create a connection with Mr.Brad, Mr.Adams needs to know the Spot location (Lightning address) of Mr.B. He'd then request a connection to Mr.B's spot, which he can accept or decline. If Mr.B accepts the connection, both of them must do something important for the connection to be established.
- Both parties must agree on the total amount of provisions that their connection can transact. This is called "Lightning channel capacity”. (Oftentimes, the person initiating the connection decides the total capacity of the channel.)
- When the above decision has been made, each party will now send their part of the agreed provision amount (Bitcoins) from the cafeteria into a shared temporary account within the canteen. (This shared account is called a "2 of 2 multi-signature" account. This means that the two users must agree before funds will be spent from that account.)
So, for instance, Mr.A and Mr.B agree to create a connection where 10m provisions can be exchanged between them. Mr. A will send his portion of provisions (maybe 6m of his provisions) from the cafeteria into the temporary joint account in the canteen, and Mr. B will send the remaining 4m into the same joint account. The account will take a record of how much each of them contributed.
OUTBOUND AND INBOUND LIQUIDITY: - The power to send and receive
Since Mr.A contributed 6m provisions in that connection, he has what we call 6m Outbound Liquidity. This means that Mr.A can only send out 6m provisions from his end of the connection. On the other hand, Mr.B can send out only 4m provisions from his end of the connection.
Inbound Liquidity is just the opposite of outbound liquidity. Inbound Liquidity for Mr.A would be 4m provisions, while Inbound Liquidity for Mr.B would be 6m provisions. This means that Mr. A and Mr. B can, respectively, receive 4m and 6m provisions at their ends of the connection. (These concepts are very crucial, and we will see why soon.)
LIGHTNING TRANSACTIONS: - How the puzzle works
In the above paragraph, we explained how Mr.A and B have created a connection between themselves, and thus can easily exchange value between themselves. So, the question then is, how will they be able to send provisions to others with whom they do not have direct connections?
The answer is that a user can create connections with multiple people at the same time. So Mr.A can have a connection with Mr B, who has a connection with Mr.C, who may also have a direct connection with Mr.D, etc.
So, if Mr.A wants to send provisions to Mr.D, he doesn't need to have a direct connection with Mr.D. All he needs to do is get the lightning invoice of Mr.D (lightning invoices are what it is; an invoice used to receive payments on the lightning network), send the provisions to that invoice, and the provisions will be sent through his connection with Mr.B.
From Mr.B, it’d be hopped to Mr.C, who then finally hops it to Mr.D. This is called "Multiple hopping."
So anyone in the canteen can send provisions to someone else, even if they're not directly connected to them, as long as they're connected to someone within the large network. The system will automatically move the provision through the nearest connection route (routing path) until it gets to the desired destination. It is important to note that there is a fee paid, and it is called "Routing fee", but this fee is usually significantly low, mostly even negligible.
Referring back to the Outbound and Inbound Liquidity we mentioned earlier, if Mr.A for instance, wants to send 7m provisions to Mr D, but he has an outbound liquidity of 6m in his connection with Mr B, he cannot send the 7m, except he receives extra 1m provisions through Mr.B, thus increasing his outbound liquidity to 7m and his inbound liquidity decreasing to 3m. This is applicable vice versa.
So for both parties, their inbound and outbound liquidities can change in the course of the life of their connection, depending on how they're sending and receiving through each other.
CLOSING A CONNECTION: - Settling Scores
The connection between Mr.A and B can be open for as long as they want. However, if they eventually decide to close the connections, the joint account that was opened at the start will be consulted.
For every transaction each of them made within the period of their connection, a record is made in their joint account. So during closure, the account will be checked for balances on each side. If in the end, Mr.A now has 2m provisions left on his side, it means that Mr.B will automatically have 8m provisions left on his side. Both users will agree to a closure (anyone can initiate closure anyway), and their respective provision balances (Bitcoin balances on the multisig account) will now be sent back to their respective accounts on the cafeteria.
BENEFITS OF LIGHTNING NETWORK:
We have tried to explain the Lightning Network in a very detailed manner for anyone to understand. Now, let us highlight the significant benefits of the Lightning Network.
- SPEED: If you remember in the explanation above, only about 2500 Bitcoin transactions are confirmed on the Bitcoin Blockchain every 10 minutes due to the limited Block space, which means that a user will have to either constantly pay heavy fees for each transaction if they want their transactions to be approved faster, or wait for days, even weeks to have their transactions approved if they pay low fees or chose not to pay at all. (Because you can publish payments without including a transaction fee). But with the Lightning Network, users can pay one-time fees for opening a connection and joining the network, and thus can send and receive payments as fast as possible.
- COST-EFFECTIVE: With the main Bitcoin Blockchain, the fees may always be high due to the demand for the limited block space every 10 minutes, and in turn, make it costly for most users to constantly send Bitcoin through the Bitcoin blockchain. But with the Lightning network, users only make one-time big transaction fees to lock their part of provisions in the joint account they created while opening a connection with someone. From here, they can send Bitcoins to anyone within the network, for a relatively insignificant fee. This makes it easy and cheap to send as many transactions as possible for way less fees or even free.
- MICRO PAYMENTS: Due to the nature of the Bitcoin Lightning setup (where Sats are used), as well as the incredibly insignificant fees, users can make micro payments for things as little as paying for a coffee.
CONCLUSION:
We have seen how effective the Lightning Network is in scaling the Bitcoin technology. The Lightning Network greatly advances Bitcoin adoption, making it easy for people to use Bitcoin as money for day-to-day value exchange. Today, you can walk into any establishment where Bitcoin is accepted and make payments using Bitcoin, thanks to the Lightning Network.
Valet, our self-custodial Bitcoin wallet, also has Lightning Network technology built into it. Once you install Valet and create a wallet, you have automatically secured a spot on the Lightning Network.
All you need to do is find someone else you can open a connection (channel) to, and you can start sending and receiving Bitcoin over the Lightning network immediately.
Valet also has a special backup feature that saves the state of your Lightning channels on your device, such that even if you uninstall Valet, whenever you install it back, you can easily use that file to restore your wallet and all your lightning connections will be restored, this way, you do not run the risk of a forced channel closures.
Learn more about how to use Lightning on Valet here: https://valet.finance/
Shutting down....
Ugochukwu Chidire David
(@orion_davids on X)
Product Growth Lead
Standard Sats