1
0
mirror of https://github.com/bitcoinbook/bitcoinbook synced 2024-11-26 01:50:42 +00:00

Merge branch 'develop'

This commit is contained in:
Andreas M. Antonopoulos 2016-10-18 18:23:38 +02:00
commit 6e22cf4a0a
5 changed files with 54 additions and 25 deletions

View File

@ -17,7 +17,7 @@ A common misconception about bitcoin is that bitcoin wallets contain bitcoin. In
[TIP] [TIP]
==== ====
Bitcoin wallets contain keys, not coins. Wallets are really keychains containing pairs of private/public keys (see <<private_public_keys>>). Bitcoin wallets contain keys, not coins. Each user has a wallet containing keys. Wallets are really keychains containing pairs of private/public keys (see <<private_public_keys>>). Users sign transactions with the keys, thereby proving they own the transaction outputs (their coins). The coins are stored on the blockchain in the form of transaction-outputs (often noted as vout or txout).((("txout notation")))((("vout notation")))
==== ====
There are two primary types of wallets, distinguished by whether the keys they contain are related to each other or not. There are two primary types of wallets, distinguished by whether the keys they contain are related to each other or not.

View File

@ -24,7 +24,7 @@ In this chapter, we will first examine mining as a monetary supply mechanism and
((("currency creation", id="ix_ch08-asciidoc2", range="startofrange")))((("mining","currency creation", id="ix_ch08-asciidoc3", range="startofrange")))Bitcoins are "minted" during the creation of each block at a fixed and diminishing rate. Each block, generated on average every 10 minutes, contains entirely new bitcoins, created from nothing. Every 210,000 blocks, or approximately every four years, the currency issuance rate is decreased by 50%. For the first four years of operation of the network, each block contained 50 new bitcoins. ((("currency creation", id="ix_ch08-asciidoc2", range="startofrange")))((("mining","currency creation", id="ix_ch08-asciidoc3", range="startofrange")))Bitcoins are "minted" during the creation of each block at a fixed and diminishing rate. Each block, generated on average every 10 minutes, contains entirely new bitcoins, created from nothing. Every 210,000 blocks, or approximately every four years, the currency issuance rate is decreased by 50%. For the first four years of operation of the network, each block contained 50 new bitcoins.
In November 2012, the new bitcoin issuance rate was decreased to 25 bitcoins per block and it will decrease again to 12.5 bitcoins at block 420,000, which will be mined sometime in 2016. The rate of new coins decreases like this exponentially over 64 "halvings" until block 13,230,000 (mined approximately in year 2137), when it reaches the minimum currency unit of 1 satoshi. Finally, after 13.44 million blocks, in approximately 2140, almost 2,099,999,997,690,000 satoshis, or almost 21 million bitcoins, will be issued. Thereafter, blocks will contain no new bitcoins, and miners will be rewarded solely through the transaction fees. <<bitcoin_money_supply>> shows the total bitcoin in circulation over time, as the issuance of currency decreases. In November 2012, the new bitcoin issuance rate was decreased to 25 bitcoins per block and it will decrease again to 12.5 bitcoins at block 420,000, which will be mined sometime in 2016. The rate of new coins decreases like this exponentially over 32 "halvings" until block 6,720,000 (mined approximately in year 2137), when it reaches the minimum currency unit of 1 satoshi. Finally, after 6.93 million blocks, in approximately 2140, almost 2,099,999,997,690,000 satoshis, or almost 21 million bitcoins, will be issued. Thereafter, blocks will contain no new bitcoins, and miners will be rewarded solely through the transaction fees. <<bitcoin_money_supply>> shows the total bitcoin in circulation over time, as the issuance of currency decreases.
[[bitcoin_money_supply]] [[bitcoin_money_supply]]
.Supply of bitcoin currency over time based on a geometrically decreasing issuance rate .Supply of bitcoin currency over time based on a geometrically decreasing issuance rate
@ -347,7 +347,7 @@ In block 277,316 we see that the coinbase (see <<generation_tx_example>>), which
The first byte, +03+, instructs the script execution engine to push the next three bytes onto the script stack (see <<tx_script_ops_table_pushdata>>). The next three bytes, +0x443b04+, are the block height encoded in little-endian format (backward, least significant byte first). Reverse the order of the bytes and the result is +0x043b44+, which is 277,316 in decimal. The first byte, +03+, instructs the script execution engine to push the next three bytes onto the script stack (see <<tx_script_ops_table_pushdata>>). The next three bytes, +0x443b04+, are the block height encoded in little-endian format (backward, least significant byte first). Reverse the order of the bytes and the result is +0x043b44+, which is 277,316 in decimal.
The next few hexadecimal digits (+03858402062+) are used to encode an extra _nonce_ (see <<extra_nonce>>), or random value, used to find a suitable proof of work solution. The next few hexadecimal digits (+0385840206+) are used to encode an extra _nonce_ (see <<extra_nonce>>), or random value, used to find a suitable proof of work solution.
The final part of the coinbase data (+2f503253482f+) is the ASCII-encoded string +/P2SH/+, which indicates that the mining node that mined this block supports the((("pay-to-script-hash (P2SH)","coinbase data and"))) pay-to-script-hash (P2SH) improvement defined in BIP-16. The introduction of the P2SH capability required a "vote" by miners to endorse either BIP-16 or BIP-17. Those endorsing the BIP-16 implementation were to include +/P2SH/+ in their coinbase data. Those endorsing the BIP-17 implementation of P2SH were to include the string +p2sh/CHV+ in their coinbase data. The BIP-16 was elected as the winner, and many miners continued including the string +/P2SH/+ in their coinbase to indicate support for this feature. The final part of the coinbase data (+2f503253482f+) is the ASCII-encoded string +/P2SH/+, which indicates that the mining node that mined this block supports the((("pay-to-script-hash (P2SH)","coinbase data and"))) pay-to-script-hash (P2SH) improvement defined in BIP-16. The introduction of the P2SH capability required a "vote" by miners to endorse either BIP-16 or BIP-17. Those endorsing the BIP-16 implementation were to include +/P2SH/+ in their coinbase data. Those endorsing the BIP-17 implementation of P2SH were to include the string +p2sh/CHV+ in their coinbase data. The BIP-16 was elected as the winner, and many miners continued including the string +/P2SH/+ in their coinbase to indicate support for this feature.

