mirror of
https://github.com/bitcoinbook/bitcoinbook
synced 2024-11-26 01:50:42 +00:00
Edited ch02_overview.adoc with Atlas code editor
This commit is contained in:
parent
7bf2d2141e
commit
9d721b3173
@ -47,7 +47,7 @@ example, we will provide a URL so you can look it up yourself and study
|
||||
it in detail.
|
||||
|
||||
[[block-explorer-privacy]]
|
||||
.Block explorer privacy warning
|
||||
.Block Explorer Privacy Warning
|
||||
[WARNING]
|
||||
====
|
||||
Searching information on a block explorer may disclose to its operator
|
||||
@ -80,17 +80,9 @@ usual options. The checkout cart displays the price in US dollars and
|
||||
also in bitcoin (BTC), at Bitcoin's prevailing exchange rate.
|
||||
|
||||
Bob's
|
||||
e-commerce system will automatically create a QR code containing an
|
||||
ecommerce system will automatically create a QR code containing an
|
||||
_invoice_ (<<invoice-QR>>).
|
||||
|
||||
Unlike a QR code that simply contains a destination Bitcoin address, this
|
||||
invoice is a QR-encoded URI that contains a destination address,
|
||||
a payment amount, and a description.
|
||||
This allows a Bitcoin wallet application to prefill the
|
||||
information used to send the payment while showing a human-readable
|
||||
description to the user. You can scan the QR code with a bitcoin wallet
|
||||
application to see what Alice would see.
|
||||
|
||||
////
|
||||
TODO: Replace QR code with test-BTC address
|
||||
////
|
||||
@ -99,6 +91,15 @@ TODO: Replace QR code with test-BTC address
|
||||
.Invoice QR code
|
||||
image::images/mbc3_0202.png["payment-request"]
|
||||
|
||||
Unlike a QR code that simply contains a destination Bitcoin address, this
|
||||
invoice is a QR-encoded URI that contains a destination address,
|
||||
a payment amount, and a description.
|
||||
This allows a Bitcoin wallet application to prefill the
|
||||
information used to send the payment while showing a human-readable
|
||||
description to the user. You can scan the QR code with a bitcoin wallet
|
||||
application to see what Alice would see:
|
||||
|
||||
|
||||
[TIP]
|
||||
====
|
||||
Try to scan this with your wallet to see
|
||||
@ -139,7 +140,7 @@ millibitcoins and satoshis.
|
||||
====
|
||||
|
||||
You can examine Alice's transaction to Bob's Store on the blockchain
|
||||
using a block explorer site (<<view_alice_transaction>>):
|
||||
using a block explorer site (<<view_alice_transaction>>).
|
||||
|
||||
[[view_alice_transaction]]
|
||||
.View Alice's transaction on https://blockstream.info/tx/674616f1fbc6cc748213648754724eebff0fc04506f2c81efb1349d1ebc8a2ef[Blockstream Explorer]
|
||||
@ -251,9 +252,8 @@ In addition to one or more outputs that pay the receiver of
|
||||
bitcoins, many transactions will also include an output that pays the
|
||||
spender of the bitcoins, called a _change_ output.
|
||||
This is because transaction inputs,
|
||||
like currency notes, cannot be partly spent. If you purchase a $5 US dollar
|
||||
item in a store but use a $20 dollar bill to pay for the item, you
|
||||
expect to receive $15 dollars in change. The same concept applies to
|
||||
like currency notes, cannot be partly spent. If you purchase a $5 US item in a store but use a $20 bill to pay for the item, you
|
||||
expect to receive $15 in change. The same concept applies to
|
||||
Bitcoin transaction inputs. If you purchased an item that costs 5
|
||||
bitcoins but only had an input worth 20 bitcoins to use, you would send one
|
||||
output of 5 bitcoins to the store owner and one output of 15 bitcoins back
|
||||
@ -266,7 +266,7 @@ payment output.
|
||||
Importantly, the change address does not have to be the
|
||||
same address as that of the input and for privacy reasons is often a new
|
||||
address from the owner's wallet. In ideal circumstances, the two
|
||||
different uses of outputs both use never-before-been addresses and
|
||||
different uses of outputs both use never-before-seen addresses and
|
||||
otherwise look identical, preventing any third party from determining
|
||||
which outputs are change and which are payments. However, for
|
||||
illustration purposes, we've added shading to the change outputs in
|
||||
@ -274,16 +274,16 @@ illustration purposes, we've added shading to the change outputs in
|
||||
|
||||
Not every transaction has a change output. Those that don't are called
|
||||
_changeless transactions_ and they can have only a single output.
|
||||
Changeless transaction are only a practical option if the amount being
|
||||
Changeless transactions are only a practical option if the amount being
|
||||
spent is roughly the same as the amount available in the transaction
|
||||
inputs minus the anticipated transaction fee. In <<transaction-chain>>
|
||||
we see Bob creating Tx3 as a changeless transaction that spends the
|
||||
output he received in Tx2.
|
||||
|
||||
==== Coin selection
|
||||
==== Coin Selection
|
||||
|
||||
Different wallets use different strategies when choosing which
|
||||
inputs to use to a payment, called _coin selection_.
|
||||
inputs to se in a payment, called _coin selection_.
|
||||
|
||||
They might aggregate many small
|
||||
inputs, or use one that is equal to or larger than the desired payment.
|
||||
@ -306,7 +306,7 @@ transaction has one input and two outputs and is shown in
|
||||
.Most common transaction
|
||||
image::images/mbc3_0205.png["Common Transaction"]
|
||||
|
||||
Another common form of transaction is a _consolidation transaction_ that spends several inputs
|
||||
Another common form of transaction is a _consolidation transaction_, which spends several inputs
|
||||
into a single output (<<transaction-consolidating>>). This represents
|
||||
the real-world equivalent of exchanging a pile of coins and currency
|
||||
notes for a single larger note. Transactions like these are sometimes
|
||||
@ -317,7 +317,7 @@ generated by wallets and businesses to clean up lots of smaller amounts.
|
||||
image::images/mbc3_0206.png["Aggregating Transaction"]
|
||||
|
||||
Finally, another transaction form that is seen often on the
|
||||
blockchain is _payment batching_ that pays to multiple outputs
|
||||
blockchain is _payment batching_, which pays to multiple outputs
|
||||
representing multiple recipients (<<transaction-distributing>>).
|
||||
This type of transaction is sometimes used by commercial entities to
|
||||
distribute funds, such as when processing payroll payments to multiple
|
||||
@ -424,7 +424,7 @@ the software logic and the data necessary for them to fully verify the
|
||||
correctness of a new transaction. The connections between peers are
|
||||
often visualized as edges (lines) in a graph, with the peers themselves
|
||||
being the nodes (dots). For that reason, Bitcoin peers are commonly
|
||||
called "full verification nodes", or _full nodes_ for short.
|
||||
called "full verification nodes," or _full nodes_ for short.
|
||||
|
||||
Alice's wallet application can send the new
|
||||
transaction to any Bitcoin node over any type of
|
||||
@ -433,7 +433,7 @@ to another program (such as a block explorer) that will relay it to a
|
||||
node. Her Bitcoin wallet does not have
|
||||
to be connected to Bob's Bitcoin wallet directly and she does not have
|
||||
to use the internet connection offered by Bob, though both those
|
||||
options are possible, too. Any Bitcoin node that receives a
|
||||
options are possible too. Any Bitcoin node that receives a
|
||||
valid transaction it has not seen before will forward it to
|
||||
all other nodes to which it is connected, a propagation technique known
|
||||
as _gossiping_. Thus, the transaction rapidly propagates out across the
|
||||
@ -483,19 +483,19 @@ Mining achieves a fine balance between cost and reward. Mining uses
|
||||
electricity to solve a computational problem. A successful miner will
|
||||
collect a _reward_ in the form of new bitcoins and transaction fees.
|
||||
However, the reward will only be collected if the miner has only
|
||||
included valid transactions, with the Bitcoin Protocol's rules for
|
||||
included valid transactions, with the Bitcoin protocol's rules for
|
||||
_consensus_ dermining what is valid. This delicate balance provides
|
||||
security for Bitcoin without a central authority.
|
||||
|
||||
Mining is designed to be a decentralized lottery. Each miner can create
|
||||
their own lottery ticket by creating a _candidate block_ that includes
|
||||
the new transactions they want to mine plus some additional data fields.
|
||||
The miner inputs their candidate into a specially-designed algorithm that
|
||||
The miner inputs their candidate into a specially designed algorithm that
|
||||
scrambles (or "hashes") the data, producing output that looks nothing
|
||||
like the input data. This _hash_ function will always produce the same
|
||||
output for the same input--but nobody can predict what the output will
|
||||
look like for a new input, even if it is only slighly different from a
|
||||
previous input. If the output of hash function matches a template
|
||||
previous input. If the output of the hash function matches a template
|
||||
determined by the Bitcoin protocol, the miner wins the lottery and
|
||||
Bitcoin users will accept the block with its transactions as a
|
||||
valid block. If the output doesn't match the template, the miner makes
|
||||
@ -510,7 +510,7 @@ valid block something that requires an incredible amount of work to
|
||||
create but only a trivial amount of work to verify. The simple
|
||||
verification process is able to probabalistically prove the work was
|
||||
done, so the data necessary to generate that proof--in this case, the
|
||||
block--is called Proof-of-Work (PoW).
|
||||
block--is called proof of ork (PoW).
|
||||
|
||||
Transactions are added to the new block, prioritized by the highest fee rate
|
||||
transactions first and a few other criteria. Each miner starts the
|
||||
@ -518,13 +518,13 @@ process of mining a new candidate block of transactions as soon as they receive
|
||||
previous block from the network, knowing that some other miner won that
|
||||
iteration of the lottery. They immediately create a new candidate block
|
||||
with a commitment to the previous block, fill it with transactions, and start
|
||||
calculating the Proof-of-Work for the candidate block. Each miner includes a
|
||||
calculating the PoW for the candidate block. Each miner includes a
|
||||
special transaction in their candidate blocks, one that pays their own Bitcoin address
|
||||
the block reward plus the sum of
|
||||
transaction fees from all the transactions included in the candidate block. If they
|
||||
finds a solution that makes the candidate into a valid block, they receives this reward
|
||||
after his successful block is added to the global blockchain and the
|
||||
reward transaction he included becomes spendable. Miners who participates in a mining pool have set up their
|
||||
find a solution that makes the candidate into a valid block, they receive this reward
|
||||
after their successful block is added to the global blockchain and the
|
||||
reward transaction they included becomes spendable. Miners who participate in a mining pool have set up their
|
||||
software to create candidate blocks that assign the reward to a pool address.
|
||||
From there, a share of the reward is distributed to members of the pool
|
||||
miners in proportion to the amount of work they contributed.
|
||||
@ -548,7 +548,7 @@ transaction that doesn't pay Bob) would require performing the same
|
||||
amount of work as it will take all Bitcoin miners to create an entirely
|
||||
new block. When there are multiple alternative blocks to choose from,
|
||||
Bitcoin full nodes choose the chain of valid blocks with the most total
|
||||
Proof-of-Work, called the _best blockchain_. For the entire network to
|
||||
PoW, called the _best blockchain_. For the entire network to
|
||||
accept an alternative block, an additional new block would need to be
|
||||
mined on top of the alternative.
|
||||
|
||||
@ -557,7 +557,7 @@ alternative to the transaction where she pays Bob, perhaps with
|
||||
Alice paying miners a share of the money she previously paid Bob. This
|
||||
dishonest behavior will require they expend the effort required to
|
||||
create two new blocks. Instead, miners who behave honestly can create a
|
||||
single new block and and receive all of the fees from the transactions
|
||||
single new block and receive all of the fees from the transactions
|
||||
they include in it, plus the block subsidy. Normally, the high cost of
|
||||
dishonestly creating two blocks for a small additional payment is much
|
||||
less profitable than honestly creating a new block, making it unlikely
|
||||
@ -575,7 +575,7 @@ Approximately 19 minutes
|
||||
after the block containing Alice's transaction is broadcast, a new block
|
||||
is mined by another miner. Because this
|
||||
new block is built on top of the block that contained Alice's
|
||||
transaction (giving Alice's transaction two confirmations) Alice's
|
||||
transaction (giving Alice's transaction two confirmations), Alice's
|
||||
transaction can now only be changed if two alternative blocks are
|
||||
mined--plus a new block built on top of them--for a total of three
|
||||
blocks that would need to be mined for Alice to take back the money she
|
||||
@ -584,8 +584,7 @@ transaction counts as an additional confirmation. As the blocks pile on
|
||||
top of each other, it becomes harder to reverse the transaction, thereby
|
||||
giving Bob more and more confidence that Alice's payment is secure.
|
||||
|
||||
In <<block-alice1>>, we can
|
||||
the block which contains Alice's transaction. Below it are
|
||||
In <<block-alice1>>, we can see the block that contains Alice's transaction. Below it are
|
||||
hundreds of thousands of blocks, linked to each other in a chain of
|
||||
blocks (blockchain) all the way back to block #0, known as the _genesis
|
||||
block_. Over time, as the "height" of new blocks increases, so does the
|
||||
@ -633,4 +632,4 @@ from owner to owner. We also tracked Alice's transaction, from the
|
||||
moment it was created in her wallet, through the Bitcoin network and to
|
||||
the miners who recorded it on the blockchain. In the rest of this book,
|
||||
we will examine the specific technologies behind wallets, addresses,
|
||||
signatures, transactions, the network, and finally mining.
|
||||
signatures, transactions, the network, and finally, mining.
|
||||
|
Loading…
Reference in New Issue
Block a user