Crypto Academy | Season 3 | Week 7 :- Homework Post for @sapwood

in SteemitCryptoAcademy3 years ago

Hello steemians, I'm here to submit my season 3 homework task 7. That carried by @sapwood.

2N61tyyncFaFVtpM8rCsJzDgecVMtkz4jpzBsszXjhqan9wbmcgftkeSNpRx1fy9otxE6tMLuaUY1uwgh5NorAtaiddwDRXZRoyDhYCVqj62kS51mFeSuAU1tS4p9ZLxk1SGCwVk8dgz~2.png

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?

The biggest problem with the bitcoin blockchain is its low scalability and high congestion because of the number of transactions to get validated.

To resolve this problem a new idea of a lightning network was put forward. Lightning network is the 2nd layer payment protocol that works under the bitcoin blockchain and in this nodes itself validate the transaction and only initial and last transactions are broadcasted to and validated by the main blockchain.

In a lightning network funds are secured with hashed time lock contract protocol which is a smart contract that allows only the receiver to unlock funds that too in the prescribed time. After this and only in this condition funds are refunded to the sender.

Lightning node- In a lightning network, nodes make the lightning network and validates the transaction. Another main purpose of a lightning node is to connect sender and receiver via shortest way with no or minimum node between. So that no or minimum transaction is levied.

Lightning channel- Sender or receivers in the lightning network are connected with each other through the lightning channel. The purpose of a node is to keep the channel shortest.

Different uses of lightning network- The main purpose of a lightning network is to keep the main blockchain less congestion and to increase its scalability. Another purpose of lightning networks is to make micropayment more popular because by using the bitcoin blockchain, micropayments become more expensive and take much time. By using a lightning network both of these problems can be resolved.

Question.2
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?

To create a lightning network between two nodes, first of all, funds are deposited in the lightning blockchain from the on-chain blockchain and this transaction is broadcasted to the main blockchain and thus can be traced using a block explorer. This is called funding transaction
After this, when transactions are made using the lightning network, these transactions are not broadcasted to the main blockchain instead of this these are validated by the nodes themselves.
These transactions are called commitment transactions.
And hundreds of transactions can be made between two nodes and the transaction fees are nill if the nodes are connected directly and fees are low if the nodes are connected indirectly.

After every commitment transaction, the balance is updated using a smart ledger in the wallet. And these transactions are signed by both parties.

These are commitment transactions are secured with HLTC protocol and can be unlocked using only a secret hash.

When this channel is to be closed last copy of transactions signed by both parties is sent to the main blockchain, all these commitment transactions are considered as a single transaction and broadcasted on the main blockchain.

Now as we discussed that in the lightning network, only the funding transaction which is made for the first time, and the last transaction when the channel is to be closed, are broadcasted to the main blockchain. Thus these transactions are on-chain transactions.

On the other hand, commitment transactions that are validated by the nodes themselves are done off-chain and are not broadcasted to the main blockchain.

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

HTLC is an acronym for hash lock time lock contract. HTLC Smart contract is like security for transactions of the Lightning Channel. As we know, Lightning Channel is made up of two nodes joining together. And the Lightning Network is made up of many channels. So it is common that there are thousands of nodes of Lightning Network and all are connected to each other. And the same happens for channels, all channels are interconnected with each other. So One peer can transfer funds to any other peer through the payment channel.

And imagine, if a peer wants to transfer funds to a peer that is not connected to each other, is it possible? Yes, it is possible. In this situation, an intermediate peer will participate in the transaction and will charge some amount as fees as his share.

Let's say I (A) want to send some payment to another peer (C). But I am not directly connected to him. So there the Intermediate Peer (B) comes in. As I am connected to B and B is connected to C (another peer). So in this case there can be a transaction between A and C. But here in return B will charge some fee. However, this fee is very small, as this transaction is recorded off-chain.

