Merge branch 'develop' into Enegnei-patch-1

pull/55/head
Andreas M. Antonopoulos 5 years ago committed by GitHub
commit fa667d8cf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,4 +10,11 @@ install:
- pip3 install --user codespell
script:
- git grep $'\r' -- "*.asciidoc" "*.md" && echo "^ Possible Windows style line ending detected. Please use Unix style line endings (\n)." && exit 1 || true
- git grep ' $' -- "*.asciidoc" "*.md" && echo "^ Trailing space detected at end of line. Please remove." && exit 1 || true
- git grep $'\t' -- "*.asciidoc" "*.md" && echo "^ Use of tabs detected. Please use space for indentation." && exit 1 || true
- git grep "[^ ] [^ ]" -- "*.asciidoc" "*.md" && echo "^ Satoshi style double spacing detected. Sorry Satoshi, please use single spacing." && exit 1 || true
- git grep -iE '(^| )(\w+) \2(\.|,|:|;| |$)' -- "*.asciidoc" "*.md" && echo "^ Detected lexical illusion in the form of a duplicated word. Please correct." && exit 1 || true
- for FILE in $(git ls-files -- "*.asciidoc" "*.md"); do if [[ $(tail -c1 $FILE) != "" ]]; then echo "File ${FILE} does not end with a newline character (\n)."; exit 1; fi; done
- git grep "" -- "*.asciidoc" "*.md" | uniq -c | grep -1 "^ [2-9] " | cut -b9- | sed 's/:$/:[more-than-one-blank-line-here-please-remove]/' | grep ":" && echo "^ Multiple blank lines detected. Please use only one blank line between paragraphs." && exit 1 || true
- codespell --ignore-words-list=que $(git ls-files -- "*.asciidoc" "*.md")

@ -1,5 +0,0 @@
[role="pagenumrestart"]
[[whatis_chapter]]
== What is the Lightning Network?
Initial paragraph

@ -17,7 +17,7 @@ Before contributing with a Pull Request, please read the current **PROJECT STATU
All contributions must be properly licensed and attributed. If you are contributing your own original work, then you are offering it under a CC-BY license (Creative Commons Attribution). *You are responsible for adding your own name or pseudonym in the Acknowledgments section in the [Preface](preface.asciidoc), as attribution for your contribution.*
If you are sourcing a contribution from somewhere else, it must carry a compatible license. The book will initially be released under a CC-BY-NC-ND license which means that contributions must be licensed under open licenses such as MIT, CC0, CC-BY, etc. Contributions under a "share-alike" or GPL license are not compatible with the CC-BY-NC-ND license and therefore cannot be accepted. You need to indicate the original source and original license, by including an asciidoc markup comment above your contribution, like this:
If you are sourcing a contribution from somewhere else, it must carry a compatible license. The book will initially be released under a CC-BY-NC-ND license which means that contributions must be licensed under open licenses such as MIT, CC0, CC-BY, etc. Contributions under a "share-alike" or GPL license are not compatible with the CC-BY-NC-ND license and therefore cannot be accepted. You need to indicate the original source and original license, by including an asciidoc markup comment above your contribution, like this:
```
////
@ -55,7 +55,7 @@ Adjust heading style in each section as follows:
5. Should include a unique anchor all lower case, underscore separated, within double square brackets (eg. [[intro_to_htlcs]]).
6. Headings should be followed by a blank line.
7. Heading should be followed by a paragraph of text, not a lower-level heading without any text. If you find one like this, add a TODO comment (line of 4 slashes "////", line with "TODO: add paragraph", line of 4 slashes)
8. Often it seems useful to link to a webpage / url. Since the research community figured out that every year about 50% of all outstanding url's become invalid we encourage you to use the wayback machine / Web Archive at: http://web.archive.org and provide a link to a saved copy of the web page.
8. Often it seems useful to link to a webpage / url. Since the research community figured out that every year about 50% of all outstanding url's become invalid we encourage you to use the wayback machine / Web Archive at: http://web.archive.org and provide a link to a saved copy of the web page.
Complete Example:
@ -72,7 +72,6 @@ As we saw in <<intro_to_ln>>, the intro paragraph is superb!
```
## Line endings
All submission should use Unix-like line endings: LF (not CR, not CR/LF). All the postprocessing is done on Unix-like systems. Incorrect line endings, or changes to line endings cause confusion for the diff tools and make the whole file look like it has changed.

