Blockchain was designed as a platform for secure, transparent money transfers. Over time, it has become a technology that offers much more than just transactions. It has become a framework for creating indispensable solutions for the market, such as decentralized applications for supply chains, banking services, etc.
Even blockchain technology may not be able to reach perfection, but it can decelerate transactions through scalability.
The Scalability Issue
Cryptocurrency, successful from the moment of its creation, ended up booming in 2017. With the addition of the benefits that blockchain offers to businesses, more and more users began to join, and its disadvantages became more visible. In the two most popular networks, Bitcoin and Ethereum, users can store data in blocks that are limited to 1MB (on Bitcoin), while on Ethereum, the only limitation is the gas fee. One more significant difference is the frequency of block executions. Bitcoin allows one block per ten minutes, but on Ethereum, the number averages between ten and thirty transactions per second.
The low capacity level of both networks remains an unsolved issue in the crypto community.
Will Capacity Increase Work?
Increasing the capacity of a block is not an innovative idea, and three years have been dedicated to discussions on block increases of 2, 4, and even 8MB. This led to the appearance of soft and hard forks such as Bitcoin Cash, SegWit, and SegWit2x.
Soft Fork vs. Hard Fork
In order to obtain a fundamental understanding of the recent situation in the blockchain community, let’s sort out the algorithm of soft and hard forks.
Nodes have software which they update from time to time. When a user uploads a block that opposes the platform’s characteristics or doesn’t refer to the existing consensus on the network (in case of hard forks), the nodes that updated to a new version automatically verify a new block. This means that there are new characteristics in the block — ones previous blocks didn’t have. However, the nodes that didn’t update or declined the new software version are separated from the new network (hard fork), and continue working on the previous version of the network.
The most popular example of the hard fork is Bitcoin Cash, which separated from the Bitcoin network on August 1, 2017.
Unlike hard forks, soft forks don’t cause network forks. When a soft fork occurs, it means that the characteristics that the previous blocks had do not appear in the next ones. On top of that, the transactions conducted before don’t contradict the new ones. To put it simply, users who accept the new block update the software, and those who don’t decline it. However, this doesn’t mean that a new network will appear.
Bitcoin Cash
In May 2017, the number of users who complained about transaction time peaked, which led to the unyielding need to speed up the network.
One of the first and the most popular hard forks of Bitcoin was BitcoinCash, which aimed to increase the size of one block from one to eight megabytes. This solution meant elimination of the problems of transaction time and high fees for speeding up the network. The community of miners actively supported the solution due to the growth that became possible owing to the increase in total block commission, even in case of the drop in transaction fees. However, developers opposed the implementation of BitcoinCash, since 1MB deregulation leads to demand for more computational power. This has a killing impact on small businesses, and makes them exit the network.
BitcoinCash is said to be faster than Bitcoin, but the issue of stability remains. Additionally, BitcoinCash opposites the main blockchain feature, decentralization, as small businesses cannot afford to use it.
Segregated Witness
The Bitcoin community has become concerned over the past few years by discussions about scalability issues and solutions.
In 2017, Segregated Witness made headlines in much of the crypto media. It had two solutions up its sleeve:
SegWit
Segwit is a Segregated Witness soft fork aimed to reduce the size of transaction in a block by means of moving the signature to the end of the transaction code, which would significantly speed up the network.
SegWit’s aim was to solve the transaction malleability issue, which allows a slight adjustment in transaction data and results in a unique ID change. Furthermore, the entities conducting the transactions couldn’t be sure if the ID of their transaction would remain the same after it passed the verification and mining process.
The solution allowed expansion of the block size up to 2MB. With the SegWit solution, the Bitcoin network becomes secure enough to develop such tools as Lightning Bitcoin Network in order to make transactions significantly cheaper and faster.
SegWit2x
Presented in November 2016, SegWit caused a flurry of criticism and discussions about which block size would most benefit the network.
After the New York Agreement, SegWit2x came out in May 2017 as an alternative to SegWit to resolve the disagreement between users and the core developers of the Bitcoin network.
The main difference between SegWit2x and SegWit was that the block size was meant to be increased up to 4MB, along with potential additions in terms of the Lightning Network structure, online codes, anonymity, zk-SNARKs technology, and smart-contract use. However, in November 2017, several days before its release, there was an announcement of its cancellation.
Fortunately for the Bitcoin network, there is a solution that offers not only a resolution to the scalability issue, but also cheaper transaction fees.
The Scalability Solution
Bitcoin Cash, Bitcoin Unlimited, SegWit, SegWit2x — all of these Bitcoin forks were created with the goal of solving scalability issue. However, not all of them have succeeded due to problems such as malleability and centralization.
One of the most long-awaited solutions in the market is the Bitcoin Lightning Network, which Applicature is happy to explain below.
Bitcoin Lightning is built on top of the network, allowing users to conduct Bitcoin transactions much faster and more cheaply. Compared with the sky-high block transaction fee on Bitcoin in December of over $35 U.S.,(capture 1) and the current Bitcoin transaction fee of less than one U.S dollar (capture 2), Bitcoin Lightning still offers a cheaper solution.
Let’s consider this table of Bitcoin transaction fees for the next block (second column), three blocks (the third column), and six blocks (the fourth column):
However, the current transaction fee on the Bitcoin network appears to be much cheaper:
Even more important, however, is Bitcoin transaction time. Currently, one Bitcoin block confirmation takes users around ten minutes. Considering the number of transactions being conducted on the network each second, there are lines of blocks awaiting confirmation. This was the main reason for the user complaints that led to Bitcoin Cash and SegWit2x hard-fork formation.
The Lightning Network for Bitcoin transactions is a system that opens the opportunity to conduct transactions in milliseconds, thanks to the payment channels that users build between themselves to transfer money.
Bitcoin Lightning Network
Elizabeth Stark, CEO of Lightning Labs, announced March 15, 2018, as the Bitcoin Lightning Network release date. The number of users adopting the network increased by 15 percent monthly between April and August.
On the Lightning Network, it is not necessary to open a direct channel between nodes that have financial relations. The nodes build a network with nodes that have already created a channel, forming a net. Currently, you can view a visualization of the Lightning Network here.
The statistics about Bitcoin Lightning show that the current capacity of the network is about 107 BTC, or $685 U.S.:
With regard to Bitcoin Lightning’s status, at the moment of this writing, there were 3,951 nodes and 11,283 channels on the network.
How to Use Bitcoin Lightning Network
As Lightning is a network of channels, Applicature is providing a full guide on how to open, operate, and close a channel on Bitcoin Lightning. Before you learn how to use the network, it is essential to become acquainted with the details described in the following paragraphs.
Unconfirmed Transactions
Bitcoin consists of a set of transactions, each referring to the previous one, including its hash (unique ID) for the transaction data. Each transaction has the lines “from” and “to” that refer to the wallets of a sender and a recipient. The sender should meet the requirements by confirming that he/she actually possesses the money he is sending. Otherwise, the system won’t recognize the transaction as valid. The recipient, which is the “to” line (and eventually the “from” line in the next transaction) will have to include new requirements.
It is important to mention that transactions conducted in the Lightning Network are not uploaded on the blockchain; local nodes store them. However, nodes can decide to send the transactions to the network.
According to the graphic above, the black transaction is already confirmed. The blue one can be sent to the network by the node A if the previous transaction has been confirmed. The red one can be sent to the network by node B under the same conditions. Node A can sign and send the unconfirmed transaction to the network having sent two BTC to node B, and only after this will node B be able to sign and send his/her transaction to node C.
Double-Spending Prevention
The idea of double-spending is simple. Let’s consider a real-life example. When you buy a cup of coffee and pay five dollars for it, you cannot pay the same five dollars for other purchase, unless you steal it.
A double-spending prevention approach is crucial to financial fraud elimination on the blockchain.
It works as follows: if two senders refer to one recipient, only one of two transactions will be verified by the miners.
Here, node A faces a choice between two transactions in order for them not to run into a conflict. Only one of the transactions marked in blue may be verified as valid.
Multi-Signature
Conducting a money transfer on Bitcoin Lightning usually requires two signatures. When two users open a channel between one other, the transaction will be verified by two nodes: the sender and the receiver.
Let’s see how it works in practice:
If node A wants to send two BTCs to node B, he/she will only be able to do so after self-signature and the signature of node B. A cryptographic signature on the blockchain (a private key) is a unique set of numbers. As soon as the transaction is multi-signed, node B receives the money. It’s important to keep in mind that whenever a transaction is signed by both nodes, it is impossible to change or delete it.
Multisig is an approach that makes any fraudulent action within the channel impossible, as node A cannot spend Bitcoin without node B being aware of the transaction.
Timelock
One more element on the Bitcoin Lightning network is the time lock, which allows blocking Bitcoins until a certain time. There are two types of timelocks:
- Check Lock Time Verify (CLTV)
- Check Sequence Verify (CSV)
CLTV puts a lock on Bitcoin until a certain time in the future or until a certain block. In contrast, CSV locks Bitcoin until a certain number of blocks have been generated. Often, a time lock on the blockchain is used as a delay.
Hash and Secret
On the Bitcoin Lightning network, a “value” or “secret” is a unique line of numbers that is extremely difficult to predict, even by powerful computers. The peculiarity is that this unique line can be hashed by anyone who knows the “secret,” but a reverse action is not possible.
This ploy can also be used on the Bitcoin platform in order to block Bitcoin. For example, you can include a hash in the line ‘to,’ with a requirement that anyone who wants to spend this money has to type in a value equal to the hash in the ‘from’ line.
In the picture above, the hash is illustrated as a lock, and the secret value is a key.
Bi-Directional Payment Channels
The idea of payment channels was a point for discussion a long time before Bitcoin Lightning creation. It goes without saying that the ordinary payment channels are useful; however, they are monodirectional. The main difference of the Lightning Network is that the payment channels on top of it are bi-directional and trustless. At this point, it is essential to understand what “trustless” means in terms of blockchain and Bitcoin Lightning.
Blockchain technology roots out the need for trust by distributing the ledger among users. The resulting “trustless channel” means that users don’t have to worry about potentially fraudulent intentions on the part of their partner, as these are simply impossible to pull off. Principles like multi-signature and double-spending prevention do not allow a node to transmit Bitcoin without the other channel participant putting his/her signature under the transaction.
How to Open a Channel
In order to open a channel between nodes, users must conduct the opening transaction, which will define the deposits they put into their accounts.
Opening the channel on Bitcoin Lightning makes sense for the nodes that conduct payments quite often, for example, once a week or even every day. This statement is based on the fact that transactions on the Lightning network do not require the verification of a majority of nodes on the blockchain; thus, money transfer is much faster.
Step 1: Opening Transaction
The channel will be opened as soon as nodes A and B send their deposits (let’s say 5 BTC) to the address with multi-signature. This will be the opening transaction. Bitcoin may be sent from this address only if both nodes sign the agreement. That is why Bitcoin Lightning channels are trustless.
In addition, nodes get a secret value and a corresponding hash in order to be able to sign transactions.
Step 2: Commitment Transaction
The next step for node A will be creating a “commitment transaction”. The node A leaves 4 BTC on his/her wallet and sends the other 6 to an address with multi-signature. This address is quite unusual: it includes CSV-timelock, so node B will be able to unlock it when a certain number of blocks have been conducted (let’s consider one thousand).
Node A can unlock this block if he/she has a secret value, however, node A only has the hash of the secret value. Therefore, there is no way to unlock the block yet.
As a result, node A has to sign the commitment transaction and send it to node B instead of uploading it to the network.
Meanwhile, node B has to do the same actions, but with reverse parameters: create the commitment transaction, leaving 6 BTC to him/herself and sending the other four to the new address with multi-signature. Node A will be able to unlock this address as soon as 1,000 blocks are conducted within the channel, or with B’s secret value.
After the two nodes exchange commitment transactions and the hashes of their secret values, they upload the opening transaction to the blockchain. The channel is then considered open.
Now, both nodes can send the commitment transaction they received from each other to the Bitcoin blockchain. However, if A does this, B will instantly receive 6 BTC. If B does it, A gets 4 BTC. In any case, if any one of the two nodes sends this transaction to the network, he/she will have to wait until 1,000 blocks have been conducted to access the address with multi-signature with the rest of the Bitcoin.
Channel Update
A little while later, if node B wants to send one BTC back to node A, they have to update the channel state. To perform an update, they need to repeat the actions described in the previous chapter despite the opening transaction, which has already been recorded on the blockchain. This time, node A leaves 5 BTC, and the other five BTC go to the address with multi-signature and the new secret values. The nodes also send hashes of new secret values to each other, along with signed commitment transactions. The node that does this will receive its 5 Bitcoins after 1,000 blocks have been conducted, and the other will receive it— immediately.
Why can’t node B send the previous commitment transaction to the network, instead? It seems that if he/she does this, he/she will receive 6 Bitcoins. As mentioned earlier, the nodes exchange their secret values for the previous commitment transactions. Signing and sending the old commitment to the network means that node A immediately gets 4 Bitcoin. However, node B will be able to get his/her 6 Bitcoins only after 1,000 blocks have been conducted.
Meanwhile, node A will get the opportunity to obtain B’s money, as he/she knows the secret value. All of this works in reverse if node A sends the previous transaction to the network.
According to Bitcoin Lightning’s network consensus as described in the previous paragraph, both nodes are interested in following it.
Now, the scheme of bi-directional payment channel can be expanded for conducting payments within the network.
How to Create a Network
Let’s say node A wants to pay node C 1 Bitcoin. To conduct the money transfer, they could open their own payment channel, but this becomes unnecessary, as A and B have already created one. Thus, C may transfer money to B, who will send them directly to A through their channel.
However, here we come to the point of trust in the network. Node A doesn’t have any reason to believe that B has sent the money to C, or that C hasn’t received the transfer. Trust within the Bitcoin Lightning network is predefined by cryptographic protocol.
To send money securely, node C creates a secret value and sends its hash to the node A. Node C asks B to buy the secret value for 1 Bitcoin, while node A says he/she will send B 1 Bitcoin for the secret value B received from C. Performing this sequence of actions, A compensates B for his/her expenses and sends 1 Bitcoin securely.
The trust within the network is also enabled by HTLC (hash time-locked contracts)
Bitcoin Lightning nodes can also make a profit by serving as intermediaries. This will come in the form of commission for transmitting money through their channels.
Channel Closure
The Bitcoin Lightning Network is an off-chain system, which means that any transaction will never get on the blockchain. However, that channel is protected by blockchain consensus.
If two nodes have created a channel on the Lightning network mutually, they need to create a transaction that overrides the actions taken when they opened the channel. In other words, if node A wants to close the channel, he/she creates a transaction, leaving 4 Bitcoins and sending 6 to the node B. If B signs this transaction, the channel can be considered closed.
Therefore, the Bitcoin network will record only opening and closing transactions, even though the nodes have conducted numerous payments between them.
One can only imagine how the Lightning network frees up blockchain.
Lightning Network Implementation
At the moment, there are three well-known implementations of the Lightning Network by the following companies:
- ACINQ — Eclair (a scala implementation of the Lightning Network, which runs with or without a graphic user interface)
- Blockstream — C-lightning (a specification-compliant implementation)
- Lightning Labs — LND (Lightning Network Daemon is a complete Lightning Network node implementation)
Litecoin, Stellar, Zcash, Ether, Ripple, Bitcoin Gold, and Bitcoin Diamond are the cryptocurrencies adopting the Lightning network protocol.
Risks
A second-long transaction with no fee on the blockchain sounds catchy, but doesn’t it seem like a set-up?
There are several risks users of the Lightning Network should be aware of:
- Improper timelocks. If the timelock is defined incorrectly, there is the possibility that an invalid transaction will become valid, which itself enables the other party to achieve coin theft.
- Forced expiration spam. All time-locked transactions may become valid; if one fraudulent node expires all of his/her channels at once, this will lead to broadcasting transactions on the blockchain. The blockchain would then be loaded with mass spam.
- Coin theft. When conducting transactions, nodes should be online. If the device storing a private key is malfunctioning, coins could be stolen if the device is under attack.
Conclusions
Lightning Bitcoin came along in 2018 as a solution to the scalability issue on the Bitcoin network. It is a set of payment channels created between nodes who frequently conduct transactions with each other.
What makes more and more nodes turn to the Lightning network each month is the speed of money transfers and transaction fees. Both aspects are significantly more profitable to nodes who perform financial operations on the Bitcoin network.
One of the most valuable characteristics of the Lightning Network is financial fraud elimination. Due to the fact that both nodes open the channel and contribute inputs, no one can steal the contributed coins. In order to do this, they would have to close the channel, which is impossible without two sides signing the agreement.
Applicature is always ready to answer any questions regarding the relevance of the Bitcoin Lightning network to your business.