Crypto Academy / Season 3 / Week 7 - Homework Post for Professor [@sapwood] : Lightning Network

This is my homework post for Steemit Crypto Academy Season 3 Week 7 for Professor @sapwood’s lesson Lightning Network.

Note : I performed this task on Windows 10 PC, Google Chrome..

Task 1

1.a.1. Lightning Network

The Lightning Network is a technology that has come to address the scalability issues Bitcoin is facing. The Lightning Network works separately from the Bitcoin blockchain, but works in tandem, with its own nodes and software that will make it run on the blockchain.

Source: https://medium.com/yardcouch-com/bitcoin-supercharged-c9acef098d27

The main idea of the Lightning Network technology is actually very simple: dealing with blockchain scalability problems by using a method of recording transactions outside the blockchain (off-chain). Users can use Lightning Network technology through a multi-signature wallet. In the wallet, they will carry out peer-to-peer transactions in a mini-ledger called Channel which can only be accessed by the parties who own the wallet. In the channel the parties can make as many transactions as they need.

-----oOo-----

1.a.2. Lightning Node

Lightning nodes (or Lightning Network nodes) are nodes in the Lightning Network, whose task is to monitor the blockchain they are bound to (the Lightning Network can be used not only on the Bitcoin blockchain network), and interact with other Lightning Network nodes on the blockchain to allow transactions to take place.

-----oOo-----

1.a.3. Lightning Channels

Lightning Channel is a mini-ledger within a multi-signature wallet that works on Lightning Network technology, where peer-to-peer transactions between parties are recorded off-chain. In the Lightning Channel, both parties can send and receive money (cryptocurrency), and they can do unlimited transaction in it.

After all transactions are completed, the channel can be closed. After that, the initial and final balance both parties have are recorded on the blockchain.

-----oOo-----

1.b. Achieving A Near-Instant Settlement, Near-Infinite Scalability

Lightning Network technology enables blockchain to achieve a near-instant settlement by recording transactions outside the blockchain (off-chain) in a peer-to-peer nature. Off-chain transactions do not require confirmation from the block (which tend to take times) because they are not logged into the network. So it can be said that transactions occur near-instantly.

About near-infinite scalability, the Bitcoin network has a scalability of 7 TPS. Imagine if Bitcoin processes 7 transactions which has 10 off-chain transactions each, then Bitcoin actually has processed 7 x 10 = 70 transactions at that second. This means that the scalability has become 70 TPS. And the number of off-chain transactions that can be made is unlimited. Imagine if some off-chain transaction has 100 or 1000 transactions, or even more. So, it's understandable why it's called Near-Infinite Scalability.

-----oOo-----

1.c. The Different Uses

Some uses of the Lightning Network technology:

  • More Privacy Payment and Money Sending. In the Lightning Network, transactions are protected from the knowledge of other parties because they are carried out peer-to-peer and off-chain. Unlike in remittances through conventional delivery services that can collect transaction data and share it with affiliated companies.
  • eCommerce. The best example of this is bitrefil. For Indonesia, there are currently 22 merchants offering goods in this eCommerce, dominated by game credits and telephone credits. Maybe in the future there will be more merchants selling here.
  • Chat Apps. Lightning Network can also be used as a secure and fast chat application. Examples of chat applications that use Lightning Network technology are WhatSat and Sphinx.
  • Game Development. Several games have been created using Lightning Network technology, for example Mint Gox, Satvival, Lightnite, and Satoshi's Games. These games offer Bitcoin token rewards for their players.
  • It could be a new way of tipping content creators and social media activists. With very low transaction fees and micro-finance payments made possible by this technology, rewarding content creators and social media activists who upload interesting content can be done easily and cheaply.

Task 2

Because all transactions that occur inside Lightning Network are off-chain (not recorded in the block), so there is no need for these block fees. And, the transaction fees in the Lightning Network are very small, almost non-existent, this is due to competition between nodes in the Lightning Network. The block fees only occur when the Lightning Channel is established (opened) and when it is closed, because these two transactions are recorded on-chain.

Task 3

HTLC (Hashed Timelock Contract) is a smart contract that allows the creation of time-based escrow to secure transactions. This means that the parties involved impose time restrictions on a transaction. If the transaction is responded to outside the time limit, the transaction will not occur.

HTLC uses elements of existing smart contracts, but HTLC has two elements that distinguish it from traditional smart contracts, namely: 1) hashlock and 2) timelock.

The hashlock is used by the originator of a transaction to generate a hashed version of a public key. The original hash can then be unlocked with the associated public key. This key only known by both parties. In practice : the originator of a transaction creates a transaction and generates a hashed public key.

