Steemit Crypto Academy ||Season 3 Week 7|| Homework task for @sapwood--Lightning Network.

in SteemitCryptoAcademy3 years ago

Hello, i am very happy to be participating in this week's crypto academy assignment task, and i want to specially thank @stream4u for the interesting and well detailed lecture this week. I would go ahead and attempt the homework task below.

Explain what do you mean by Lightning Network, Lightning Node, Lightning Channels? How does it achieve a near-instant settlement, near-infinite scalability? What are the different uses?

Lightning Network.

Lightning network has turned out to be a game changer in the cryptocurrency industry as it makes a transaction processing time to be fast as well as reducing the transaction fee. However, lightning network is a second layer off-chain built on the bitcoin network that makes use of a cutting-edge smart contract to create a fast transaction on a peer-to-peer platform.

Moreso, it enables a microtransaction that is not allowed in the traditional financial system. The lightning network surrounded by network of channels as only the first and last of the channels are been recorded on-chain.

Lightning Node.

The lightning network comprises of nodes and channels and a node ensures that there is an interaction between the other lightning network nodes when carrying out a transaction on the peer-to-peer network as well as monitor the underlying blockchain so as to avoid funds been stolen. Moreso, it keeps track of ownership of funds in the channel.

Lightning Channels.

Lightning channels enables users to send and receive money from one user to another. They are usually between two nodes and allows a seamless flow of payment between users. However, the lightning channels are been created by locking some funds on the Bitcoin blockchain (on-chain) and unlocking them on the lightning network with low or no fee attached, this way, money will not be spent on multiple places at the same time.

How It Achieve A near-instant Settlement, near-infinite scalability.

Lightning Network achieves a near-infinite scalability in the sense that it can process millions of transactions per seconds and possibly more by the help of the lightning nodes in which it verifies or validates a direct payment and not the whole payment for the network making it fast.

However, a near-instant settlement can achieved in the sense that when a transaction is been carried out on the lightning network which consist of the nodes and channels by a user, the user does not spend as much as 1 satoshi and at the same time no fees attached. The user gets the payment instantly without waiting because its an off-chain transaction.

Uses.

Privacy: The lightning network can be used to hide details or identities of the user's payment on the blockchain, so that others can not see the source nor its destination of the funds.

Unlimited Transactions: The lightning network can be used to carry out millions of transactions per second on the protocol which is not limited at less or no cost.

Arbitrage for Exchange: Lightning network can be used to figure out a trading strategy in the sense that a user can compare prices from other exchanges to prices on lightning network, and use these prices on the network to place a profitable trade.

Escrow Services: The lightning Network serves a an escrow for when two users wants to carry out a transaction, this entails a smart contract.

How does a Lightning network enable two peers to make a transaction or recurring or multiple transactions without any transaction fee? Does it happen off-chain or on-chain?

Lightning network enables two peers to make a transaction through the use of a multisig wallet, and this process starts with the two peers opening a payment channel through the lightning network but before that they have to create a multi-signature transaction that will act as a quasi-bitcoin wallet, which allows multiple persons to have access the same non-custodial address with their individual private keys.

Now, the first user opens the payment channel by starting the transaction which now creates a multi-signature address, then the second user sends funds to that same address and signs the transaction, this signifies his ownership of the funds. However, if the first user signs in as the receiver, then the exchange can take place and the channel will be closed. So unlimited transactions can be carried out at lesser cost. But if otherwise, the funds remains in the escrow, so all of this transactions happens off-chain.

How does the routing of payment through intermediate nodes(or peers) become trustless with HTLC?

The HTLC which is also known as the Hashed TimeLock Contract is made up a Hash Lock and a Time Lock. It is a smart contract that enables transactions to be carried out from one user to another but does not have the direct channel on the lightning network. It depends on the fact that a user can come up with a payment structure such that the other user can only receive the payment if he knows the secret the hash has actually shared with them at the required time-bound.

Now, how does HTLC works?
HTLC comes in to play when user A who wants to send money to another user 'C' through a multi-sig wallet forgets the password and the transaction cant go on because of that. Let me explain further, for example, if user A wants to money to user C, there has to be an intermediary user B. Now, user C who is the receiver generates a hashed secret only known by him, when that is done, a time is set for the transaction to take place, if it doesnt, the transaction is been cancelled and the money is returned back to user A.

But then, if the transaction takes place, the user C first sends the hashed secret to user A, so that user A is able to transfer the money to user B who is now acting as the lightning channel. however, user B receives this money from user A and generates a HTLC payment because he can not access the money due to the fact that he doesnt have the hashed secret so he sends it to user C who has the secret password or hash and can access the money. At the end, user B also gets his password and access his own money.

Finally, all this transaction is done with in a Time lock so as to avoid cancelling of the transaction and also the transaction fees that is being paid to user A is very low. This is how the HTLC becomes trustless.

Set up Lighting Wallet(Create a standard wallet, then open a Channel), open a Lightning Channel using Electrum(Trampoline Node), Phoenix, or any other non-custodial wallet that supports Lightning Network, make an eCommerce purchase(or a micro-Transaction) using Lightning Channel, then close the Channel? Does it incur fees? 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? How does Swap Function help to improve sending and receiving capacity?

First of all, i will go ahead to set up the lightning network and also open a lightning channel using Electrum (trampoline). I already have my Electrum wallet installed in my android, so i will have to fund it and continue with creating the channels.

  • So once i am in the front page of my Standard wallet, i will click on the Channel icon at the top of the front page, and then i also clicked on Open Channels