View File

@ -7,7 +7,7 @@
int main() int main()
{ {
// Create genesis block. // Create genesis block.
bc::block_type block = bc::genesis_block(); const bc::block_type block = bc::genesis_block();
// Genesis block contains a single coinbase transaction. // Genesis block contains a single coinbase transaction.
assert(block.transactions.size() == 1); assert(block.transactions.size() == 1);
// Get first transaction in block (coinbase). // Get first transaction in block (coinbase).
@ -16,7 +16,7 @@ int main()
assert(coinbase_tx.inputs.size() == 1); assert(coinbase_tx.inputs.size() == 1);
const bc::transaction_input_type& coinbase_input = coinbase_tx.inputs[0]; const bc::transaction_input_type& coinbase_input = coinbase_tx.inputs[0];
// Convert the input script to its raw format. // Convert the input script to its raw format.
const bc::data_chunk& raw_message = save_script(coinbase_input.script); const bc::data_chunk raw_message = save_script(coinbase_input.script);
// Convert this to an std::string. // Convert this to an std::string.
std::string message; std::string message;
message.resize(raw_message.size()); message.resize(raw_message.size());
@ -25,4 +25,3 @@ int main()
std::cout << message << std::endl; std::cout << message << std::endl;
return 0; return 0;
} }

View File

