A Primer to the Lightning Network (Part 2): The LN Between 2 People.

in #bitcoin7 years ago (edited)

In Part 1, we talked about multisig addresses and how you can have Open Channel Payments and Closed Channel Payments. These are the building blocks of the Lightning Network (LN). Now let’s look at how the LN would work between 2 people: Alice the Boss and Carol the Graphic Designer.

The Lightning Network between 2 People

Let’s say Alice hires Carol as a Graphic Designer and Alice intends to pay Carol 0.1 LTC for every project she completes. Alice would rather avoid paying a transaction fee for every payment so she and Carol agree to use the Lightning Network(LN). The LN will allow Alice to pay Carol multiple times for only one transaction fee.

In order to use the LN, Alice and Carol create a multisig address where there must be 2 signatures in order for LTC to be sent (i.e to close the payment channel). This is called a 2 of 2 multisig address: 2 people, 2 signatures.

1.png

In order to set up the Lightning Network, Alice first sends 1 LTC into the multisig address. Alice then creates a smart contract that states it will return to her in 30 days. Both Alice and Carol must sign off on this because it is a 2 for 2 multisig address. This serves 2 purposes: a functional purpose and to act as insurance.

A. Functional Purposes of the 1 LTC in a time contract

  1. The 30 day smart contract creates an open payment channel.
  2. This open payment channel locks up the 1 LTC so that neither party can touch it until 30 days has passed.
  3. Alice will take from this 1 LTC and send Carol payments of 0.1 LTC for each project she completes.

B. The Time Contract as Insurance

The 1 LTC can only be spent in 2 ways: A) There are 2 signatures on a outgoing transaction B) The 30 days are up.

So if Carol doesn’t complete a single project, Alice can choose not to initiate or sign off on any payments towards Carol. The 30 days would hit and the 1 LTC would automatically return to Alice.

Ok So Let’s Review:

1 LTC is locked up in the multisig address through an open payment channel and it will be sent to Alice in 30 days.

  • The 1 LTC can also be sent if Alice and Carol both sign a payment transaction before the 30 days.
  • An open payment channel is created when one person proposes spending the LTC. It remains open until the second person signs the transaction.
  • Therefore, several payment channels can be opened and exist at the same time if the second person never signs the transactions. Only the proposed payment that has 2 signatures will go through.
  • To help conceptualize this, it is easier to think of open payment channels as proposing a payment offer. For example, Alice can propose several different payment offers to Carol. If Carol doesn’t sign any of them, she leaves the offers on the table. Carol now has the luxury to choose which offer she likes the best. When she has decided, she finalizes this decision by signing the offer she wants. This then closes the payment channel. Ok, now let’s flush this out through Alice and Carol.

Alice Pays Carol for 1 Project

Carol finishes 1 project and so Alice decides to pay Carol 0.1 LTC. Alice goes into the multisig address to propose a payment of 0.1 LTC to Carol from the 1 LTC that is locked up in the multisig address. She does this by initiating a payment and then signs the transaction. Carol is notified by the multisig address that 0.1 LTC is trying to be sent and asks for her signature. If Carol accepts the offer, she signs this transaction closing the payment channel. This means that 0.9 LTC will stay in the multisig address and 0.1 LTC will go into Carol’s address. The transaction will also be recorded on the blockchain and a transaction fee will be sent to the miners.

BUT! Carol decides not to sign this proposed payment of 0.1 LTC and leaves the offer “on the table.” So the 0.1 LTC is unspent and stays as an open payment channel. The reason for this is because Carol has 9 other projects she to finish for Carol.

3.png

Alice pays Carol for 2 Projects

Carol finishes her 2nd project and so Alice decides to pay Carol for two jobs. Alice goes back into the multisig address and proposes a second transaction, or another payment channel, to Carol.

Alice offers her 0.2 LTC for 2 jobs because Carol can only accept 1 offer. You can not combine or sign two offers. Once Carol signs one payment channel, all the other offers will disappear. Carol is notified that 0.2 LTC is trying to be sent and requests her signature. She now has 3 choices:

  1. Does she accept the 0.1 LTC offer only?
  2. Does she sign off on the 0.2LTC offer only?
  3. Does she do nothing and keep working on the other 8 projects for Alice?

3.png

Closing the Payment Channel

Carol decides to do nothing and continues to work for Alice.This process of offering payments and ignoring them happens over and over again until Carol finishes all 10 projects for Alice. Alice proposes and signs the 10th transaction to Carol for 1 whole LTC.

*Side note: Up to this point, not a single transaction has been recorded on the LTC blockchain and no fee charged because none of the payment channels have closed. This is what it means to have “offchain” transactions. None of the offers have been recorded on the blockchain and therefore a fee is not sent to miners.

Carol is notified of Alice’s proposal of sending 1 LTC and she immediately accepts the offer by signing the transaction. This closes the payment channel and the 1 LTC is sent from the multisig address into Carol’s personal address. The transaction is finally recorded on the blockchain and a transaction fee is sent to a miner.

Through the Lightning Network, only 1 fee out of 10 was paid. Also, only 1 transaction out of 10 was recorded on the blockchain. This is significant because the LN significantly reduces the need for bigger blocksizes.

Carol Can Initiate Payments Too

One last point to mention is that Carol can propose payments too because she controls the multisig address as well. However just like before, the transaction can only be completed if there are two signatures. So Alice must sign Carol’s proposal for the LTC to be sent.

Summary

Alice offered 10 payments of 0.1 LTC to 1 LTC to Carol through the Lightning Network. Carol accepted the offer of 1 LTC by signing off on it. Of the 10 proposed transactions, only 1 was recorded on the blockchain and there was only one transaction fee.
Alright now that we have the basics down, you can now move on to Part3: The Full Picture of the Lightning Network.

Sources:
https://lightning.network/


https://streams.lykke.com/Project/ProjectDetails/b134b15b54e745559f26c217bef5a2f8

Donation Addresses:
LTC: LRrekGu3D4ALFvVwWHNXxBMpphujHCnPkv
BTC: 1Mj6Jrz8WzgnQPP2KQrQXZ6AUWcLsTJukg

P.S. Follow me on twitter at ecurrencyhodler!

Sort:  

Hi. I am a volunteer bot for @resteembot that upvoted you.
Your post was chosen at random, as part of the advertisment campaign for @resteembot.
@resteembot is meant to help minnows get noticed by re-steeming their posts


To use the bot, one must follow it for at least 3 hours, and then make a transaction where the memo is the url of the post.
If you want to learn more - read the introduction post of @resteembot.
If you want help spread the word - read the advertisment program post.


Steem ON!