INTRODUCTION
edited with Canva
Blockchain technology has brought with it a lot of benefits like its hosting of cryptocurrencies, enablement of decentralized transactions as well as its interesting security features. However, the increasing adoption of this technology has equally brought with it an increasing number of issues, chief of which is that of scalability.
In addition to this issue of scalability, which is a far cry from what is obtainable with PayPal and Visa transactions, comes the issue of user privacy and the recurring cost-prohibitive manner in which the transactions occur. The lightning network which has been adopted by some crypto networks like Litecoin and Bitcoin comes as an answer to some of these major issues.
THE LIGHTNING NETWORK: LIGHTNING NODES AND LIGHTNING CHANNELS
A lightning network refers to a payment gateway designed on a layer 2 format and developed on a cryptocurrency network that is based on the blockchain technology intended to be used for the completion of micropayments among a peer-to-peer network at a very speedy rate without the funds being delegated to any third-party.
The first people to publish a drafted white paper for lightning network were Thaddeus Dryja and Joseph Poon in February 2015. Jack Dorsey, a mobile payments investor, has endorsed the concept. Eventually, the Bitcoin lightning torch was experimented in 2019 by an anonymous hodlonaut Twitter user.
Lightning Node:-
A Lightning Node is a sort of software developed to connect and interact with the underlying Lightning Network to enable the sending and receiving of payment from other connected nodes.
It monitors the blockchain it is developed on and acts as a bridge between other transacting nodes on the network. Unlike blockchain nodes, they only interact and validate transactions that are linked to it.
Lightning Channels:-
A Lightning Channel is a mechanism created by lightning nodes on the lightning network for the purpose of completing transactions.
It refers to the pathway through which the transactions would follow. Hence, it acts as the line of transactions among the different nodes.
NEAR-INSTANT SETTLEMENT
With the use of Lightning Networks, it is said that transaction throughput is potentially increased to 25 million transactions per second. In ordinary blockchain transactions each node has to strive to confirm all the ongoing blockchain transactions at the same time.
However, with lightning networks a node only has to confirm and validate the transaction to which it is connected. In this way the lightning network which functions off chain ensures near-instant settlements.
NEAR-INFINITE SCALABILITY
The lightning network also creates an atmosphere for near-infinite scalability and execution of multiple transactions in a very short time frame in that multiple peers can create lightning networks from their ends without any limitation.
Theoretically lightning networks are able to execute billions of transactions per second due to this fact. However, the limitation is only with the bandwidth and capacity the network is able to carry.
THEIR DIFFERENT USES
Lightning networks can be used in different ways:
- Generally, they enable payments and even Bitfinex uses it for both withdrawals and deposits
- It ensures granularity in that payment even smaller than a satishi can be made
- The intermediary node payments can even be as little as millisatoshis
- It ensures user privacy as payment networks are not recorded on blockchain
- Speed of settlement can be as low as milliseconds
- Transaction throughput is high as any number of transactions can occur per second; there are only limited by the speed and capacity of each node
- Transactions can be made across blockchains
HOW LIGHTNING NETWORKS ELIMINATE TRANSACTION FEES
The Lightning Network creates a second layer on the blockchain of a cryptocurrency. On this second layer, multiple lightning players can be created for the transmission of multiple payments strictly between the parties involved. Be that as it may, transactions are confirmed and validated by the lightning nodes between which the interaction is directly being made.
This means that transaction fees are eliminated as the transacting node would validate and confirm the transaction immediately by itself and not the case where nodes are paid to confirm and validate transactions, thereby creating miner's fees charged to transacting parties. Transaction fees can only be paid to intermediate nodes in the case that the transaction has to pass through them to get to another node with whom the sender is not directly connected.
Where The Transactions Occur:-
Furthermore, the transactions in lightning networks occur off-chain and interacting parties can send and receive payments between one another by simply making use of their individual digital wallets.
It is not every single transaction that occurs on the lightning network that is recorded on the blockchain. However the transactions are eventually settled on-the-clock training Wednesday lightning channel is closed with the use of the final balance sheet. So, only the opening records as well as closing records that are recorded on-chain. Transactions that occur in between are not.
TRUSTLESSNESS WITH HTLC
The lightning network makes use of the Hask Lock and Time Lock(HTLC) technology to ensure that there is trustlessness when payments are routed through intermediate peers or nodes. The HTLC works in the form of contracts that are time-locked which are used in carrying out Commitment Transactions.
It works as a combination of a Time Lock sequence together with a Hash Lock function. With the use of this technology payment can only be released to the receiver upon the provision of a secret information within the stipulated time frame (Time Lock).
A secret that is created, hashed and time-locked with a particular hash value is written into the payment script of the HTLC. This works in two scenarios to ensure trust less transactions viz a viz:
- The intended receiver produces the secret needed for the calculation of the H value in order to redeem the payment within the stipulated time frame
- The sender is unable to redeem the asset within the stipulated time lock but can only do that upon its expiration and, hence, invalidation
In the case that transaction is to be broadcast to a third node(say, Alice), from the first node(say, Bob), through a second node(say, James) because Alice is not directly connected to Bob, then:
- Bob is connected to James but is not connected directly to Alice
- James whom Bob is connected to is directly connected to Alice
- Alice creates and hashes a secret only known to her and sends it across to Bob
- Using the lightning channel for payment with James, Bob create a HTLC payment
- Bob initiates another payment to Alice
- James is unable to claim the payment but Alice does so since she has the secret
So, the transaction through the intermediate node becomes trustless and secure since the secret is not known to the intermediate node.
HOW TO CREATE, OPEN AND USE THE LIGHTNING NETWORK
I am going to be using the electrum wallet for this demonstration. Since I already have a funded standard electrum wallet, I simply proceed to create the channels as described subsequently.
- First on the home screen I selected channels as shown below and clicked yes
- This opens a new page where I have to include amount and the click ok
- Then, I input my password and indicated a fee rate. After that I click send
- A pop-up indicates that the channel has been established. I click ok
- From the image below the short channel ID is indicated with the sending capacity and the amount that can be sent out together with the amount that can be received.
This transaction can be tracked on the blockchain explorer. This is due to the fact that it is an on-chain transaction. To do this I undertook the steps below:
- From the home screen I selected the particular transaction
- I copied the transaction ID from the next page
- I visited blockchain.com, input the transaction ID and clicked enter
- Then it displays the details of the transaction as shown including the hash and the fees associated with it
Making An E-commerce Purchase With The Lightning Network
In order to carry out an e-commerce purchase I had to visit the Bitrefill platform through https://www.bitrefill.com
- While on the site I clicked on browse products from the top right hand corner
- On the next page that opens up I see different top products and I select MTN to recharge my mobile line
- On the next page I include the amount and include my phone number. Then, I enter purchase
- A new page shows up and I click checkout
- On the next page I fill in my email to receive status updates, agreed to terms and conditions and clicked continue
- Next, I select Lightning (BTC) for the payment of 625 sats
- On the next page I am required to copy or scan a QR code
- I click to copy this lightning invoice
- Having copied this I went back to my electron wallet and selected send. Then, I pasted the copied invoice and it displayed the other details of the transaction. Having done this I select pay
- A new page opens up and I have to confirm the intended transaction by clicking yes
- Near-instantly my mobile account balance is credited with the top-up from this transaction
- Equally, the order is completed on Bitrefill as shown below
Fees Incurred On The Transaction
Just as I have explained before, the fees incurred on the transaction was quite low or minimal. This is due to the fact that it is an off-chain transaction and does not include miners fees for verification. The insignificant fee is shown below:
Is the transaction recorded on-chain?
Actually, this transaction is not recorded on-chain. This is due to the fact that once a channel is opened all the microtransactions that occur through it would be recorded only on the channel in order to decongest the network itself. Hence, only the first and last transactions are recorded on-chain.
Swap Function
The swap function is a feature of the lightning network established with the creation of a lightning channel. It makes it possible for users to quickly transfer funds from the lightning channel to their on-chain account. This is done in such a way that the inbound capacity of the transferer is not affected. What this means is that the channel will still be retained.
Equally, with the swap function, the sending and receiving capacity of the user is significantly increased. So, by and large the swap function works to increase the general capacity of the channel.
How do you back up a wallet file(Channel Backup), why and when is it needed? Indicate the funding Transaction, Commitment Transaction, and Settlement Transaction both in your wallet and Block Explorer?
- To back up the wallet file I opened my wallet and right-clicked on electrum trampoline option and selected export backup
- On the next page I clicked save to initiate the save process
- A new page opened up and I impute a file name and clicked "save*
- I have to confirm this by clicking ok
Why and when backup is needed
Wallet backup is needed on several occasions. These include:
- It is needed so that users can close the channels that have opened and be able to transfer the funds dear in to an on-chain account
- With the saved wallet backup file the lightning channel transactions can always be imported back on the same device or wallet
- Generally, the backed up file can always be called up at any time in order to initiate the process of closing a channel
Indicating the funding transaction
The funding transaction is that which establishes a particular lightning channel. This can be accessed from the transaction history. It is always indicated with the message open channel
Funding transaction on blockchain explorer
Indicating the commitment transaction
These particular commitment transactions indicate the transactions that had occurred off-chain once the channel was opened. An example is the mobile top-up I undertook. Usually, there are no fees attached to them as fees are only incurred when intermediaries are used for transactions.
Indicating the settlement transaction
The settlement transaction is that which indicates the closed channel. It is only recorded when the channel is closed.
Settlement transaction on blockchain explorer
Closing The Channel
In order to close the channel I undertook the following steps:
- First, I right-clicked on the electrum trampoline
- Then, I selected Close channel
- I confirmed this option by clicking yes
- Finally, I clicked ok to close the channel
CONCLUSION
Lightning networks are very crucial because they will play a very important role in solving the problem of scalability and fixing the issue of high transaction fees that are usually associated with some blockchains, especially the Bitcoin network.
These lightning networks involve transactions that are carried out off-chain but which are connected through lightning channels with the help of lightning nodes that bridge the gap between on-chain and off- chain transactions.
The use of HTLC ensures that transactions are secret in the case that intermediaries are used to make transfers between two parties that are not directly connected.
The lightning networks are desired and serve as important solutions in solving scalability transaction fees and also a membrane very speedy transactions.