@ -49,7 +49,7 @@ Proof-Of-Work::
A piece of data that requires significant computation to find. In bitcoin, miners must find a numeric solution to the SHA256 algorithm that meets a network-wide target, the difficulty target. ((("proof-of-work"))) A piece of data that requires significant computation to find. In bitcoin, miners must find a numeric solution to the SHA256 algorithm that meets a network-wide target, the difficulty target. ((("proof-of-work")))
reward:: reward::
An amount included in each new block as a reward by the network to the miner who found the Proof-Of-Work solution. It is currently 25BTC per block.((("reward"))) An amount included in each new block as a reward by the network to the miner who found the Proof-Of-Work solution. It is currently 12.5BTC per block.((("reward")))
secret key (aka private key):: secret key (aka private key)::
The secret number that unlocks bitcoins sent to the corresponding address. A secret key looks like +5J76sF8L5jTtzE96r66Sf8cka9y44wdpJjMwCxR3tzLh3ibVPxh+.((("secret key")))((("private key", see="secret key"))) The secret number that unlocks bitcoins sent to the corresponding address. A secret key looks like +5J76sF8L5jTtzE96r66Sf8cka9y44wdpJjMwCxR3tzLh3ibVPxh+.((("secret key")))((("private key", see="secret key")))

View File

@ -144,25 +144,55 @@ Thank you all for supporting me throughout this journey.
Many contributors offered comments, corrections, and additions to the early-release draft on GitHub. Thank you all for your contributions to this book. Following is a list of notable GitHub contributors, including their GitHub ID in parentheses: Many contributors offered comments, corrections, and additions to the early-release draft on GitHub. Thank you all for your contributions to this book. Following is a list of notable GitHub contributors, including their GitHub ID in parentheses:
* Minh T. Nguyen, GitHub contribution editor (enderminh)
* Ed Eykholt (edeykholt)
* Michalis Kargakis (kargakis)
* Erik Wahlström (erikwam)
* Richard Kiss (richardkiss)
* Eric Winchell (winchell)
* Sergej Kotliar (ziggamon)
* Nagaraj Hubli (nagarajhubli)
* ethers
* Alex Waters (alexwaters) * Alex Waters (alexwaters)
* Mihail Russu (MihailRussu) * Andrew Donald Kennedy (grkvlt)
* Bryan Gmyrek (physicsdude)
* Casey Flynn (cflynn07)
* Chapman Shoop (belovachap)
* Cody Scott (Siecje)
* coinradar
* Cragin Godley (cgodley)
* dallyshalla
* Diego Viola (diegoviola)
* Dirk Jäckel (biafra23)
* Dmitry Marakasov (AMDmi3)
* drstrangeM
* Ed Eykholt (edeykholt)
* Ed Leafe (EdLeafe)
* Eric Voskuil (evoskuil)
* Eric Winchell (winchell)
* Erik Wahlström (erikwam)
* effectsToCause (vericoin)
* Esteban Ordano (eordano)
* ethers
* fabienhinault
* Gaurav Rana (bitcoinsSG)
* genjix
* Holger Schinzel (schinzelh)
* Ish Ot Jr. (ishotjr) * Ish Ot Jr. (ishotjr)
* James Addison (jayaddison) * James Addison (jayaddison)
* Nekomata (nekomata-3) * Jameson Lopp (jlopp)
* Simon de la Rouviere (simondlr)
* Chapman Shoop (belovachap)
* Holger Schinzel (schinzelh)
* effectsToCause (vericoin)
* Stephan Oeste (Emzy)
* Joe Bauers (joebauers)
* Jason Bisterfeldt (jbisterfeldt) * Jason Bisterfeldt (jbisterfeldt)
* Ed Leafe (EdLeafe) * JerJohn15
* Joe Bauers (joebauers)
* joflynn
* Jorgeminator
* Kai Bakker (kaibakker)
* Mai-Hsuan Chia (mhchia)
* Marzig (marzig76)
* Maximilian Reichel (phramz)
* Michalis Kargakis (kargakis)
* Mihail Russu (MihailRussu)
* Minh T. Nguyen, GitHub contribution editor (enderminh)
* Nagaraj Hubli (nagarajhubli)
* Nekomata (nekomata-3)
* Richard Kiss (richardkiss)
* Ruben Alexander (hizzvizz)
* Sam Ritchie (sritchie)
* Sergej Kotliar (ziggamon)
* Simon de la Rouviere (simondlr)
* Stephan Oeste (Emzy)
* takaya-imai
* Thiago Arrais (thiagoarrais)
* Will Binns (wbinns)
* Wojciech Langiewicz (wlk)