Lightning Network, Explained!!

in #steemit7 years ago

1.jpg

1.What is this all about?

Blockchains are slow.
And therefore, expensive. If I had to send you some Bitcoins, you’d receive them in about a couple of hours and I’d have paid a heavy transaction fee too. With such a reputation, how will Blockchains take over the world?
Any idea that can solve the non-scalability of Blockchains is worth attention, time and effort. Lightning Network is one such idea. But before we understand the solution, we’ll need to understand the problem.
If you’re already aware of the problem, you can directly jump to the next section.

2.Why Blockchains are slow?

Think of a Blockchain as a register.
And this register contains several pages (blocks) where each page has several transactions. As soon as a page has been filled with transactions, it needs to be added to the register before starting to record transactions on the next page.
Before a page (block) can be added to the register (chain), there’s some processing that needs to be done to ensure that everyone agrees with the contents it contains. The process approximately takes 10 minutes (for Bitcoin Blockchain) for each block.
Imagine, you send 1 BTC to your friend, Joe. The transaction will look something like this.

2.png

Among other things, a transaction contains information about the sender, the recipient, the amount and the transaction fee.

3.Wait a minute, transaction fee?

Yes, there’s an additional fee.
You can pay it to incentivize miners to include your transaction in a block as soon as possible. There’s no set price and it’s entirely up to you how much you are willing to pay to speed up the process. The higher the fee, faster your transaction will go through.
At any given moment, there are several transactions available to be recorded on the current page.

3.png

The miners, i.e. computers working in the Blockchain network, have to decide which of the available transactions to include in the current block. To help them decide, they look at which transactions yield the most rewards — meaning that the transactions with the highest transaction fee will be included first.

4.png

If there are enough transactions with a higher transaction fee than yours to fill up the block, your transaction will have to wait in queue. The wait can last from a few minutes to a few hours. And sometimes, even days. The more you pay in transaction fees, the quicker your transaction is processed.

5.png

That’s why Blockchains are slow, and therefore, expensive for everybody to start using. Ideally, the adoption of Blockchain would mean more transactions happening but as the number of transactions goes up, the network will become slow, making a hurdle for adoption. What a paradox!
Lightning Network (LN) is a potential solution to the problem.

4.So what is Lightning Network again?

The idea behind LN is that not all transactions are required to be recorded on the Blockchain.

Imagine you and I transact quite a few times among ourselves. In such a case, we can bypass recording the transactions on the Blockchain and carry them off the chain.

In the simplest terms, how it’ll work is -- we’ll open something called a payment channel between us and record its opening on the Blockchain. Now, you and I can transact any number of times through this payment channel and it can stay open for any number of hours, days, weeks or decades. The only time we would touch the Blockchain ever again will be when we would want to close the channel. Then, we’ll write the final status of the transactions that occurred through the channel on the Blockchain.

Using this idea of payment channel, we can create a network of payment channels such that it would be only rarely required to transaction on the Blockchain. Imagine there are three characters - Xan, Yelena and Zeke.

If Xan and Yelena have a payment channel opened between them and Yelena and Zeke have a payment channel opened between them, then Xan can send money to Zeke via Yelena.

Suppose Xan wants to send 2 BTC to Zeke, Yelena will send 2 BTC to Zeke and Xan will reimburse Yelena with 2 BTC.

That’s what the idea of Lightning Network is. Because you won’t be touching the Blockchain often, the transactions will be happening at lightning speed. As you might have guessed by now, all the magic happens in the payment channels. Let’s learn the magic trick then. Let’s learn the magic trick then.!

5.And what are those payment channels?

It’s like a safety deposit box where two people deposit equal amounts of money and each put a lock on it.

6.png

This action of depositing equal amounts of money in a common box is recorded on the Blockchain in the form of an ‘Opening Transaction’ and thereafter a payment channel is open between those two people.

The idea behind locking money in such a box is that no one person can spend the money in the box without the other. The money in this box is then used to transact between each other.

Imagine, Xan and Yelena pool in 10 BTC each in the common box. And now, if Xan wants to send 2 BTC to Yelena, how would he do that?

To do that, he would transfer a promise of ownership for two of his Bitcoins in the common box to Yelena. After this transfer of promise, if the box is unlocked, Xan will be able to take 8 BTC from it and Yelena will be able to claim 12 BTC.

7.png

But they will not open the box because they want to continue transacting between themselves. That’s the beauty of this arrangement.

Now, if the next day, Yelena has to send 1 BTC to Xan, she would do the same - transfer a promise of ownership for one of her Bitcoins to Xan. After these two transactions, if the box is opened, Xan can claim 9 BTC and Yelena can get 11 BTC.

To imagine how off-chain transactions look like, consider this:
8.png

To sum it up, payment channel is nothing but a combination of pooling some money together and then transferring the promise of ownership of the pooled-in money in the agreed upon manner. If ever either of Xan or Yelena wants to close the channel, they can.

Closing a channel would simply mean opening up the box and taking the money inside. This opening of the box happens on the Blockchain and the who owns how much from the box is recorded forever.

9.png

That’s how payment channels work. But that doesn’t even come close to defining their true potential. Their true power is unleashed when two or more payment channels work together to form a network - The Lightning Network.

6.Got it, so how does it actually work?

LN works by moving the value from the ownership of the Bitcoins to the promise of ownership of the Bitcoins.

This shift is huge. Like always, we will use an example to understand this. Imagine there are three people - Xan, Yelena and Zeke - such that there’s a payment channel open between Xan and Yelena, and there’s another channel open between Yelena and Zeke. Note that Xan and Zeke have no payment channel between them.

In such a situation, if Xan wants to transfer 2 BTC to Zeke, he can use the payment channel between Yelena and Zeke to do that. How does that look like?

Xan asks Yelena to transfer a promise of 2 BTC to Zeke on Yelena-Zeke payment channel and then he reimburses Yelena with 2 BTC on Xan-Yelena channel.

10.png

With such network of payment channels, a huge chunk of transactions can be off-loaded from the Blockchain to be carried out off the chain, therefore, freeing up the chain’s bandwidth. Using a network of payment channels, millions of transactions can happen, and that too without a hefty transaction fee.

That’s the Lightning Network.

taken from cointelegraph

Coin Marketplace

STEEM 0.30
TRX 0.26
JST 0.039
BTC 93723.65
ETH 3350.57
USDT 1.00
SBD 3.30