mirror of
https://github.com/bitcoinbook/bitcoinbook
synced 2024-12-27 00:48:09 +00:00
changes per AM's notes, completed
This commit is contained in:
parent
9c2e13d7f7
commit
066b55775c
@ -15,11 +15,11 @@ The bitcoin protocol includes built-in algorithms that regulate the mining funct
|
|||||||
|
|
||||||
Behind the scenes, bitcoin is also the name of protocol, a network and a distributed computing innovation. The bitcoin currency is really only the first application of this invention. As a developer, I see bitcoin as akin to the Internet of money, a network for propagating value and securing the ownership of digital assets via distributed computation. There's a lot more to bitcoin than first meets the eye.
|
Behind the scenes, bitcoin is also the name of protocol, a network and a distributed computing innovation. The bitcoin currency is really only the first application of this invention. As a developer, I see bitcoin as akin to the Internet of money, a network for propagating value and securing the ownership of digital assets via distributed computation. There's a lot more to bitcoin than first meets the eye.
|
||||||
|
|
||||||
In this chapter we'll get started with bitcoin by explaining some of the main concepts and terms, getting the necessary software and using bitcoin for simple transactions. In following chapters we'll start unwrapping the layers of technology that make bitcoin possible and examine the inner workings of the bitcoin network and protocol.
|
In this chapter we'll get started by explaining some of the main concepts and terms, getting the necessary software and using bitcoin for simple transactions. In following chapters we'll start unwrapping the layers of technology that make bitcoin possible and examine the inner workings of the bitcoin network and protocol.
|
||||||
|
|
||||||
=== History of Bitcoin
|
=== History of Bitcoin
|
||||||
|
|
||||||
The emergence of viable digital money is closely linked to developments in cryptography. This is not surprising when one considers the fundamental challenges involved with using bits to represent value that can be exchanged for goods and services. There are two fundamental questions for anyone accepting digital money:
|
The emergence of viable digital money is closely linked to developments in cryptography. This is not surprising when one considers the fundamental challenges involved with using bits to represent value that can be exchanged for goods and services. Two fundamental questions for anyone accepting digital money, are:
|
||||||
|
|
||||||
1. Can I trust the money is authentic and not counterfeit?
|
1. Can I trust the money is authentic and not counterfeit?
|
||||||
2. Can I be sure that no one else can claim that this money belongs to them and not me? (aka the “double-spend” problem)
|
2. Can I be sure that no one else can claim that this money belongs to them and not me? (aka the “double-spend” problem)
|
||||||
@ -28,7 +28,7 @@ Issuers of paper money are constantly battling the counterfeiting problem, by us
|
|||||||
|
|
||||||
In the late 1980s, when cryptography started becoming more broadly available and understood, many researchers began trying to use cryptography to build digital currencies. These early digital currency projects issued digital money, usually backed by a national currency or precious metal such as gold.
|
In the late 1980s, when cryptography started becoming more broadly available and understood, many researchers began trying to use cryptography to build digital currencies. These early digital currency projects issued digital money, usually backed by a national currency or precious metal such as gold.
|
||||||
|
|
||||||
While these earlier digital currencies worked, they were centralized and as a result they were easy to attack by governments and hackers. Early digital currencies used a central clearinghouse to settle all transactions at regular intervals, just like a traditional banking system. These central clearinghouses and the organizations issuing the digital currency were highly centralized organizations, usually corporations. Unfortunately, in most cases these nascent digital currencies were targeted by worried governments and eventually litigated out of existence. Some failed in spectacular crashes when the parent company liquidated abruptly. Based on the issues discussed above, the creator of bitcoin recognized that, in order to be robust against intervention by antagonists - be they legitimate governments or criminal elements - a successful digital currency needed to avoid the use of a central currency issuing or transaction clearing authority that could be a single point of attack. Bitcoin is such a system, completely de-centralized by design, lacking any central authority or point of control that can be attacked or corrupted.
|
While these earlier digital currencies worked, they were centralized and as a result they were easy to attack by governments and hackers. Early digital currencies used a central clearinghouse to settle all transactions at regular intervals, just like a traditional banking system. Unfortunately, in most cases these nascent digital currencies were targeted by worried governments and eventually litigated out of existence. Some failed in spectacular crashes when the parent company liquidated abruptly. To be robust against intervention by antagonists, be they legitimate governments or criminal elements, a digital currency needed to avoid the use of a central currency issuing or transaction clearing authority that could be a single point of attack. Bitcoin is such a system, completely de-centralized by design, lacking any central authority or point of control that can be attacked or corrupted.
|
||||||
|
|
||||||
Bitcoin represents the culmination of decades of research in cryptography and distributed systems and includes four key innovations brought together in a unique and powerful combination. Bitcoin consists of:
|
Bitcoin represents the culmination of decades of research in cryptography and distributed systems and includes four key innovations brought together in a unique and powerful combination. Bitcoin consists of:
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ The bitcoin network started in 2009, based on a reference implementation publish
|
|||||||
Satoshi Nakamoto withdrew from the public in April of 2011, leaving the responsibility of developing the code and network to a thriving group of volunteers. The name Satoshi Nakamoto is an alias and the identity of the person or people behind this invention is currently unknown. However, neither Satoshi Nakamoto nor anyone else exerts control over the bitcoin system, which operates based on fully transparent mathematical principles. The invention itself is groundbreaking and has already spawned new science in the fields of distributed computing, economics and econometrics.
|
Satoshi Nakamoto withdrew from the public in April of 2011, leaving the responsibility of developing the code and network to a thriving group of volunteers. The name Satoshi Nakamoto is an alias and the identity of the person or people behind this invention is currently unknown. However, neither Satoshi Nakamoto nor anyone else exerts control over the bitcoin system, which operates based on fully transparent mathematical principles. The invention itself is groundbreaking and has already spawned new science in the fields of distributed computing, economics and econometrics.
|
||||||
|
|
||||||
|
|
||||||
.A solution to a distributed computing problem
|
.A Solution To a Distributed Computing Problem
|
||||||
****
|
****
|
||||||
Satoshi Nakamoto's invention is also a practical solution to a previously unsolved problem in distributed computing, known as the Byzantine Generals problem. Briefly, the problem consists of trying to agree on a course of action by exchanging information over an unreliable and potentially compromised network. Satoshi Nakamoto's solution, which uses the concept of Proof-of-Work to achieve consensus without a central trusted authority represents a breakthrough in distributed computing science and has wide applicability beyond currency. It can be used to achieve consensus on decentralized networks for provably-fair elections, lotteries, asset registries, digital notarization and more.
|
Satoshi Nakamoto's invention is also a practical solution to a previously unsolved problem in distributed computing, known as the Byzantine Generals problem. Briefly, the problem consists of trying to agree on a course of action by exchanging information over an unreliable and potentially compromised network. Satoshi Nakamoto's solution, which uses the concept of Proof-of-Work to achieve consensus without a central trusted authority represents a breakthrough in distributed computing science and has wide applicability beyond currency. It can be used to achieve consensus on decentralized networks for provably-fair elections, lotteries, asset registries, digital notarization and more.
|
||||||
****
|
****
|
||||||
@ -92,18 +92,18 @@ Web Client:: Web-clients are accessed through a web browser and store the user's
|
|||||||
|
|
||||||
.Mobile Bitcoin
|
.Mobile Bitcoin
|
||||||
****
|
****
|
||||||
Mobile clients, for smartphones such as those based on the Android system can either operate as full clients, light clients or web clients. Some mobile clients are synchronized with a web or desktop client, providing a multi-platform wallet across multiple devices but with a common source of funds
|
Mobile clients, for smartphones such as those based on the Android system can either operate as full clients, light clients or web clients. Some mobile clients are synchronized with a web or desktop client, providing a multi-platform wallet across multiple devices but with a common source of funds. See <<mobile_bitcoin>>
|
||||||
****
|
****
|
||||||
|
|
||||||
The choice of bitcoin client depends on how much control the user wants over their funds. A full client will offer the highest level of control and independence for the user, but in turn put the burden of backups and security on the user. On the other end of the range of choices, a web client is the easiest to setup and use, but the security and control is shared by the user and the owner of the web service, which introduces counterparty risk. If a web wallet service is compromised, as many have been, the users can lose all their funds. Conversely, if a user has a full client without adequate backups, they may lose their funds through a computer mishap.
|
The choice of bitcoin client depends on how much control the user wants over funds. A full client will offer the highest level of control and independence for the user, but in turn put the burden of backups and security on the user. On the other end of the range of choices, a web client is the easiest to setup and use, but the security and control is shared by the user and the owner of the web service, which introduces counterparty risk. If a web-wallet service is compromised, as many have been, the users can lose all their funds. Conversely, if a user has a full client without adequate backups, they may lose their funds through a computer mishap.
|
||||||
|
|
||||||
For the purposes of this book, we will be demonstrating the use of a variety of bitcoin clients, from the reference implementation (the Satoshi client) to web wallets. Some of the examples will require the use of the reference client, which exposes APIs to the wallet, network and transaction services. If you are planning to explore the programmatic interfaces into the bitcoin system, you will need the reference client.
|
For the purposes of this book, we will be demonstrating the use of a variety of bitcoin clients, from the reference implementation (the Satoshi client) to web-wallets. Some of the examples will require the use of the reference client, which exposes APIs to the wallet, network and transaction services. If you are planning to explore the programmatic interfaces into the bitcoin system, you will need the reference client.
|
||||||
|
|
||||||
==== Quick Start - Web Wallet
|
==== Quick Start - Web Wallet
|
||||||
|
|
||||||
A web wallet is the easiest way to start using bitcoin, and is the choice of Alice who we introduced in <<user-stories>>. Alice is not a technical user and only recently heard about bitcoin from a friend. She starts her journey by visiting the official website bitcoin.org, where she finds a broad selection of bitcoin clients. Following the advice on the bitcoin.org site, she chooses the easiest-to-use client, a web wallet by blockchain.info a popular hosted-wallet service. Following a link from bitcoin.org, she opens the blockchain.info wallet page at https://blockchain.info/wallet and selects "Start a New Wallet". To register her new wallet, she must enter an email address, a password and prove that she is a human by completing a CAPTCHA test.
|
A web-wallet is the easiest way to start using bitcoin, and is the choice of Alice who we introduced in <<user-stories>>. Alice is not a technical user and only recently heard about bitcoin from a friend. She starts her journey by visiting the official website bitcoin.org, where she finds a broad selection of bitcoin clients. Following the advice on the bitcoin.org site, she chooses a web-wallet by blockchain.info a popular hosted-wallet service. Following a link from bitcoin.org, she opens the blockchain.info wallet page at https://blockchain.info/wallet and selects "Start a New Wallet". To register her new wallet, she must enter an email address, a password and prove that she is a human by completing a CAPTCHA test.
|
||||||
|
|
||||||
[TIP]
|
[WARNING]
|
||||||
====
|
====
|
||||||
When creating a bitcoin wallet you will need to provide a password or passphrase to protect your wallet. There are many bad actors attempting to break weak passwords, so take care to select one that cannot be easily broken. Use a combination of upper and lower-case characters, numbers and symbols. Avoid personal information such as birthdates or names of sports teams. Avoid any words commonly found in dictionaries, in any language. If you can, use a password generator to create a completely random password, at least 12 characters in length. Remember: bitcoin is money and can be instantly moved anywhere in the world - that makes it easy to steal and disappear.
|
When creating a bitcoin wallet you will need to provide a password or passphrase to protect your wallet. There are many bad actors attempting to break weak passwords, so take care to select one that cannot be easily broken. Use a combination of upper and lower-case characters, numbers and symbols. Avoid personal information such as birthdates or names of sports teams. Avoid any words commonly found in dictionaries, in any language. If you can, use a password generator to create a completely random password, at least 12 characters in length. Remember: bitcoin is money and can be instantly moved anywhere in the world - that makes it easy to steal and disappear.
|
||||||
====
|
====
|
||||||
@ -114,25 +114,25 @@ Once Alice has completed the registration form, she is presented with a Wallet R
|
|||||||
.Blockchain.info - Wallet Recovery Mnemonic
|
.Blockchain.info - Wallet Recovery Mnemonic
|
||||||
image::images/blockchain-mnemonic.png["wallet recovery mnemonic"]
|
image::images/blockchain-mnemonic.png["wallet recovery mnemonic"]
|
||||||
|
|
||||||
A few seconds later, Alice can start using her new bitcoin web wallet by logging in with her account ID and password. In her web browser, she sees the web wallet home screen:
|
A few seconds later, Alice can start using her new bitcoin web-wallet by logging in with her account ID and password. In her web browser, she sees the web-wallet home screen:
|
||||||
|
|
||||||
[[blockchain-home]]
|
[[blockchain-home]]
|
||||||
.Blockchain.info - Wallet Home Screen
|
.Blockchain.info - Wallet Home Screen
|
||||||
image::images/blockchain-home.png["wallet home screen"]
|
image::images/blockchain-home.png["wallet home screen"]
|
||||||
|
|
||||||
The most important part of this screen is Alice's _bitcoin address_. Like an email address, Alice can share this address and anyone can use it to send money directly to her new web wallet. On the screen it appears as a long string of letters and numbers: +1Cdid9KFAaatwczBwBttQcwXYCpvK8h7FK+. Next to the wallet's bitcoin address, there is a QR-code, a form of barcode that contains the same information in a format that can be easily scanned by a smartphone's camera. Alice can print the QR code as a way to easily give her address to others without them having to type the long string of letters and numbers.
|
The most important part of this screen is Alice's _bitcoin address_. Like an email address, Alice can share this address and anyone can use it to send money directly to her new web-wallet. On the screen it appears as a long string of letters and numbers: +1Cdid9KFAaatwczBwBttQcwXYCpvK8h7FK+. Next to the wallet's bitcoin address, there is a QR-code, a form of barcode that contains the same information in a format that can be easily scanned by a smartphone's camera. Alice can print the QR code as a way to easily give her address to others without them having to type the long string of letters and numbers.
|
||||||
|
|
||||||
[TIP]
|
[TIP]
|
||||||
====
|
====
|
||||||
Bitcoin addresses start with the digit "1". Like email addresses, they can be shared with other bitcoin users who can use them to send bitcoin directly to your wallet. Unlike email addresses, you can create new addresses as often as you like, all of which will direct funds to your wallet. A wallet is simply a collection of addresses and the keys that unlock the funds within. There is practically no limit to the number of addresses a user can create.
|
Bitcoin addresses start with the digit "1". Like email addresses, they can be shared with other bitcoin users who can use them to send bitcoin directly to your wallet. Unlike email addresses, you can create new addresses as often as you like, all of which will direct funds to your wallet. A wallet is simply a collection of addresses and the keys that unlock the funds within. There is practically no limit to the number of addresses a user can create.
|
||||||
====
|
====
|
||||||
|
|
||||||
Alice is now ready to start using her new bitcoin web wallet.
|
Alice is now ready to start using her new bitcoin web-wallet.
|
||||||
|
|
||||||
[[getting_first_bitcoin]]
|
[[getting_first_bitcoin]]
|
||||||
===== Getting your first bitcoins
|
==== Getting your first bitcoins
|
||||||
|
|
||||||
It is not possible to buy bitcoins at a bank, or foreign exchange kioks, at this time. It is not possible to use a credit card to buy bitcoins, either. In 2013, it is still quite difficult to acquire bitcoins in most countries. There are a number of specialized currency exchanges where you can buy and sell bitcoin in exchange for a local currency. These operate as web-based currency markets and include:
|
It is not possible to buy bitcoins at a bank, or foreign exchange kioks, at this time. It is not possible to use a credit card to buy bitcoins, either. At the time this book is being written, in 2013, it is still quite difficult to acquire bitcoins in most countries. There are a number of specialized currency exchanges where you can buy and sell bitcoin in exchange for a local currency. These operate as web-based currency markets and include:
|
||||||
|
|
||||||
* Bitstamp (bitstamp.net), a European currency market that supports several currencies including euros (EUR) and US dollars (USD) via wire transfer
|
* Bitstamp (bitstamp.net), a European currency market that supports several currencies including euros (EUR) and US dollars (USD) via wire transfer
|
||||||
* Coinbase (coinbase.com), a US-based currency market, based in California, that supports US dollar exchange to and from bitcoin. Coinbase can connect to US checking accounts via the ACH system
|
* Coinbase (coinbase.com), a US-based currency market, based in California, that supports US dollar exchange to and from bitcoin. Coinbase can connect to US checking accounts via the ACH system
|
||||||
@ -149,22 +149,21 @@ There are three other methods for getting bitcoins as a new user:
|
|||||||
|
|
||||||
Alice was introduced to bitcoin by a friend and so she has an easy way of getting her first bitcoin while she waits for her account on a California currency market to be verified and activated.
|
Alice was introduced to bitcoin by a friend and so she has an easy way of getting her first bitcoin while she waits for her account on a California currency market to be verified and activated.
|
||||||
|
|
||||||
===== Sending and receiving bitcoins
|
==== Sending and receiving bitcoins
|
||||||
|
|
||||||
Once Alice created her bitcoin web wallet, she is ready to receive funds. Her web wallet application generated a bitcoin address and the corresponding key (an elliptic curve private key, describe in more detail in <<private keys>>). At this point, her bitcoin address is not known to the bitcoin network or "registered" with any part of the bitcoin system. Her bitcoin address is simply a number that corresponds to a key that she can use to control access to the funds. There is no account or association between that address and an account. Until the moment this address is referenced as the recipient of value in a transaction posted on the bitcoin ledger (the blockchain), it is simply part of the vast number of possible addresses that are "valid" in bitcoin. Once it has been associated with a transaction, it becomes part of the known addresses in the network and anyone can check its balance on the public ledger.
|
Alice has created her bitcoin web-wallet and she is now ready to receive funds. Her web-wallet application generated a bitcoin address and the corresponding key (an elliptic curve private key, describe in more detail in <<private keys>>). At this point, her bitcoin address is not known to the bitcoin network or "registered" with any part of the bitcoin system. Her bitcoin address is simply a number that corresponds to a key that she can use to control access to the funds. There is no account or association between that address and an account. Until the moment this address is referenced as the recipient of value in a transaction posted on the bitcoin ledger (the blockchain), it is simply part of the vast number of possible addresses that are "valid" in bitcoin. Once it has been associated with a transaction, it becomes part of the known addresses in the network and anyone can check its balance on the public ledger.
|
||||||
|
|
||||||
Alice meets her friend Joe who introduced her to bitcoin at a local restaurant so they can exchange some US dollars and put some bitcoins into her account. She has brought a print out of her address and the QR code as shown on the home page of her web wallet. There is nothing sensitive, from a security perspective, about the bitcoin address, it can be posted anywhere without risking the security of her account and it can be changed by creating a new address at any time. The print out of the address and QR code is just for convenience. Alice wants to convert just $10 US dollars into bitcoin, so as not to risk too much money on this new technology. She gives Joe a $10 bill and the printout of her address so that Joe can send her the equivalent amount of bitcoin.
|
Alice meets her friend Joe who introduced her to bitcoin at a local restaurant so they can exchange some US dollars and put some bitcoins into her account. She has brought a print out of her address and the QR code as shown on the home page of her web-wallet. There is nothing sensitive, from a security perspective, about the bitcoin address, it can be posted anywhere without risking the security of her account and it can be changed by creating a new address at any time. Alice wants to convert just $10 US dollars into bitcoin, so as not to risk too much money on this new technology. She gives Joe a $10 bill and the printout of her address so that Joe can send her the equivalent amount of bitcoin.
|
||||||
|
|
||||||
First, Joe has to figure out the exchange rate so that he can give the correct amount of bitcoin to Alice. There are hundreds of applications and web sites that can provide the current market rate, here are some of the most popular:
|
First, Joe has to figure out the exchange rate so that he can give the correct amount of bitcoin to Alice. There are hundreds of applications and web sites that can provide the current market rate, here are some of the most popular:
|
||||||
|
|
||||||
* bitcoincharts.com, a market data listing service that shows the market rate of bitcoin across many exchanges around the globe, denominated in different local currencies
|
* bitcoincharts.com, a market data listing service that shows the market rate of bitcoin across many exchanges around the globe, denominated in different local currencies
|
||||||
* bitcoinaverage.com, a site that provides a simple view of the volume-weighted-average for each currency.
|
* bitcoinaverage.com, a site that provides a simple view of the volume-weighted-average for each currency.
|
||||||
* Bitcoin Prices, a free Android application that can display a bitcoin price from most exchanges or from the bitcoinaverage.com site mentioned above.
|
* ZeroBlock, a free Android and iOS application that can display a bitcoin price from different exchanges.
|
||||||
* Bitcoin Price, an iOS application for iPhone and iPad that shows the bitcoin price in difference exchanges.
|
|
||||||
|
|
||||||
[[bitcoin-price-android]]
|
[[zeroblock-android]]
|
||||||
.Bitcoin Prices - A bitcoin market rate application for Android OS
|
.ZeroBlock - A bitcoin market-rate application for Android and iOS
|
||||||
image::images/bitcoin-price-android.png["bitcoin prices screenshot"]
|
image::images/zeroblock.png["zeroblock screenshot"]
|
||||||
|
|
||||||
Using one of the applications or websites above, Joe determines the price of bitcoin to be approximately $100 US dollars per bitcoin. At that rate, he should give Alice 0.10 bitcoin, also known as 100 milli-bits, in return for the $10 US dollars she gave him.
|
Using one of the applications or websites above, Joe determines the price of bitcoin to be approximately $100 US dollars per bitcoin. At that rate, he should give Alice 0.10 bitcoin, also known as 100 milli-bits, in return for the $10 US dollars she gave him.
|
||||||
|
|
||||||
|
@ -36,19 +36,23 @@ $1.50 USD
|
|||||||
----
|
----
|
||||||
|
|
||||||
[[payment-request-QR]]
|
[[payment-request-QR]]
|
||||||
.Payment Request QR Code - encodes a payment request URL as defined in BIP0021
|
.Payment Request QR Code - Hint: Try to scan this!
|
||||||
image::images/payment-request-qr.png["payment-request"]
|
image::images/payment-request-qr.png["payment-request"]
|
||||||
|
|
||||||
[[payment-request-URL]]
|
[[payment-request-URL]]
|
||||||
.The payment request QR code above encodes the following URL, defined in BIP0021
|
.The payment request QR code above encodes the following URL, defined in BIP0021
|
||||||
----
|
----
|
||||||
bitcoin:1GdK9UzpHBzqzX2A9JFP3Di4weBwqgmoQA?amount=0.015&label=Bob%27s%20Cafe&message=Purchase%20at%20Bob%27s%20Cafe
|
bitcoin:1GdK9UzpHBzqzX2A9JFP3Di4weBwqgmoQA?\
|
||||||
|
amount=0.015&\
|
||||||
|
label=Bob%27s%20Cafe&\
|
||||||
|
message=Purchase%20at%20Bob%27s%20Cafe
|
||||||
|
|
||||||
Components of the URL
|
Components of the URL
|
||||||
A bitcoin address: 1GdK9UzpHBzqzX2A9JFP3Di4weBwqgmoQA
|
|
||||||
The payment amount: amount=0.015
|
A bitcoin address: "1GdK9UzpHBzqzX2A9JFP3Di4weBwqgmoQA"
|
||||||
A label for the recipient address: label=Bob%27s%20Cafe
|
The payment amount: "0.015"
|
||||||
A description for the payement: message=Purchase%20at%20Bob%27s%20Cafe
|
A label for the recipient address: "Bob's Cafe"
|
||||||
|
A description for the payement: "Purchase at Bob's Cafe"
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
||||||
@ -57,7 +61,7 @@ A description for the payement: message=Purchase%20at%20Bob%27s%20Cafe
|
|||||||
Unlike a QR code that simply contains a destination bitcoin address, a "payment request" is a QR encoded URL that contains a destination address, a payment amount and a generic description such as "Bob's Cafe". This allows a bitcoin wallet application to pre-fill the information to send the payment while showing a human-readable description to the user. See <<payment request URL>>, for more details. You can scan the QR code above with a bitcoin wallet application to see what Alice would see.
|
Unlike a QR code that simply contains a destination bitcoin address, a "payment request" is a QR encoded URL that contains a destination address, a payment amount and a generic description such as "Bob's Cafe". This allows a bitcoin wallet application to pre-fill the information to send the payment while showing a human-readable description to the user. See <<payment request URL>>, for more details. You can scan the QR code above with a bitcoin wallet application to see what Alice would see.
|
||||||
====
|
====
|
||||||
|
|
||||||
Bob says _"That's one-dollar-fifty, or fifteen milibits"_.
|
Bob says "That's one-dollar-fifty, or fifteen milibits".
|
||||||
|
|
||||||
Alice uses her smartphone to scan the barcode on display. Her smartphone shows a payment of +0.0150 BTC+ to +Bob's Cafe+ and she selects +Send+ to authorize the payment. Within a few seconds (about the same time as a credit card authorization), Bob would see the transaction on the register, completing the transaction.
|
Alice uses her smartphone to scan the barcode on display. Her smartphone shows a payment of +0.0150 BTC+ to +Bob's Cafe+ and she selects +Send+ to authorize the payment. Within a few seconds (about the same time as a credit card authorization), Bob would see the transaction on the register, completing the transaction.
|
||||||
|
|
||||||
@ -133,7 +137,7 @@ $ curl https://blockchain.info/unspent?active=1Cdid9KFAaatwczBwBttQcwXYCpvK8h7FK
|
|||||||
"unspent_outputs":[
|
"unspent_outputs":[
|
||||||
|
|
||||||
{
|
{
|
||||||
"tx_hash":"186f9f998a5aa6f048e51dd8419a14d8a0f1a8a2836dd734d2804fe65fa35779",
|
"tx_hash":"186f9f998a5...2836dd734d2804fe65fa35779",
|
||||||
"tx_index":104810202,
|
"tx_index":104810202,
|
||||||
"tx_output_n": 0,
|
"tx_output_n": 0,
|
||||||
"script":"76a9147f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a888ac",
|
"script":"76a9147f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a888ac",
|
||||||
@ -203,16 +207,18 @@ A common misconception about bitcoin transactions is that they must be "confirme
|
|||||||
|
|
||||||
=== Bitcoin Mining
|
=== Bitcoin Mining
|
||||||
|
|
||||||
The bitcoin system of trust is based on computation. Transactions are bundled into "blocks" which require an enormous amount of computation to "prove", but only a small amount of computation to verify as "proven", in a process called "mining". Mining serves two purposes in bitcoin:
|
The transaction is now propagated on the bitcoin network. It does not become part of the shared ledger (the _blockchain_) until it is verified and included in a block, in a process called _mining_. See <<mining>> for a detailed explanation.
|
||||||
|
|
||||||
|
The bitcoin system of trust is based on computation. Transactions are bundled into _blocks_ which require an enormous amount of computation to prove, but only a small amount of computation to verify as proven, in a process called _mining_. Mining serves two purposes in bitcoin:
|
||||||
|
|
||||||
* Mining creates new bitcoins in each block, almost like a central bank printing new money. The amount of bitcoin created is fixed and diminishes with time
|
* Mining creates new bitcoins in each block, almost like a central bank printing new money. The amount of bitcoin created is fixed and diminishes with time
|
||||||
* Mining creates trust by ensuring that transactions are only confirmed if enough computational power was devoted to the block that contains them. More blocks mean more computation which means more trust.
|
* Mining creates trust by ensuring that transactions are only confirmed if enough computational power was devoted to the block that contains them. More blocks mean more computation which means more trust.
|
||||||
|
|
||||||
A good way to describe mining is like a giant game of bingo that resets every time someone finds a solution and whose difficulty automatically adjusts so that it takes approximately 10 minutes to find a solution.
|
A good way to describe mining is like a giant competitive game of sudoku that resets every time someone finds a solution and whose difficulty automatically adjusts so that it takes approximately 10 minutes to find a solution. Imagine a giant sudoku puzzle, several thousand rows and columns in size. If I show you a completed puzzle you can verify it quite quickly. If it is empty, however, it takes a lot of work to solve! The difficulty of the sudoku can be adjusted by changing its size (more or fewer rows and columns), but it can still be verified quite easily even if it is very large. The "puzzle" used in bitcoin is based on a cryptographic hash and exhibits similar characteristics: it is assymetrically hard to solve, but easy to verify and its difficulty can be adjusted.
|
||||||
|
|
||||||
In <<user-stories>> we introduced Jing, a computer engineering student in Shanghai. Jing is participating in the bitcoin network as a miner. Every 10 minutes or so, Jing joins thousands of other miners in a global race to find a solution to a block of transactions. Finding such a solution, the so-called "Proof-of-Work" requires quadrillions of hashing operations per second, across the entire bitcoin network. The algorithm for "Proof-of-Work" involves repeatedly hashing the header of the block and a random number with the SHA256 cryptographic algorithm, until a solution matching a pre-determined pattern emerges. The first miner to find such a solution wins the round of competition and publishes that block into the blockchain.
|
In <<user-stories>> we introduced Jing, a computer engineering student in Shanghai. Jing is participating in the bitcoin network as a miner. Every 10 minutes or so, Jing joins thousands of other miners in a global race to find a solution to a block of transactions. Finding such a solution, the so-called "Proof-of-Work" requires quadrillions of hashing operations per second, across the entire bitcoin network. The algorithm for "Proof-of-Work" involves repeatedly hashing the header of the block and a random number with the SHA256 cryptographic algorithm, until a solution matching a pre-determined pattern emerges. The first miner to find such a solution wins the round of competition and publishes that block into the blockchain.
|
||||||
|
|
||||||
Jing started mining in 2010 using a very fast desktop computer to find a suitable Proof-of-Work for new blocks. As more miners started joining the bitcoin network, the difficulty of the problem increased rapidly. Soon, Jing and other miners upgraded to more specialized hardware, such as Graphical Processing Units (GPU), as used in gaming desktops or consoles. By 2013, the difficulty is so high that it is only profitable to mine with Application Specific Integrated Circuits, essentially hundreds of mining algorithms printed in hardware, running in parallel on a single silicone chip. Jing also joined a "mining pool", which much like a lottery-pool allows several participants to share their efforts and the rewards. Jing now runs two ASIC machines, which are USB connected devices, to mine for bitcoin 24 hours a day. He pays his electricity costs by selling the bitcoin he is able to generate from mining, creating some income from the profits. His computer runs a copy of bitcoind, the reference bitcoin client, as a back-end to his specialized mining software.
|
Jing started mining in 2010 using a very fast desktop computer to find a suitable Proof-of-Work for new blocks. As more miners started joining the bitcoin network, the difficulty of the problem increased rapidly. Soon, Jing and other miners upgraded to more specialized hardware, such as Graphical Processing Units (GPU), as used in gaming desktops or consoles. As this book is written, by 2014, the difficulty is so high that it is only profitable to mine with Application Specific Integrated Circuits, essentially hundreds of mining algorithms printed in hardware, running in parallel on a single silicone chip. Jing also joined a "mining pool", which much like a lottery-pool allows several participants to share their efforts and the rewards. Jing now runs two ASIC machines, which are USB connected devices, to mine for bitcoin 24 hours a day. He pays his electricity costs by selling the bitcoin he is able to generate from mining, creating some income from the profits. His computer runs a copy of bitcoind, the reference bitcoin client, as a back-end to his specialized mining software.
|
||||||
|
|
||||||
=== Mining transactions in blocks
|
=== Mining transactions in blocks
|
||||||
|
|
||||||
|
@ -1,35 +1,33 @@
|
|||||||
[[ch03_bitcoin_client]]
|
[[ch03_bitcoin_client]]
|
||||||
== The Bitcoin Client
|
== The Bitcoin Client
|
||||||
|
|
||||||
=== Bitcoin-Qt - The Reference Implementation, aka Satoshi Client
|
=== Bitcoin Core - The Reference Implementation, aka Satoshi Client
|
||||||
|
|
||||||
You can download the Satoshi Client from bitcoin.org. Depending on your operating system, it will be called bitcoin-qt or bitcoind. The reference client implements all aspects of the bitcoin system, including wallets, a transaction verification engine with a full copy of the entire transaciton ledger (blockchain) and a full network node in the peer-to-peer bitcoin network.
|
You can download the Reference Client, also known as _Bitcoin Core_ from bitcoin.org. The reference client implements all aspects of the bitcoin system, including wallets, a transaction verification engine with a full copy of the entire transaciton ledger (blockchain) and a full network node in the peer-to-peer bitcoin network.
|
||||||
|
|
||||||
Go to http://bitcoin.org/en/choose-your-wallet and select "Bitcoin-Qt" to download the reference client. Depending on your operating system, you will download an executable installer. For Windows, this is either a ZIP archive or an EXE executable. For Mac OS it is DMG disk image. Linux versions include a PPA package for Ubuntu or a TAR.GZ archive.
|
Go to http://bitcoin.org/en/choose-your-wallet and select "Bitcoin Core" to download the reference client. Depending on your operating system, you will download an executable installer. For Windows, this is either a ZIP archive or an EXE executable. For Mac OS it is DMG disk image. Linux versions include a PPA package for Ubuntu or a TAR.GZ archive.
|
||||||
|
|
||||||
==== Bitcoin-Qt - Download Options
|
[[bitcoin-choose-client]]
|
||||||
|
.Bitcoin - Choose A Bitcoin Client
|
||||||
|
image::images/bitcoin-choose-client.png["bitcoin choose client"]
|
||||||
|
|
||||||
[[bitcoin-qt-dl-options]]
|
==== Bitcoin Core - Running the client for the first time
|
||||||
.Bitcoin-Qt - Download options for different operating systems
|
|
||||||
image::images/bitcoin-qt-dl-options.png["bitcoin-qt download options"]
|
|
||||||
|
|
||||||
==== Bitcoin-Qt - Running the client for the first time
|
|
||||||
|
|
||||||
If you download an installable package, such as an EXE, DMG or PPA, you can install it the same way as any application on your operating system. For Windows, run the EXE and follow the step-by-step instructions. For Mac OS, launch the DMG and drag the Bitcoin-QT icon into your Applications folder. For Ubuntu, double-click on the PPA in your File Explorer and it will open the package manager to install the package. Once you have completed installation you should have a new application "Bitcoin-Qt" in your application list. Double-click on the icon to start the bitcoin client.
|
If you download an installable package, such as an EXE, DMG or PPA, you can install it the same way as any application on your operating system. For Windows, run the EXE and follow the step-by-step instructions. For Mac OS, launch the DMG and drag the Bitcoin-QT icon into your Applications folder. For Ubuntu, double-click on the PPA in your File Explorer and it will open the package manager to install the package. Once you have completed installation you should have a new application "Bitcoin-Qt" in your application list. Double-click on the icon to start the bitcoin client.
|
||||||
|
|
||||||
The first time you run Bitcoin-Qt it will start downloading the blockchain, a process that may take several days. Leave it running in the background, until it displays "Synchronized" and no longer shows "Out of sync" next to the balance.
|
The first time you run Bitcoin Core it will start downloading the blockchain, a process that may take several days. Leave it running in the background, until it displays "Synchronized" and no longer shows "Out of sync" next to the balance.
|
||||||
|
|
||||||
[TIP]
|
[TIP]
|
||||||
====
|
====
|
||||||
Bitcoin-Qt keeps a full copy of the transaction ledger (blockchain), with every transaction that has ever occured on the bitcoin network since its inception in 2009. This data set is several gigabytes in size (approximately 16GB in late 2013) and is downloaded incrementally over several days. The client will not be able to process transactions or update account balances until the full blockchain dataset is downloaded. During that time, the client will display "Out of sync" next to the account balances and show "Synchronizing" in the footer. Make sure you have enough disk space, bandwidth and time to complete the initial synchronization.
|
Bitcoin Core keeps a full copy of the transaction ledger (blockchain), with every transaction that has ever occured on the bitcoin network since its inception in 2009. This data set is several gigabytes in size (approximately 16GB in late 2013) and is downloaded incrementally over several days. The client will not be able to process transactions or update account balances until the full blockchain dataset is downloaded. During that time, the client will display "Out of sync" next to the account balances and show "Synchronizing" in the footer. Make sure you have enough disk space, bandwidth and time to complete the initial synchronization.
|
||||||
====
|
====
|
||||||
|
|
||||||
[[bitcoin-qt-firstload]]
|
[[bitcoin-qt-firstload]]
|
||||||
.Bitcoin-Qt - The Graphical User Interface, during the blockchain initialization
|
.Bitcoin Core - The Graphical User Interface, during the blockchain initialization
|
||||||
image::images/bitcoin-qt-firstload.png["bitcoin-qt first run"]
|
image::images/bitcoin-qt-firstload.png["bitcoin-qt first run"]
|
||||||
|
|
||||||
|
|
||||||
==== Bitcoin-Qt - Compiling the client from the source code
|
==== Bitcoin Core - Compiling the client from the source code
|
||||||
|
|
||||||
For developers, there is also the option to download the full source code, either as a ZIP archive or by cloning the authoritative source repository from Github. Go to https://github.com/bitcoin/bitcoin and select "Download ZIP" from the sidebar. Alternatively, use the git command line to create a local copy of the source code on your system. In the example below, we are cloning the source code from a unix-like command-line, in Linux or Mac OS:
|
For developers, there is also the option to download the full source code, either as a ZIP archive or by cloning the authoritative source repository from Github. Go to https://github.com/bitcoin/bitcoin and select "Download ZIP" from the sidebar. Alternatively, use the git command line to create a local copy of the source code on your system. In the example below, we are cloning the source code from a unix-like command-line, in Linux or Mac OS:
|
||||||
|
|
||||||
@ -1124,7 +1122,7 @@ See 'sx help COMMAND' for more information on a specific command.
|
|||||||
SpesmiloXchange home page: <http://sx.dyne.org/>
|
SpesmiloXchange home page: <http://sx.dyne.org/>
|
||||||
----
|
----
|
||||||
|
|
||||||
===== Generating and manipulating keys with sx
|
===== Generating and manipulating keys with sxBitcoin Core
|
||||||
|
|
||||||
Generate a new private key, using the operating system's random number generator, with the +newkey+ command. We save the standard output into the file +private_key+:
|
Generate a new private key, using the operating system's random number generator, with the +newkey+ command. We save the standard output into the file +private_key+:
|
||||||
|
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
Dump of material that needs to be placed later
|
Dump of material that needs to be placed later
|
||||||
|
|
||||||
|
bio
|
||||||
|
|
||||||
|
|
||||||
|
I've been working in security and distributed system for a bit more than twenty years. It all started at age ten when I saw the first personal computers and discovered the joy of programming languages. I spent much of my teenage years learning to code, exploring online communities with a dial-up modem and eventually stumbled upon the Internet at the end of the 80s, just before starting my university education in Computer Science. By the mid-90's I had witnessed the dawn of the Internet and I had become enthralled by the technologies and communities it spawned: the open source movement, the "hacker" community, the Cypherpunks and a global culture of open communication and information sharing. I became interested in cryptography and digital currencies, starting with the Cypherpunk movement that developed around the use of strong cryptography for anonymity, de-centralization of power and social and political change. I studied the work of David Chaum, a digital currency pioneer who invented the concept of a "blind signature" for use in anonymous digital currency. After completing my Masters in Data Communications, Networks and Distributed Systems, I found myself more and more interested in information security on distributed systems, like the Internet. I developed my career in information security, I continued to follow the digital currency space, as an area of applied cryptography and information security. I watched as several attempts to create digital currencies failed, each one adding a bit more to the field.
|
||||||
|
|
||||||
|
When bitcoin was invented in 2008, I wasn't paying much attention, as I was trying to save the company I co-founded, a 5-year old startup, from the economic collapse that was destroying companies all around me. For the next two years, I was very distracted by the challenge of navigating a hollowed out economy as an entrepreneur and security analyst, responsible for the livelihood of my employees and partners. By 2011 I had left my last company and was working on small projects while looking for new opportunities that would capture my imagination and passion.
|
||||||
|
|
||||||
.The transaction outputs sum up to less than the input, leaving the fee
|
.The transaction outputs sum up to less than the input, leaving the fee
|
||||||
----
|
----
|
||||||
Alice's transaction to pay for Bob's coffee:
|
Alice's transaction to pay for Bob's coffee:
|
||||||
|
BIN
images/bitcoin-choose-client.png
Normal file
BIN
images/bitcoin-choose-client.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 55 KiB |
Binary file not shown.
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 24 KiB |
BIN
images/zeroblock.png
Normal file
BIN
images/zeroblock.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
Loading…
Reference in New Issue
Block a user