The timelock has its uses in determining the time period in which a transaction is valid. There are two different timelocks availabe:

  • CheckLockTimeVerify (CLTV). CLTV uses time to determine when tokens will be released. The release can be done on a certain date and time, or on a certain block..
  • CheckSequenceVerify (CSV CSV uses the number of block creations to determine when tokens are released.

Intermediate node could not interfere with the transaction, since it does not have the private keys to unlock the transaction.

Task 4

For this task I used Electrum wallet.

4.a. Opening A Lightning Channel In Electrum

I open Electrum standard wallet. The wallet showed the balances. It was not enough to establish a lightning channel, which need a minimum of 2 mBTC.


So I opened my UPbit wallet and sent some more BTC to my Electrum wallet.

I had to wait about 30 minutes before the sending was successful. Now I had enough token to proceed.

I clicked the [Channels] tab (marked number 1) to open the channels window. In it I clicked the [Open Channel] button on the upper right of the window (marked number 2).

On the confirmation pop-up box that followed, I clicked [Yes].

On the next pop-up box I needed to do 2 things: 1) choosing the trampoline node from a dropdown menu, which I did not perform and I left it as it was, and 2) filling in the amount in mBTC to send to the lightning channel. When it was done, I clicked [OK].

On the next pop-up box, I did not change anything, just filled in the password and clicked the [Send] button.

The transaction was sent to blockchain. Now I needed to wait for 3 confirmations before this channel could be used. I clicked the [OK] button.

Now there was a channel waiting to be useful in my Electrum lightning channels window.

It took around 45 minutes since the transaction was sent to blockchain until the lightning channel was opened. When it was opened at last, I could see that my wallet balance changed, I had 2 mBTC in Lightning Channel.

4.b. Making a Transaction Using Lightning Network

I opened bitrefill. I decided to top up the phone.


On the next page, I made sure that Bitcoin was selected as the currency that I would use to pay for this transaction. Next I filled in the purchase details. After I finished, I pressed the [Purchase] button.

A pop-up box appeared, since there were no other purchases I needed to make, I pressed the [Checkout] button.

The next page showed the details of the order that I have made. Here I was asked to fill in my email address and to agree to the Terms and Conditions and the Privacy Policy. When I was done, I clicked the [Continue] button.