For this, you can see a real example of Bitrefill. I purchased the product from Bitrefill but I was not directly connected to it. So here the Trampoline node acted as an intermediate peer. And charged 0.00003 mBTC as a fee which is negligible.

Question.4
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? (Screenshots needed)

Steps to set up & open a Lightning Channel using Electrum

To create a channel, go to the channel section and click on open channel.
![32FTXiZsHoAW6noHJDhrg3W8ZKHVFSsLYM859aTDCF8iErGeRyFS5XhsXExgkt9XVpRhcw1KnjHjiNVgTviF11Rzrijgdf1rp45crZidiykkPMmdDmt6ZBepr8q1zFzLcw1ayxVTmStUbqee.jpeg](https://cdn.steemitimages.com/DQmecqzFqBeuEaMkW2KBEgevfAaj2sv3FZf8ZqwEtkiUpzp/32FTXiZsHoAW6noHJDhrg3W8ZKHVFSsLYM859aTDCF8iErGeRyFS5XhsXExgkt9XVpRhcw1KnjHjiNVgTviF11Rzrijgdf1rp45crZidiykkPMmdDmt6ZBepr8q1zFzLcw1ayxV
32FTXiZsHoAW6noHJDhrg3W8ZKHVFSsLYM859aTDCF8iErXG2ERaL9fAHND3DhUWJqkD33ua3yjBmTaKQ2jkt5cAJRwwXo6oN9UHLCcgdEYVQvqQHC8G6wnme3oGW94mP6FnpyhBDuKuwsie.jpeg

Crypto Academy | Season 3 | Week 7 :- Homework Post for @sapwood
aman9675 (63)in SteemitCryptoAcademy • 3 days ago
Hello steemians, I'm here to submit my season 3 homework task 7. That carried by @sapwood.

20210814_224247_0000.png

Question.1
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?

The biggest problem with the bitcoin blockchain is its low scalability and high congestion because of the number of transactions to get validated.

To resolve this problem a new idea of a lightning network was put forward. Lightning network is the 2nd layer payment protocol that works under the bitcoin blockchain and in this nodes itself validate the transaction and only initial and last transactions are broadcasted to and validated by the main blockchain.

In a lightning network funds are secured with hashed time lock contract protocol which is a smart contract that allows only the receiver to unlock funds that too in the prescribed time. After this and only in this condition funds are refunded to the sender.

Lightning node- In a lightning network, nodes make the lightning network and validates the transaction. Another main purpose of a lightning node is to connect sender and receiver via shortest way with no or minimum node between. So that no or minimum transaction is levied.

Lightning channel- Sender or receivers in the lightning network are connected with each other through the lightning channel. The purpose of a node is to keep the channel shortest.

Different uses of lightning network- The main purpose of a lightning network is to keep the main blockchain less congestion and to increase its scalability. Another purpose of lightning networks is to make micropayment more popular because by using the bitcoin blockchain, micropayments become more expensive and take much time. By using a lightning network both of these problems can be resolved.

Question.2
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?

To create a lightning network between two nodes, first of all, funds are deposited in the lightning blockchain from the on-chain blockchain and this transaction is broadcasted to the main blockchain and thus can be traced using a block explorer. This is called funding transaction
After this, when transactions are made using the lightning network, these transactions are not broadcasted to the main blockchain instead of this these are validated by the nodes themselves.
These transactions are called commitment transactions.
And hundreds of transactions can be made between two nodes and the transaction fees are nill if the nodes are connected directly and fees are low if the nodes are connected indirectly.

After every commitment transaction, the balance is updated using a smart ledger in the wallet. And these transactions are signed by both parties.

These are commitment transactions are secured with HLTC protocol and can be unlocked using only a secret hash.

When this channel is to be closed last copy of transactions signed by both parties is sent to the main blockchain, all these commitment transactions are considered as a single transaction and broadcasted on the main blockchain.

Now as we discussed that in the lightning network, only the funding transaction which is made for the first time, and the last transaction when the channel is to be closed, are broadcasted to the main blockchain. Thus these transactions are on-chain transactions.

On the other hand, commitment transactions that are validated by the nodes themselves are done off-chain and are not broadcasted to the main blockchain.

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

HTLC is an acronym for hash lock time lock contract. HTLC Smart contract is like security for transactions of the Lightning Channel. As we know, Lightning Channel is made up of two nodes joining together. And the Lightning Network is made up of many channels. So it is common that there are thousands of nodes of Lightning Network and all are connected to each other. And the same happens for channels, all channels are interconnected with each other. So One peer can transfer funds to any other peer through the payment channel.

And imagine, if a peer wants to transfer funds to a peer that is not connected to each other, is it possible? Yes, it is possible. In this situation, an intermediate peer will participate in the transaction and will charge some amount as fees as his share.

Let's say I (A) want to send some payment to another peer (C). But I am not directly connected to him. So there the Intermediate Peer (B) comes in. As I am connected to B and B is connected to C (another peer). So in this case there can be a transaction between A and C. But here in return B will charge some fee. However, this fee is very small, as this transaction is recorded off-chain.

For this, you can see a real example of Bitrefill. I purchased the product from Bitrefill but I was not directly connected to it. So here the Trampoline node acted as an intermediate peer. And charged 0.00003 mBTC as a fee which is negligible.

Question.4
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? (Screenshots needed)

Steps to set up & open a Lightning Channel using Electrum

To create a channel, go to the channel section and click on open channel.
IMG-20210812-WA0002__01.jpg
Now it will give you a warning type message that you really want to open your first channel. Click on ok.
IMG-20210812-WA0007__01.jpg
Now you can select for your node with which you want to open the channel. Or you can just set it to default. Also, enter the amount you want to add to your channel. The minimum amount is 2 mBTC. Enter the amount and click on ok.
IMG-20210812-WA0006__01.jpg
Now for confirmation, enter your password for confirmation. Enter the password and click on ok.
IMG-20210812-WA0005__01.jpg
Now you will see a pop-up stating that your channel is established. And you can see the same in the status option as opening
IMG-20210812-WA0004__01.jpg
After 3 confirmations, the Lightning channel is opened completely and usable. Now you can perform the off-chain transactions on it.

As the initial translation that is funding transaction is done on-chain, you can see the details on the block explorer.

E-commerce purchasing using Lightning Network::-

32FTXiZsHoAW6noHJDhrg3W8ZKHVFSsLYM859aTDCF8iErNidkkfdLgP2s1XkfYzTJA39Z43ocWsYo54Q5bB121k2UkCjT8a6erPYT3wycw4CBvyGgSEVarZYAveQGVxhDk28Typsor9oEpW.jpeg

To purchase using a lighting network go to an e-commerce website that supports the Lightning channel. For example, here I am visiting the bitrefill website.

Go to bitrefill website and click on browse product
IMG-20210812-WA0024__01.jpg
Now select your product, here I am purchasing for my mobile prepaid plan (JIO). I clicked on that icon.
IMG-20210812-WA0023__01.jpg
Now Select the plan you want to purchase and you can also see the value in bitcoin here. Click on purchase
Enter your Email id on the next page to get the updates of the order.

Now select the method using which you want to purchase. Here I select lighting bitcoin.
32FTXiZsHoAW6noHJDhrg3W8ZKHVFSsLYM859aTDCF8iErXG2ERaL9fAHND3DhUWJqkD33ua3yjBmTaKQ2jkt5cAJRwwXo6oN9UHLCcgdEYVQvqQHC8G6wnme3oGW94mP6FnpyhBDuKuwsie.jpeg

Coin Marketplace

STEEM 0.17
TRX 0.16
JST 0.029
BTC 74021.49
ETH 2621.74
USDT 1.00
SBD 2.42