@ -1,5 +1,7 @@
# Mastering the Lightning Network
[![Build Status](https://travis-ci.com/lnbook/lnbook.svg?branch=develop)](https://travis-ci.com/lnbook/lnbook)
![Mastering Lightning Cover](images/cover_thumb.png)
Mastering the Lightning Network is an O'Reilly Media book, due for publication in Q4'2020, and announced on August 28th by authors Andreas M. Antonopoulos ([@aantonop](https://twitter.com/aantonop)), Olaoluwa Osuntokun ([@roasbeef](https://twitter.com/roasbeef)), Rene Pickhardt ([@renepickhardt](https://twitter.com/renepickhardt)).

@ -4,20 +4,20 @@
=== What is the Lightning Network?
The Lightning Network is a payment system for Bitcoin.
The Lightning Network (LN) is a payment system for Bitcoin.
It is a second layer protocol on top of Bitcoin that defines rules and contracts which enable 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.
Users of the LN 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 on-chain Bitcoin transactions.
Like a standard Bitcoin transaction, a payment on the LN 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 LN are off-chain and offer more privacy than on-chain Bitcoin transactions.
Due to the use of onion routing, which is also implemented in Tor, even the nodes involved in forwarding the payment from sender to recipient do not know for whom they deliver the payment.
=== History of the Lightning Network
// The following is a working draft and suggested mile stones in the history of the Lightning Network.
// The following is a working draft and suggested mile stones in the history of the LN.
The history of the Lightning Network is nearly as old as the history of Bitcoin.
The history of the LN is nearly as old as the history of Bitcoin.
The first response to Satoshi Nakamoto's initial publication of the Bitcoin whitepaper on the metzdowd cryptography mailing list discussed the issue of scaling.
[quote, James A. Donald, First Response to the Bitcoin whitepaper https://www.metzdowd.com/pipermail/cryptography/2008-November/014814.html ]
____
@ -25,8 +25,8 @@ We very, very much need such a system, but the way I understand your proposal, i
____
While James A. Donald was probably referring to maintenance of the unspent transaction outputs (UTXOs) database, it quickly became clear that verifying and storing so many transactions would also become infeasible for any blockchain.
A key requirement for a second layer protocol such as Lightning (which will be described 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` field 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.
A key requirement for a second layer protocol such as Lightning (which will be described in greater depth later in this book) is the ability to sequence transactions external to the blockchain. In the first versions of Bitcoin, Satoshi Nakamoto recognised this and introduced a data field called `nSequence` into the input transaction data.
The `nSequence` field 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.
According to a Mailinglist post in 2013 by early Bitcoin developer Mike Hearn, Satoshi Nakamoto envisioned this construction for the use case of high frequency trading.footnote:HearnBitcoinDev[Mike Hearn on Bitcoin-dev - April 16th 2013 - Anti DoS for tx replacement http://web.archive.org/web/20190501234757/https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2013-April/002433.html.]
@ -42,10 +42,7 @@ What Hashcoin proposed would eventually be termed a unidirectional payment chann
With this mechanism, user "Alice" could fund a multi-signature address between herself and another user, "Bob", together with a timelocked transaction that 'refunded' the bitcoin back to Alice.
In their scenario, Hashcoin imagined Bob to represent an exchange.
The transaction used to fund the multi-signature address, which is controlled by Bob's and Alice's keys, is naturally called the funding transaction.
This transaction would not be signed and broadcasted by Alice before Bob provided a signature for the spend.
The setup allows Alice to send bitcoin to Bob.
As long as the channel remained open, she could update the channel balance with a newer transaction that sent less bitcoin back to herself and kept more bitcoin with Bob.
This transaction could not be mined without a signature from Bob.
Alice would send the partially signed transaction to Bob, who would sign it and keep it private.
Note that keeping it private is crucial. If Bob does not share the fully signed transaction with Alice, she does not have both signatures needed to spend funds from the multi-signature address. Except for the timelocked refund transaction, she can't send an outdated spend of the funding transaction to the Bitcoin network.
Bob, on the other hand, could do so, but he would have no interest in publishing an old channel state. The newer state would provide him with more bitcoin than the older state.
@ -54,25 +51,30 @@ Therefore, Bob can securely receive more updates to the channel balance as long
This mechanism would allow two users to engage into several smaller transactions which all happened outside of the Bitcoin network.
While this construction of the unidirectional payment channel would have solved the custody problem of exchanges it has never been widely implemented.
We can only speculate for reasons and guess that the overhead communication would have had to be standardized - as it is nowadays in the Lightning Network specification - which might have been too much overhead in the early days of Bitcoin.
We can only speculate for reasons and guess that the overhead communication would have had to be standardized - as it is nowadays in the LN specification - which might have been too much overhead in the early days of Bitcoin.
Also as a payment channel this system was not too useful as the channel could only at total send the total amount of provided Bitcoin in the funding transaction.
Once the timelock was over or all Bitcoin were sent to B the channel would have to be closed.
The obvious idea of opening two channels one from A to B and one from B to A would not have helped as each of those channels would have to be closed and reestablished once it ran dry.
The core breakthrough for the Lightning Network to become a reallity was the ability to create payment channels which technically can live forever and can send money back and forth as often as the peers wish to in combination with routing payments among several channels.
The core breakthrough for the LN to become a reality was the ability to create payment channels which technically can live forever and can send money back and forth as often as the peers wish to in combination with routing payments among several channels.
[TIP]
====
You can watch a video explaining the construction and operation of unidirectional payment channels online at: https://youtu.be/AcP3czefanM
====
Surprisingly both properties took quite some while until the community figured them out.
Technically speaking the unidirectional payment channel has all the important ingreedients (funding transaction to a 2-2 multisignature wallet, a transaction spending from the wallet encoding the balance, a timelock to allow refunding if the other side becomes unresponsive, off chain communication and the fact that no additional trust other than the one in the bitcoin network) of modern payment channels which are used in the Lightning Network.
Despite being rather useless in todays world we will study the unidirectional payment channel in more depth in this book as it is an easy to understand educational example to approach the construction of todays payment channels.
Technically speaking the unidirectional payment channel has all the important ingreedients (funding transaction to a 2-2 multisignature wallet, a transaction spending from the wallet encoding the balance, a timelock to allow refunding if the other side becomes unresponsive, off chain communication and the fact that no additional trust other than the one in the bitcoin network) of modern payment channels which are used in the LN.
Despite being rather useless in today's world we will study the unidirectional payment channel in more depth in this book as it is an easy to understand educational example to approach the construction of today's payment channels.
This setup has one safety issue as transactions have been malleable without the segwit upgrade.
A problem that needed to be solved for any payment channel construction that we know up till today and which has been fixed in August 2017.
During the first couple of years, the Bitcoin network was growing and the focus of many enthusiasts was on adoption, rather than the blocksize and scaling. However, in 2012 Gavin Andresen proposed the Ultra Transaction server on his blog.footnote:[Gavin Andresen's blog - July 4th 2012 - Off-the-chain transactions - http://web.archive.org/web/20190730234737/http://gavintech.blogspot.com/2012/07/off-chain-transactions.html]
During the first couple of years, the Bitcoin network was growing and the focus of many enthusiasts was on adoption, rather than the blocksize and scaling. However, in 2012 Gavin Andresen proposed the Ultra Transaction server on his blog.footnote:[Gavin Andresen's blog - July 4th 2012 - Off-the-chain transactions - http://web.archive.org/web/20190730234737/http://gavintech.blogspot.com/2012/07/off-chain-transactions.html]
The Ultra Transaction server was proposed to be 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 observed that with such a mechanism, payments would effectively take place offchain, allowing the number of transacations which could be handled by the system to be increased.
Andresen noted that there might be a better construction which would require less trust in the Ultra Server, and while his proposal was a step in the right direction, a few issues remained to be solved before the design of fully trustless payment channels was complete.
Andresen's work led to many discussions on Bitcointalk forum, and later on the bitcoin-development mailing list. These discussions resulted in the first construction of the first unidirectional payment channels.
Andresen's work led to many discussions on Bitcointalk forum, and later on the bitcoin-development mailing list. These discussions resulted in the first construction of the first unidirectional payment channels.
to sum this up: Andresen used a similar construction as the unidirectional channel.
They key difference was that a trusted party would have co-signed the spend of the funding transaction.
@ -82,18 +84,17 @@ The next day, probably in response to Gavin's blogpost, Meni Rosenfeld started a
As Hashed Timelocked Contracts have neither been invented nor seen to solve the issue of trustless routing Rosenfeld imagined trusted routing nodes.
Without mentioning the term network or routing of payments the idea of connecting payment channels and being able to send funds from anyone to anyone else even if there was no direct channel was born.
In Rosenfelds solution payment providers would be the ultraservers and they would among themselves settle the transactions based on trust.
It took us another 3 years until the lightning network whitepaper emerged which had solved all the bits and bolts necessary to get rid of the trust in Rosenfelds solution.
It took us another 3 years until the LN whitepaper emerged which had solved all the bits and bolts necessary to get rid of the trust in Rosenfelds solution.
It was 2013 that Bitcoin developer Mike Hearn refered to Meni Rosenfelds proposal and suggesting to reactivate the `nSequence` field which Satoshi preiviously had deactivated.footnote:HearnBitcoinDev[]
Also Hearn refered to a section on the contracts article talking about the case of micropayment channels with the help of `nSequence`
It was 2013 that Bitcoin developer Mike Hearn referred to Meni Rosenfelds proposal and suggesting to reactivate the `nSequence` field which Satoshi preiviously had deactivated.footnote:HearnBitcoinDev[]
Also Hearn referred to a section on the contracts article talking about the case of micropayment channels with the help of `nSequence`
Links:
* https://en.bitcoin.it/w/index.php?title=Contract&oldid=36712#Example_7:_Rapidly-adjusted_.28micro.29payments_to_a_pre-determined_party
* Multiple white papers
* Multiple white papers
** Joseph Poon, Thaddeus Dryja - The Bitcoin Lightning Network:
Scalable Off-Chain Instant Payments https://lightning.network/lightning-network-paper.pdf
Scalable Off-Chain Instant Payments https://lightning.network/lightning-network-paper.pdf
** Christian Decker, Roger Wattenhoffer - A Fast and Scalable Payment Network with
Bitcoin Duplex Micropayment Channels
https://tik-old.ee.ethz.ch/file/716b955c130e6c703fac336ea17b1670/duplex-micropayment-channels.pdf
@ -111,8 +112,8 @@ Bitcoin Duplex Micropayment Channels
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.
However, without the LN, Bitcoin is hard to be used concurrently by millions of people.
Therefore, in order to fully understand the uses of the LN, 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:
@ -125,7 +126,7 @@ 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.
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 LN, 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.
@ -137,8 +138,8 @@ Characteristic for remittance is that the payments usually are cross border and
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.
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 LN.
By providing liquidity to the LN 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.
@ -146,29 +147,47 @@ They usually pay fees for using point of sales services and several payment meth
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.
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 LN, 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 LN, 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)
* 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
* We start with a mobile wallet like eclair
* Verify the authenticity of the software (e.g. App store / Acinq website / github)
** discuss that a general phising scheme might consist of tricking you to download a similar looking software
[[getting_first_bitcoin]]
==== Getting Your First Bitcoin on the Lightning Network
* Trade fiat for Bitcoin (as in Mastering Bitcoin)
[[using_own_bitcoin]]
==== Process for people who already own Bitcoin ====
* send bitcoin to lightning wallet (1 onchain transaction - soon nodes / wallets may support funding a channel directly without sending bitcoins to the lightning network wallet first)
* find a node to open a channel with (Node explorer / Autopilots / ...)
* open a connection
* open a channel
* wait confirmations for the channel to become operational
[[sending_receiving]]
==== Sending and Receiving Bitcoin on the Lightning Network
* have the person who helps onbording open a payment channel (As complex as a bitcoin transaction)
* showcase how the funds now can be send back and forth
** create invoice
** decode invoice (do always before paying!)
** pay an invoice
* showcase how an arbitrary invoice can be paid e.g. https://voting.ln.rene-pickhardt.de

@ -0,0 +1,96 @@
[role="pagenumrestart"]
[[ch02_How_Lightning_Works]]
== How the Lightning Network Works
=== Payment channels
* trustless between peers
* operation takes place off chain
* throughput bound by TCP/IP traffic
* have capacity which is split into a balance sheet
* instant payments between peers
==== Multisig address
* short review of bitcoin transactions
* review of segwit multisig addresses
==== Funding Transaction
* opens the payment channel
* encodes the capacity of the channel
* not clear who owns what fraction of the capacity
* visible onchain transaction (even for private channels)
==== Commitment Transaction
* encodes the balance of the payment channel
* kept secretly between channel partners
* everyone has their own set of transactions
* encumbered with a time lock to give time to penalize protocol breach
* smart contract inside which gives possability to penalize protocol breach
==== Announcing the channel
* gossip protocol
* option to have private channels
==== closing the channel
* the good way - mutal close
* the bad way - force close
* the ugly way - protocol breach
=== Invoices
an alternative structure for the subsections of the invoice section (while covering the same topics) could be: (creating, decoding, paying as 3 sub chapters)
* creating invoices
* decoding invoices
* bech32 encoding and human readable part of invoices
==== Payment Hash
* `pre_image` as proof of payment
* random numbers and selecting the pre_image
==== Meta Data
* Description
* routing hints
* fallback address
* expire time
* signature
=== Delivering the payment
* gossip protocol
* network of payment channels
* different scope of the network
** global path finding (entire knowledge of the network necessary)
** multihop routing (onion necessary only a subset of nodes involved)
** locally setting up and setteling htlcs (only peers involved)
==== Finding a path
* trivial case / channel partner as destination with enough funds in the channel
* topology information from the gossip protocol
* fees and pathfinding from destination to source
==== Onion routing
* construct an onion using
** SPHINX
** payment hash
** path
==== Payment Forwarding Algorithm
* receive an incoming HTLC
* forward an HTLC
* BOLT 02 channel update protocol
* sending back errors
=== Comparison with Bitcoin
* select outputs vs select payment channels / finding a path
* change outputs vs no change on lightning
* mining fees vs routing fees
* public transactions on the blockchain vs. secret payments
* waiting for confirmations vs instant settlement (if everything works smoothly)
* arbitrary amounts vs capacity restrictions
* variying fees depending on the traffic vs announced fees (might become dynamic too?)
* blockchain to save all transactions vs blockchain as a court system

@ -4,7 +4,6 @@ License: CC-BY
Added By: @aantonop
////
== Basis of Lightning Technology (BOLT)
The Basis of Lightning Technology (BOLT) documents describe a layer-2 protocol for off-chain bitcoin transfer by mutual cooperation, relying on on-chain transactions for enforcement if necessary.

@ -6,7 +6,6 @@ This quick glossary contains many of the terms used in relation to bitcoin. Thes
address::
A bitcoin address looks like +1DSrfJdB2AnWaFNgSbv3MZC2m74996JafV+. It consists of a string of letters and numbers. It's really an encoded base58check version of a public key 160-bit hash. Just as you ask others to send an email to your email address, you would ask others to send you bitcoin to one of your bitcoin addresses.
Asymmetric Cryptographic System::
Asymmetric cryptography, or public-key cryptography, is a cryptographic system that uses pairs of keys: public keys which may be disseminated widely, and private keys which are known only to the owner.
The generation of such keys depends on cryptographic algorithms based on mathematical problems to produce one-way functions.
@ -32,7 +31,7 @@ bech32::
tbd.
bip::
Bitcoin Improvement Proposals. A set of proposals that members of the bitcoin community have submitted to improve bitcoin. For example, BIP-21 is a proposal to improve the bitcoin uniform resource identifier (URI) scheme.
Bitcoin Improvement Proposals. A set of proposals that members of the bitcoin community have submitted to improve bitcoin. For example, BIP-21 is a proposal to improve the bitcoin uniform resource identifier (URI) scheme.
bitcoin::
The name of the currency unit (the coin), the network, and the software.
@ -75,24 +74,24 @@ c-lightning::
Implementation of the Lightning Network Protocol by the Victoria based Blockstream. It is written in C.
Closing Transaction::
If both channel partners agree to close a channel they will create a spent of the funding transaction that reflects the most recent commitment transaction.
It does not include any Hashed Time Lock Contracts or Revocable Sequence Maturity Contracts.
After exchanging signatures for a closing transaction no further channel updates should be made, as this one allows one side to enforce the closing transaction on the blockchain.
Mutually closing a channel with the help of a closing transaction has the advantage that less blockchain transactions are required to claim all funds, in comparison to unilaterally forcing a channel close by publishing a commitment transaction. Additionally, funds are for both parties immediately spendable from a closing transaction.
If both channel partners agree to close a channel they will create a spent of the funding transaction that reflects the most recent commitment transaction.
It does not include any Hashed Time Lock Contracts or Revocable Sequence Maturity Contracts.
After exchanging signatures for a closing transaction no further channel updates should be made, as this one allows one side to enforce the closing transaction on the blockchain.
Mutually closing a channel with the help of a closing transaction has the advantage that less blockchain transactions are required to claim all funds, in comparison to unilaterally forcing a channel close by publishing a commitment transaction. Additionally, funds are for both parties immediately spendable from a closing transaction.
coinbase::
A special field used as the sole input for coinbase transactions. The coinbase allows claiming the block reward and provides up to 100 bytes for arbitrary data.
A special field used as the sole input for coinbase transactions. The coinbase allows claiming the block reward and provides up to 100 bytes for arbitrary data.
The block reward consists of two things.
First newly generated coins. The amount of allowed coins to be generated is part of the consensus rules and decreases over time based on the current block height.
In addition to the newly generated coins, the miner is also allowed to add all the fees of the transactions from the current block to the coinbase.
Not to be confused with Coinbase transaction.
coinbase transaction::
The first transaction in a block. Always created by a miner, it includes a single coinbase.
Not to be confused with Coinbase.
The first transaction in a block. Always created by a miner, it includes a single coinbase.
Not to be confused with Coinbase.
cold storage::
Refers to keeping a reserve of bitcoin offline. Cold storage is achieved when Bitcoin private keys are created and stored in a secure offline environment. Cold storage is important for anyone with bitcoin holdings. Online computers are vulnerable to hackers and should not be used to store a significant amount of bitcoin.
Refers to keeping a reserve of bitcoin offline. Cold storage is achieved when Bitcoin private keys are created and stored in a secure offline environment. Cold storage is important for anyone with bitcoin holdings. Online computers are vulnerable to hackers and should not be used to store a significant amount of bitcoin.
Commitment Transaction::
Commitment Transactions encode the balance of the payment channel with the help of one output for each channel partner by spending the funding transaction.
@ -100,7 +99,7 @@ Commitment Transaction::
One output also holds a Revocable Sequence Maturity Contract which is made to disincentivize a channel partner to broadcast an old commitment transaction to the Bitcoin network.
This effectively invalidates old commitment transactions.
Broadcasting a commitment transaction forces a unilateral channel close.
Up to 483 Hashed Time Lock Contracts can be stored as additional outputs in the commitment transactions allow the routing of payments.
Up to 483 Hashed Time Lock Contracts can be stored as additional outputs in the commitment transactions allow the routing of payments.
In order to be able to ascribe blame in the case of unilateral channel closes, each channel partner has a slightly different commitment transaction.
// TODO probably don't explain the difference with the RSMC here
@ -111,7 +110,7 @@ Computationally Hard::
A problem is considered to be computationally hard if no algorithm exists or is known that is able to compute the solution to the problem rather quickly.
confirmations::
Once a transaction is included in a block, it has one confirmation. As soon as _another_ block is mined on the same blockchain, the transaction has two confirmations, and so on. Six or more confirmations are considered sufficient proof that a transaction cannot be reversed.
Once a transaction is included in a block, it has one confirmation. As soon as _another_ block is mined on the same blockchain, the transaction has two confirmations, and so on. Six or more confirmations are considered sufficient proof that a transaction cannot be reversed.
Contract::
A contract is a set of Bitcoin transactions which result together in a certain desired behavior.
@ -123,7 +122,7 @@ Diffie Hellman Key Exchange::
This shared secret may be directly used as a key, or to derive another key.
The key, or the derived key, can then be used to encrypt subsequent communications using a symmetric-key cipher.
An example of the derived key would be the ephemeral key used by the SPHINX Mix Format.
via https://en.wikipedia.org/w/index.php?title=Elliptic-curve_Diffie%E2%80%93Hellman&oldid=836070673
Via https://en.wikipedia.org/w/index.php?title=Elliptic-curve_Diffie%E2%80%93Hellman&oldid=836070673
Digital Signature::
A digital signature is a mathematical scheme for verifying the authenticity of digital messages or documents.
@ -155,7 +154,7 @@ Ephemeral Key::
Even if an ephemeral key leaks, only information about a single payment becomes public.
fees::
The sender of a transaction often includes a fee to the network for processing the requested transaction.
The sender of a transaction often includes a fee to the network for processing the requested transaction.
Not to be confused with a routing fee for payments on the lightning network.
Nodes on the Lightning network are allowed to take a routing fee for forwarding payments.
The routing fee is the sum of a fixed _base_fee_ and a _fee_rate_ which depends on the payment amount.
@ -170,11 +169,10 @@ Funding Transaction::
It is part of the rsmc to ensure that either side of the channel can withdraw their funds without the necessity to trust the channel partner.
Globalfeatures::
Globalfeaturess of a Lightning Network node are the features of interest for all other nodes.
Globalfeatures of a Lightning Network node are the features of interest for all other nodes.
Most commonly they are related to supported routing formats.
They are announced in the `_init_` message of the peer protocol as well as the `_channel_announcement_` and `_node_announcement_` messages of the gossip protocol.
Gossip Protocol::
Lightning Network nodes send and receive information about the topology of the Lightning Network through gossip messages which are exchanged with their peers.
The gossip protocol is mainly defined in BOLT 7 and defines the format of the _node_announcement_, _channel_announcement_ and _channel_update messages_.
@ -199,7 +197,6 @@ Hash Function::
It is infeasible to find two different messages with the same hash value.
https://en.wikipedia.org/w/index.php?title=Cryptographic_hash_function&oldid=868055371
hashlocks::
A hashlock is a type of encumbrance that restricts the spending of an output until a specified piece of data is publicly revealed. Hashlocks have the useful property that once any hashlock is opened publicly, any other hashlock secured using the same key can also be opened. This makes it possible to create multiple outputs that are all encumbered by the same hashlock and which all become spendable at the same time.
@ -214,7 +211,7 @@ Invoice::
Lightning Network::
The Lightning Network is a protocol on top of bitcoin (or other cryptocurrencies).
It creates a network of payment channels which enable the trustless forwarding of payments through the network with the help of HTLCs and Onion Routing.
It creates a network of payment channels which enables the trustless forwarding of payments through the network with the help of HTLCs and Onion Routing.
Other components of the lightning network are the gossip protocol, the transport layer and payment requests.
Lightning Network Node::
@ -225,7 +222,7 @@ lnd::
It is written in Go.
Localfeatures::
Localfeaturess of a Lightning Network node are the features of direct interest of the peer.
Localfeatures of a Lightning Network node are the features of direct interest of the peer.
They are announced in the `_init_` message of the peer protocol as well as the `_channel_announcement_` and `_node_announcement_` messages of the gossip protocol.
Locktime::
@ -233,7 +230,7 @@ Locktime::
Millisatoshi::
The smallest unit of account on the lightning network.
The the value cannot be enforced on chain.
The value cannot be enforced on chain.
multisignature::
Multisignature (multisig) refers to requiring more than one key to authorize a bitcoin transaction.
@ -241,12 +238,12 @@ multisignature::
In the standard case of a 2 party payment channel a 2-2 multisignature address is used.
Noise_XK::
The template of the Noise protocol framework to establish and authenticated and encrypted communication channel between two peers of the lightning network.
The template of the Noise protocol framework to establish an authenticated and encrypted communication channel between two peers of the lightning network.
X means that no public key needs to be known from the initiator of the connection.
K means that the public key of the receiver needs to be known.
More particular (from: http://www.noiseprotocol.org/noise.html) the protocol enables.
Encryption to a known recipient, strong forward secrecy. This payload is encrypted based on an ephemeral-ephemeral DH as well as an ephemeral-static DH with the recipient's static key pair. Assuming the ephemeral private keys are secure, and the recipient is not being actively impersonated by an attacker that has stolen its static private key, this payload cannot be decrypted. Sender authentication resistant to key-compromise impersonation (KCI). The sender authentication is based on an ephemeral-static DH ("es" or "se") between the sender's static key pair and the recipient's ephemeral key pair. Assuming the corresponding private keys are secure, this authentication cannot be forged.
// the noice protocol documentation is according to their IPR section public domain. The author is Trevor Perrin (noise@trevp.net)
// the noise protocol documentation is according to their IPR section public domain. The author is Trevor Perrin (noise@trevp.net)
Onion Routing::
Onion routing is a technique for anonymous communication over a computer network.
@ -292,7 +289,7 @@ Payment Channel::
There are currently three methods known to construct a fully duplex bidirectional payment channel.
Christian Decker proposed a method in his PhD thesis based on invalidation trees.
In the Lightning Network whitepaper, Joseph Poon and Tadge Dryja describe the Revocable Sequence Maturity Contract based method that is currently being implemented on the Lightning Network.
Recently Christian Decker et al. came up with the Eltoo mechanism which would require a Bitcoin softfork.
Recently Christian Decker et al. came up with the Eltoo mechanism which would require a Bitcoin softfork.
peer::
Two parties which form a payment channel are called peers.
@ -361,7 +358,7 @@ Second stage HTLC::
tbd.
secret key (aka private key)::
The secret number that unlocks bitcoin sent to the corresponding address. pass:[<span class="keep-together">A secret</span>] key looks like the following:
The secret number that unlocks bitcoin sent to the corresponding address. pass:[<span class="keep-together">A secret</span>] key looks like the following:
+
----
5J76sF8L5jTtzE96r66Sf8cka9y44wdpJjMwCxR3tzLh3ibVPxh
@ -406,7 +403,7 @@ timelocks::
Transaction::
Transactions are a binary format used by the Bitcoin protocol to transfer bitcoins from one address to another.
Several transactions are built into a block which has to be confirmed by the Bitcoin network through the process of mining.
Transactions can only be included in a block if they contain a valid signature (more precisely a valid input script) matching the output script defined by the previous owner.
Transactions can only be included in a block if they contain a valid signature (more precisely a valid input script) matching the output script defined by the previous owner.
The first transaction in each block is called the coinbase and generates new bitcoins.
Transactions can also contain contracts and should not be confused with payments.
@ -416,7 +413,6 @@ Transaction Malleability::
Transport Layer::
tbd.
unspent transaction output (UTXO)::
UTXO is an unspent transaction output that can be spent as an input to a new transaction.
@ -426,5 +422,4 @@ upstream payment::
wallet::
Software that holds all your bitcoin addresses and secret keys. Use it to send, receive, and store your bitcoin.
Some contributed definitions have been sourced under a CC-BY license from the https://en.bitcoin.it/wiki/Main_Page[bitcoin Wiki], https://en.wikipedia.org[Wikipedia], https://github.com/bitcoinbook/bitconbook[Mastering Bitcoin] or from other open source documentation sources.

@ -24,7 +24,6 @@ _Italic_:: Indicates new terms, URLs, email addresses, filenames, and file exten
_++Constant width italic++_:: Shows text that should be replaced with user-supplied values or values determined by context.
[TIP]
====
This icon signifies a tip or suggestion.
@ -68,7 +67,7 @@ If you feel your use of code examples falls outside fair use or the permission g
All references to companies and products are intended for educational, demonstration, and reference purposes. The authors do not endorse any of the companies or products mentioned. We have not tested the operation or security of any of the products, projects, or code segments shown in this book. Use them at your own risk!
[[addresses_and_transactions_sec]]
=== Addresses and Transactions in this Book
=== Addresses and Transactions in this Book
((("blockchain","warnings and cautions")))((("keys and addresses", seealso="cryptography; private keys; public keys")))((("QR codes")))((("transactions","warnings and cautions")))((("warnings and cautions","when using test and example material appearing in book")))The Bitcoin addresses, transactions, keys, QR codes, and blockchain data used in this book are, for the most part, real. That means you can browse the blockchain, look at the transactions offered as examples, retrieve them with your own scripts or programs, etc.
@ -121,7 +120,6 @@ Follow us on Twitter: link:$$https://twitter.com/oreillymedia$$[]
Watch us on YouTube: link:$$https://www.youtube.com/oreillymedia$$[]
==== Contacting Andreas
You can contact Andreas M. Antonopoulos on his personal site:
@ -142,7 +140,6 @@ link:$$https://linkedin.com/company/aantonop$$[]
Andreas would also like to thank all of the patrons who support his work through monthly donations. You can support Andreas on Patreon at
link:$$https://patreon.com/aantonop$$[].
==== Contacting Rene
You can contact Rene Pickhardt on his personal site:
@ -162,7 +159,6 @@ link:$$https://patreon.com/renepickhardt$$[].
Or you can support his work directly with bitcoin (also via the Lightning Network) at link:$$https://tallyco.in/s/lnbook$$[] for which Rene is equally thankful as for his patreons.
[[acknowledgments_sec]]
=== Acknowledgments by Andreas
@ -178,7 +174,6 @@ I am also grateful to the Bitcoin and Lightning Network community who welcomed m
In particular I am grateful to all the open source Bitcoin and Lightning Network protocol developers and people who fund them to make that technology possible.
Last but not least I am thankful to my loved ones.
[[github_contrib]]
=== Contributions

@ -52,7 +52,7 @@ Review of some mechanics and terms from Mastering Bitcoin. This would probably b
=== Motivation: Why the Lightning Network
* clear definition what does scaling of a computer system mean? (I realize that discussions often fail because that term is not well defined among participants. A similar definition might be necessary for Decentralized and trustless)
* clear definition what does scaling of a computer system mean? (I realize that discussions often fail because that term is not well defined among participants. A similar definition might be necessary for Decentralized and trustless)
* Scale Payments (amount of possible payments independent of block size / data base size)
* increase privacy (not all payments stored on chain)
* decrease settlement time (get rid of confirmations)
@ -86,9 +86,9 @@ This group of topics would be end user oriented and is rather non technical
While also important for end users to be aware of some of the topics here it is primarily meant for professionals and developers.
* backup & restore a Lightning Network node
* configure a Lightning network Nodes
* configure a Lightning network Node
** max concurrent htlc in flight
** min channel channel size
** min channel size
** max channel size
** cltv_expiry delta
** routing fees
@ -103,7 +103,6 @@ While also important for end users to be aware of some of the topics here it is
* uptime
* watchtowers
=== BOLT 1.0
A summary of how the Lightning Network protocol works.
@ -137,7 +136,6 @@ A summary of how the Lightning Network protocol works.
* Transaction Malleability
* Transport Layer
=== BOLT 1.1 / 2.0
Future trends and developments on the Lightning Network.
@ -173,7 +171,7 @@ Everything about the Lightning Network that is not covered by the BOLTs but impo
** JIT https://lists.linuxfoundation.org/pipermail/lightning-dev/2019-March/001891.html
** Trampoline routing https://lists.linuxfoundation.org/pipermail/lightning-dev/2019-April/001950.html
** permuteroute https://github.com/ElementsProject/lightning/pull/2890
** Real time strategy games https://lists.linuxfoundation.org/pipermail/lightning-dev/2019-August/002095.html
** Real time strategy games https://lists.linuxfoundation.org/pipermail/lightning-dev/2019-August/002095.html
=== Building on top of the Lightning Network
Creating Lightning Network Applications
@ -186,21 +184,34 @@ Creating Lightning Network Applications
** streaming example
** more ideas: https://bitcoingames2019.devpost.com/submissions
* btc pay server
* Turbo Channels https://medium.com/@akumaigorodski/instant-channels-enable-safe-lightning-payments-with-unconfirmed-funding-8d640defa183
=== comparisons and examples
The following is a loose list of potential infoboxes, tables and dropins which will most likely make it to some part of the book.
They have particular illustrative purpose and are therefore collected seperately to keep better track of them.
They have particular illustrative purpose and are therefore collected separately to keep better track of them.
==== comparisons
* payment process on Bitcoin vs payment process on the lightning network
* transaction vs payment
* capacity vs balance
* routing fees vs mining fees
* private vs public channel (difficulty to have truely private channels that don't reveal over time on the blockchain?)
* private vs public channel (difficulty to have truly private channels that don't reveal over time on the blockchain?)
* source based routing vs best effort routing (onion routing vs IP forwarding)
* eltoo vs RSMC (?)
* private key vs fully signed transaction (it can be seen as almost the same in the sense of ownership)
* locked bitcoin vs freely movable bitcoin (onchain vs. offchain bitcoin)
* routing vs path finding
==== examples
tba
tba
==== properties
* the seven ingredients for a payment channel c.f: https://youtu.be/AcP3czefanM
** 2-2 musig address
** funding transaction to open the channel (without possibility to malleate the transaction)
** commitment transaction to encode the balance of the channel
** a time lock to remove trust
** a communication protocol for partners exchange data outside of the bitcoin network
** asymmetrical information (unless we switch to eltoo but even there not all keys are shared but channel state is symmetric)
** game theoretic and economical incentives to follow the protocol

Loading…
Cancel
Save