You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lnbook/ch01.asciidoc

127 lines
9.6 KiB
Plaintext

[role="pagenumrestart"]
[[ch01_intro_what_is_the_lightning_network]]
== Introduction
=== What is the Lightning Network?
The Lightning Network is a payment system for Bitcoin.
It is a second layer protocol on top of Bitcoin that defines rules and contracts which enable the fast, secure, private, trustless and permissionless transfer of Bitcoin.
Users of the Lightning Network are able to transfer Bitcoin among each other at virtually no cost and in real time.
They are not required to wait for block confirmations for payments.
Once a payment arrives, it is final and cannot be reversed.
Like a standard Bitcoin transaction, a payment on the Lightning Network can only be refunded by the recipient.
While all Bitcoin transactions are stored in the blockchain where they can be tracked, the payments on the Lightning Network are off-chain and offer more privacy than Bitcoin payments.
Due to the use of onion routing, which is also used in Tor, even the nodes that are involved in forwarding the payment from the sender to the recipient do not know for whom they deliver the payment.
=== History of the Lightning Network
// The following is working draft and suggested mile stones in the history of the Lightning Network.
The history of the Lightning Network could be considered to be as old as the history of Bitcoin.
The first response to Satoshi Nakamotos initial publication of the Bitcoin whitepaper on the metzdowd cryptography mailing list discussed the issue of scale.
[quote, James A. Donald, https://www.metzdowd.com/pipermail/cryptography/2008-November/014814.html ]
____
We very, very much need such a system, but the way I understand your proposal, it does not seem to scale to the required size.
____
While it seemed as if James A. Donald just refered to keeping the set of unspend transaction outputs (UTXOs) it quickly became clear that also verifying and storing that many transactions would become infeasible for any blockchain.
A key requirement for a second layer protocol such as lightning (and as will be decribed in greater depth later in this book) is the ability to sequence transactions external to the blockchain. In the first verisons of Bitcoin, Satoshi Nakamoto recognised this and introduced a data field called `nSequence` into the input transaction data.
The `nSequence` was intended to allow users to transmit updated versions of a transaction to the network, changing the outputs of a transaction, effectively creating a payment channel.
Such a payment channel would then be valid as long as the transaction was not mined.
Satoshi Nakamoto envisioned this construction for the case of high frequency trading.(ref)
There were however some weaknesses in this initial formulation, which limited its potential. Firstly, the 'payment channel' would only be open until the transaction was mined by the miners, either limiting the duration the payment channel or handing control of the payment channel to the miners. Secondly, there was no economic incentive for miners to respect the `nSequence` number, making this mechanism effectivley useless.
The revocable Sequence maturity contracts which form the payment channels in the first version of the Lightning Network have taken part of their name from their property of fixing the nSequence field and making the latest version of the sequence of updates in the payment channel enforcable.
// find / add sources for some of the claimes
While the Bitcoin network was growing adoption the blocksize and usage has not been an issue in the frist couple years.
In 2012 Gavin Andresen proposed the Ultra Transaction server on his blog.
The Ultra Transaction server would have been a trusted partner of a 2-2 multisig wallet that could not steal funds but allowed signing transactions from a 2-2 multisig wallet.
Andresen observerd that with such a mechanism payments would effectively take place offchain and that this would result in arbitrary throughput of scale.
Andresen also noted that there might be a better construction which would require less trust in the Ultra Server.
Though it seems as he was on the right way he wasn't able to solve the problem of constructing a trustless payment channel.
The Work of Andresen lead to discussions on Bicroin talk and later on the bitcoin-development mailinglist resulting in the first construction of a unidirectional payment channel.
* unidirectional payment channels
** http://web.archive.org/web/20190419103457/https://bitcointalk.org/index.php?topic=91732.0[bitcoin talk discussion].
** 2012 http://web.archive.org/web/20190730234737/http://gavintech.blogspot.com/web/20150510204329/http://gavintech.blogspot.com/2012/07/off-chain-transactions.html[[Blogpost by Gavin Andresen]]
** (Mike Hearn, Jeremy Spilman 2013 - http://web.archive.org/web/20190501234757/https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2013-April/002433.html
* Multiple white papers (Joseph Poon, Thaddeus Dryja - https://lightning.network/lightning-network-paper.pdf / Christian Decker, Roger Wattenhoffer - https://tik-old.ee.ethz.ch/file/716b955c130e6c703fac336ea17b1670/duplex-micropayment-channels.pdf)
* Milan meeting and creation of BOLTs
* segwit activation
* passing of integration tests / mainnet launch
* Australia Meeting and BOLT 1.1
* Initial nodes/wallets - eclair, c-lightning etc
* Reckless - Testing on mainchain.
* satoshis.place / The lightning torch
* today
[[user-stories]]
=== Lightning Network Uses, Users, and Their Stories
As an electronic cash system it preserves the 3 most important properties of money (medium of exchange, store of value, and unit of account).
The invention of money (and in particular Bitcoin) was primarily made to facilitate trade and enable the exchange of value between people.
However, without the Lightning Network Bitcoin is hard to be used concurrently by millions of people.
Therefore, in order to fully understand the uses of the Lightning Network, we'll examine it from the perspective of people using it.
In particular the use cases will come from previous users of Bitcoin as well as people who have not used Bitcoin before.
Each of the people and their stories, as listed here, illustrates one or more specific use cases.
We'll be seeing them throughout this book:
consumer::
A regular consumer on the Internet or in the offline world who wants to make purchases.
content creator / curator::
A person or platform offering content on the web.
They want to install a pay wall or get tipped by their fans and consumers.
This could even include music or video streaming on demand paying in real time
John is a 9 year old boy from Australia, who wanted a games console just like his friends. However he was told by his dad that in order to buy it, he had to earn the money by himself. Now John is an aspiring artist so he knows that while he is still learning, he can't charge much for his artwork. After learning about Bitcoin, he managed to setup a website to sell his drawings across the internet. By using the Lightning Network, John was able to charge as little as $1 for one of his drawings. By being able to set a fair price, which would normally be considered a micropayment and as such not possible with other payment methods, and by using a global currency such as Bitcoin, John was able to sell his art work to customers all over the world and in the end buy the games console he so very much wanted.
gamer::
Similar to the content creator, a gamer and live streamer would like to be tipped.
However, in gaming (and gambling) the transfer of bitcoin could be part of the game for example to trade items or to wage for bets.
migrant::
Remittance is an important way for refugees to help their loved one in their home country.
Characteristic for remittance is that the payments usually are cross border and relatively small.
However, they might happen on a monthly base as they are just a fraction of the monthly wage.
professional bitcoiner::
A person who wants to earn interest on their bitcoin without the risk of lending them to other people could decide to set up routing nodes on the lightning network.
By providing liquidity to the Lightning Network the routing capacities will be increased offering the chance to earn routing fees on the owned bitcoin.
merchants::
Merchants live on the margin of the sold goods.
They usually pay fees for using point of sales services and several payment methods which take a fraction of the transferred money.
This directly decreases the margin on which merchants operate.
A merchant will be happy to get an additional payment method which is virtually for free to the merchant.
An example of a merchant is Silke.
Silke runs a small coffee shop in an upmarket street in Berlin.
She knows about Bitcoin and wants to accept it in her shop, but has been reluctant to do so because she knows that Bitcoin payments take approx. 10 minutes to be confirmed into her account.
However with the Lightning Network, she knows that her regular clients, such as Joerg can pay for their coffee at her shop, quickly and with negligible fees.
Additionally, by using the Lightning Network, Silke has all funds deposited instantly to her wallet and with usually smaller fees on her side as well.
Ultimately this allows her to provide a better service or to offer better pricing for her products.
=== Getting Started
==== Choosing a Lightning Network Wallet
* full nodes (c-lightning, eclair, lnd) + remote controls
* phone / desktop wallets (SPV clients)
* custodial services / wallets?
// Mastering bitcoin also had a section about custodial web wallets. So it might be fair to include them.
==== Quick Start
[[getting_first_bitcoin]]
==== Getting Your First Bitcoin on the Lightning Network
[[sending_receiving]]
==== Sending and Receiving Bitcoin on the Lightning Network