iMarkup_20210814_075825.jpg

So once i do that, a notification pops up and from it, i clicked Yes.

iMarkup_20210814_120226.jpg

  • Next, i inputted that amount of BTC i would like to use, which the minimum should be 2mBTC or 0.002BTC.
  • Next i chose Trampoline Nodes as Nodes and then clicked Ok.

iMarkup_20210814_130323.jpg

  • The next part, i inputted my Password, the ETA bar can be placed where i wish so i can get a fee thats affoldable. Then i clicked on Send.

iMarkup_20210814_152029.jpg

  • Once i clicked on Send, a notification comes out in which i have to confirm the Channel, So once i clicked Ok, the tab closes.

iMarkup_20210814_152204.jpg

  • So once i clicked Ok, i will wait a bit for the Short Channel ID to get updated and once it does, i will see the 2mBTC i deposited as 1.96338mBTC which i can send while 0 as what i receive.

iMarkup_20210814_184456.jpg

To be able to keep track of my transactions from the blockchain, i will have to get my transaction ID and i can get that by clicking on the History Tab and from here, i can go to the transaction i did with the 2mBTC, click on it and copy the ID.

Next, i input the ID and all the transactions are been seen.

iMarkup_20210814_194538.jpg

How to make purchase through E-commerce on the Lightning Network.

  • So for this task, i will be using bitrefill for the purchase.
  • On the front page, i click on Browse Products from the top of the page.

iMarkup_20210814_200745.jpg

  • So immediately i clicked on the Browse Products, logos of all the mobile telecommunication in my country are displayed, and i went ahead to pick GLO as the e-commerce i want to purchase.

iMarkup_20210814_201351.jpg

  • So, onthe next page, i can see different amounts that can be purchased but i will input the amount i want and then my mobile number before clicking on Purchase.

iMarkup_20210814_202106.jpg

  • Once i have clicked on purchase, a pop up comes out that instruct me to either Checkout or keep shopping, so i went ahead to click on Checkout. Then i input my email and click on continue.

iMarkup_20210814_203430.jpg

iMarkup_20210814_203940.jpg

  • After clicking on "Continue", the next page brings out different payment methods in which i chosed **Lightning(BTC), after which i copy my Invoice Lightning ID

iMarkup_20210814_204913.jpg

iMarkup_20210814_205111.jpg

  • So i go back to my Electrum Wallet and click on the Send tab which allows me paste my Invoice number on the Pay To space.

  • Once i do that, the Description and Amount comes up immediately, after which i click on the Pay button.

iMarkup_20210814_210747.jpg

  • Lastly i click on Yes to go on with the payment. After that, i got the notification on my mobile phone which implies that lightning network is so fast and scalable.

iMarkup_20210814_211008.jpg

Fees incurred during the transaction.

From the transaction i carried out, i noticed that the fees were very small. The fees incurred was 0.00006mBTC which explains the use case of the lightning network and this fee is incurred from when the intermediary nodes are been paid.

iMarkup_20210814_212217.jpg

Does it Incur Fess

Definitely YES, there were some very little fees that were incurred as i executed the transactions because it was looped directly rather they were presence of intermediaries (Electrum Trampoline Node). Those payments as we know are definitely for the settlement of this intermediaries who help in linking the buyer to the seller in a trustless manner.

Does it Record Transaction On Chain

Definitely NO. Lightning Network transactions are basically done off-chain except while creating a channel. Lets remember only the initial and final transaction takes place in the on-chain layer which makes other micro transactions offloaded to the off-chain layer. This is the idea of creating the lightning network to help process transaction in more swift and scalable manner that saves time and cost, hence this can only happen in the off-chain zone of the bitcoin.

Swap Function

This is another veritable feature created in the lightning Network that aids users to move funds across chains and still get befitted for it. This improves the capacity of the user by increasing its Receiving and Sending funds in the channel. In doing so by using this channel, it does not close or alter the the already created/ established channel in use.

How do you back up a wallet file, why and when is it needed? Indicate the funding Transaction, Commitment Transaction, and Settlement Transaction both in your wallet and Block Explorer?

How to back up a Wallet File

  • First Right Click on the Electrum Trampoline and then a drop down comes out where you click on Backup
  • Next you click on the Save icon and enter the filename then save.

iMarkup_20210814_215006.jpg

iMarkup_20210814_214504.jpg

iMarkup_20210814_214739.jpg

Benefits

  • It approves importation of the lightning channel transaction on same wallet.
  • it ensures the funds can be sent to On-Chain network.

how to indicate funding transaction

iMarkup_20210814_214301.jpg

iMarkup_20210814_194538.jpg

How to indicate Commitment Transaction

iMarkup_20210814_215006.jpg

iMarkup_20210814_215829.jpg

How to Indicate Settlement Transaction

iMarkup_20210814_215006.jpg

iMarkup_20210814_215325.jpg

Closing The Channel

iMarkup_20210814_220156.jpg

iMarkup_20210814_220303.jpg

iMarkup_20210814_220715.jpg

Thank you for reading..

Sort:  
Loading...

Coin Marketplace

STEEM 0.28
TRX 0.12
JST 0.032
BTC 67227.10
ETH 3137.71
USDT 1.00
SBD 3.76