The next page was where I must select the payment method. I clicked on [Lightning (BTC) tab.

The next page was the payment page. Users can choose one of three different ways to do the payment: by doing the QR code, or pay in wallet, or copy the invoice and paste it to their wallet. I chose the last one. I clicked on the [Copy] button.

A pop-up box appeared. I clicked on the first box that contained the lightning invoice. Clicking on it automatically copied it. Now I was ready to paste it into my wallet.

On the [Send] page of my Electrum wallet, I pasted the copied lightning invoice to [Pay to] box, the Description and the Amount boxes were filled in automatically. I clicked the [Pay] button.

A confirmation pop-up box appeared on the screen. I confirmed it by clicking the [Yes] button.

The transaction was immediately recorded as a note in the send queue section. It will be there until the transaction is successful.

Took around four minutes until the payment was successfully made. It is much faster when compared to Bitcoin on-chain payment method.

The balance has changed. And the ability of sending and receiving in this lightning channel has also changed, since I have decrease in the balance, now there was place for receiving activity.

4.c. Closing The Channel

To close a channel, right-click on the channel to close, and from the pop-up list choose [Close channel].


On the pop-up box, confirm it by clicking [Yes] button. The request force close from remote peer tick box is useful if we want to close the channel but counterparty's node is offline.

The transaction sent to blockchain for confirmation.

The channel status changes from "Open" to "Closing". "Closing" means it is still waiting to be processed on the block.

About one hundred minutes later, I saw this notification in the Channels window. It showed that the channel was closed. The balance showed changes at the bottom part of the wallet window, It showed that the lightning wallet balance had gone to 0 mBTC.

The below picture shows that the transaction was start to process on the blockchain at 23:18 hours.

4.d. Fee Incurrance

There was a fee that I had to pay when I was making payment with the lightning channel, but it was very small. As shown in the following picture, I paid 0.00003 mBTC as fee so that my total payment amount became 0.10977 mBTC.

4.e. Does It Record The Transaction On-Chain? If yes indicate it, if no, then tell us why it does not record the transaction on-chain.

I checked out whether the transaction was recorded on-chain or not. So I copied the payment hash.


Pasted it on the Bitcoin blockchain explorer. I used blockstream.info.

It came out with "No Result Found".

So it is clear that the transaction was not recorded on-chain. It was because the transaction occurred in a peer-to-peer system. Avoiding to record the transaction on-chain is the idea to deal with the scalability issue in the blockchain.

4.f. How Swap Function Helps To Improve Sending And Receiving Capacity

Each lightning channel has a maximum capacity and it depends on how many tokens were sent to it when the lightning channel was created. So, the higher the lightning funds number ("Can Send"), the smaller the receiving capacity ("Can Receive"). To increase the channel's receiving capacity, users can exchange lightning balances into onchain balances.

For example: my Lightning Wallet has a capacity of 2000 mBTC with a balance ("Can Send") of 1500 mBTC, so the "Can Receive" number is 500 mBTC. (Let's put aside all fees first, to make it easier for us to understand this). I can increase the "Can Receive" number by swapping my lightning wallet balance. Suppose I do a 1000 mBTC swap, then my lightning channel balance ("Can Send") will be 1500 – 1000 = 500 mBTC and the "Can Receive" number (receiving capacity) will be 500 + 1000 = 1500 mBTC. At the same time I will also receive an onchain fund of 1500 mBTC. Swapping requires server fees and mining fees.

I can increase my channel receiving capacity by Swapping my lightning funds for onchain funds.

Task 5


5.a. Backing Up A Wallet File


5.a.1. Backing Up The Whole Wallet

To back up a wallet, I clicked [File] on the menu. From the dropdown list, I chose [Save backup].


A pop up box will appear. I clicked on the blank button to choose a directory to place the back up file.

I browsed the PC for the folder. When I found the folder of my choice, I opened it and clicked the [Select Folder] button.

On the next pop up box, I could click the [OK] button to confirm.

The method above is how to back up the entire wallet, including all available channels. To back up a specific channel, here's how:

5.a.2. Backing Up a Specific Channel

To back up a specific channel, go to Channel window and right click the channel to back up, then choose [Export backup].


The channel back up window will open. There are three ways available to do the back up: by copying the image and save it somewhere, or copying the text, or by saving the QR image as a file. One can do all three.

5.b. Why and When To Back Up A Wallet File

Backup files cannot be used to send or receive tokens. The use of this file is when lightning channels need to be closed, for example when users lose their wallet files. Closing the channels will cause the funds contained in them to be sent to the on-chain. So this is important as a security measure, so that users who lose their wallet files can still get their funds back from their lightning wallet.

Back up needs to be done every time a new channel is opened.

5.c. Funding Transaction

Funding Transaction is the opening of a Lightning Channel. This transaction is recorded on-chain.

To see it in the wallet, open the Channels window, right click on the channel needed to be observed, and from the pop-up list, choose [View funding transaction].


The funding transaction detail window opened. The transaction ID could be used to track this transaction on the blockchain using blockchain explorer.

To see it on the block explorer, go to Bitcoin blockchain explorer and paste the transaction ID inside the search box and click search button.


Here comes the transaction detail on the blockchain explorer.

5.d. Commitment Transaction

Commitment Transaction is the transaction spending from the 2-2 address. In my case it was when I purchased the phone top-up. Commitment Transaction is recorded off-chain.

To see the Commitment Transaction details in the wallet, open the [History] window, right-click on the lightning transaction, on the pop-up list choose [View Payment].


Lightning Payment window will open. The Payment Hash would be useful if we're gonna track the transaction on the block explorer.

To see it on the block explorer, pasted the Payment Hash inside the search box and click search button.


The transaction was not found on the block explorer. Because it was recorded off-chain.

5.e. Settlement Transaction

Settlement Transaction is lightning channel closure. This transaction is an on-chain type.

There are two ways to see it in the wallet: open the History window and right-click on the transaction, then on the pop up list choose [View Transaction].


Or, in the Channels window, right click on the channel and choose [View closing transaction from dropdown list.

Both ways will show the Transaction.

To see it on block explorer, in the History window, right-click on the transaction, then on the pop up list choose [View on block explorer].


The block explorer will open in the default browser.

Thanks

Thanks Professor @sapwood for the lesson titled Lightning Network.

Pictures Sourcing

  • The editorial picture was created by me.
  • All another pictures were screenshoots and were edited with Photoshop CS 3.

Sources and Reading Suggestion


My Introductory Post | Artikel Perkenalan Saya.


Picture created by @aneukpineung78


Thanks for stopping by.

Sort:  

Good jod for indonesia

Loading...

This is very clear content about this topic, I so much appreciate your work here. You are a wonderful author. Good work done my friend

Coin Marketplace

STEEM 0.18
TRX 0.13
JST 0.028
BTC 64479.05
ETH 3181.85
USDT 1.00
SBD 2.57