Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Preface
Writing the Bitcoin Book
Intended Audience
Why Are There Bugs on the Cover?
Conventions Used in This Book
Code Examples
Using Code Examples
Bitcoin Addresses and Transactions in This Book
O’Reilly Safari
How to Contact Us
Contacting the Author
Acknowledgments
Early Release Draft (GitHub Contributions)
1. Introduction
What Is Bitcoin?
History of Bitcoin
Bitcoin Uses, Users, and Their Stories
Getting Started
Choosing a Bitcoin Wallet
Quick Start
Getting Your First Bitcoin
Finding the Current Price of Bitcoin
Sending and Receiving Bitcoin
2. How Bitcoin Works
Transactions, Blocks, Mining, and the Blockchain
Bitcoin Overview
Buying a Cup of Coffee
Bitcoin Transactions
Transaction Inputs and Outputs
Transaction Chains
Making Change
Common Transaction Forms
Constructing a Transaction
Getting the Right Inputs
Creating the Outputs
Adding the Transaction to the Ledger
Transmitting the transaction
How it propagates
Bob’s view
Bitcoin Mining
Mining Transactions in Blocks
Spending the Transaction
3. Bitcoin Core: The Reference Implementation
Bitcoin Development Environment
Compiling Bitcoin Core from the Source Code
Selecting a Bitcoin Core Release
Configuring the Bitcoin Core Build
Building the Bitcoin Core Executables
Running a Bitcoin Core Node
Running Bitcoin Core for the First Time
Configuring the Bitcoin Core Node
Bitcoin Core Application Programming Interface (API)
Getting Information on the Bitcoin Core Client Status
Exploring and Decoding Transactions
Exploring Blocks
Using Bitcoin Core’s Programmatic Interface
Alternative Clients, Libraries, and Toolkits
C/C++
JavaScript
Java
Python
Ruby
Go
Rust
C#
Objective-C
4. Keys, Addresses
Introduction
Public Key Cryptography and Cryptocurrency
Private and Public Keys
Private Keys
Generating a private key from a random number
Public Keys
Elliptic Curve Cryptography Explained
Generating a Public Key
Bitcoin Addresses
Base58 and Base58Check Encoding
Key Formats
Private key formats
Decode from Base58Check
Encode from hex to Base58Check
Encode from hex (compressed key) to Base58Check
Public key formats
Compressed public keys
Compressed private keys
Implementing Keys and Addresses in Python
Advanced Keys and Addresses
Encrypted Private Keys (BIP-38)
Pay-to-Script Hash (P2SH) and Multisig Addresses
Multisignature addresses and P2SH
Vanity Addresses
Generating vanity addresses
Vanity address security
Paper Wallets
5. Wallets
Wallet Technology Overview
Nondeterministic (Random) Wallets
Deterministic (Seeded) Wallets
HD Wallets (BIP-32/BIP-44)
Seeds and Mnemonic Codes (BIP-39)
Wallet Best Practices
Using a Bitcoin Wallet
Wallet Technology Details
Mnemonic Code Words (BIP-39)
Generating mnemonic words
From mnemonic to seed
Optional passphrase in BIP-39
Working with mnemonic codes
Creating an HD Wallet from the Seed
Private child key derivation
Using derived child keys
Extended keys
Public child key derivation
Using an Extended Public Key on a Web Store
Hardened child key derivation
Index numbers for normal and hardened derivation
HD wallet key identifier (path)
Navigating the HD wallet tree structure
6. Transactions
Introduction
Transactions in Detail
Transactions—Behind the Scenes
Transaction Outputs and Inputs
Transaction Outputs
Transaction serialization—outputs
Transaction Inputs
Transaction serialization—inputs
Transaction Fees
Adding Fees to Transactions
Transaction Scripts and Script Language
Turing Incompleteness
Stateless Verification
Script Construction (Lock + Unlock)
The script execution stack
A simple script
Separate execution of unlocking and locking scripts
Pay-to-Public-Key-Hash (P2PKH)
Digital Signatures (ECDSA)
How Digital Signatures Work
Creating a digital signature
Serialization of signatures (DER)
Verifying the Signature
Signature Hash Types (SIGHASH)
ECDSA Math
The Importance of Randomness in Signatures
Bitcoin Addresses, Balances, and Other Abstractions
7. Advanced Transactions and Scripting
Introduction
Multisignature
A bug in CHECKMULTISIG execution
Pay-to-Script-Hash (P2SH)
P2SH Addresses
Benefits of P2SH
Redeem Script and Validation
Data Recording Output (RETURN)
Timelocks
Transaction Locktime (nLocktime)
Transaction locktime limitations
Check Lock Time Verify (CLTV)
Relative Timelocks
Relative Timelocks with nSequence
Original meaning of nSequence
nSequence as a consensus-enforced relative timelock
Relative Timelocks with CSV
Median-Time-Past
Timelock Defense Against Fee Sniping
Scripts with Flow Control (Conditional Clauses)
Conditional Clauses with VERIFY Opcodes
Using Flow Control in Scripts
Complex Script Example
8. The Bitcoin Network
Peer-to-Peer Network Architecture
Node Types and Roles
The Extended Bitcoin Network
Bitcoin Relay Networks
Network Discovery
Full Nodes
Exchanging “Inventory”
Simplified Payment Verification (SPV) Nodes
Bloom Filters
How Bloom Filters Work
How SPV Nodes Use Bloom Filters
SPV Nodes and Privacy
Encrypted and Authenticated Connections
Tor Transport
Peer-to-Peer Authentication and Encryption
Transaction Pools
9. The Blockchain
Introduction
Structure of a Block
Block Header
Block Identifiers: Block Header Hash and Block Height
The Genesis Block
Linking Blocks in the Blockchain
Merkle Trees
Merkle Trees and Simplified Payment Verification (SPV)
Bitcoin’s Test Blockchains
Testnet—Bitcoin’s Testing Playground
Using testnet
Segnet—The Segregated Witness Testnet
Regtest—The Local Blockchain
Using Test Blockchains for Development
10. Mining and Consensus
Introduction
Bitcoin Economics and Currency Creation
Decentralized Consensus
Independent Verification of Transactions
Mining Nodes
Aggregating Transactions into Blocks
The Coinbase Transaction
Coinbase Reward and Fees
Structure of the Coinbase Transaction
Coinbase Data
Constructing the Block Header
Mining the Block
Proof-of-Work Algorithm
Target Representation
Retargeting to Adjust Difficulty
Successfully Mining the Block
Validating a New Block
Assembling and Selecting Chains of Blocks
Blockchain Forks
Mining and the Hashing Race
The Extra Nonce Solution
Mining Pools
Managed pools
Peer-to-peer mining pool (P2Pool)
Consensus Attacks
Changing the Consensus Rules
Hard Forks
Hard Forks: Software, Network, Mining, and Chain
Diverging Miners and Difficulty
Contentious Hard Forks
Soft Forks
Soft forks redefining NOP opcodes
Other ways to soft fork upgrade
Criticisms of Soft Forks
Soft Fork Signaling with Block Version
BIP-34 Signaling and Activation
BIP-9 Signaling and Activation
Consensus Software Development
11. Bitcoin Security
Security Principles
Developing Bitcoin Systems Securely
The Root of Trust
User Security Best Practices
Physical Bitcoin Storage
Hardware Wallets
Balancing Risk
Diversifying Risk
Multisig and Governance
Survivability
Conclusion
12. Blockchain Applications
Introduction
Building Blocks (Primitives)
Applications from Building Blocks
Colored Coins
Using Colored Coins
Issuing Colored Coins
Colored Coins Transactions
Counterparty
Payment Channels and State Channels
State Channels—Basic Concepts and Terminology
Simple Payment Channel Example
Making Trustless Channels
Asymmetric Revocable Commitments
Hash Time Lock Contracts (HTLC)
Routed Payment Channels (Lightning Network)
Basic Lightning Network Example
Lightning Network Transport and Routing
Lightning Network Benefits
Conclusion
A. The Bitcoin Whitepaper by Satoshi Nakamoto
Bitcoin - A Peer-to-Peer Electronic Cash System
Introduction
Transactions
Timestamp Server
Proof-of-Work
Network
Incentive
Reclaiming Disk Space
Simplified Payment Verification
Combining and Splitting Value
Privacy
Calculations
Conclusion
References
License
B. Transaction Script Language Operators, Constants, and Symbols
C. Bitcoin Improvement Proposals
D. Segregated Witness
Why Segregated Witness?
How Segregated Witness Works
Soft Fork (Backward Compatibility)
Segregated Witness Output and Transaction Examples
Pay-to-Witness-Public-Key-Hash (P2WPKH)
Wallet construction of P2WPKH
Pay-to-Witness-Script-Hash (P2WSH)
Differentiating between P2WPKH and P2WSH
Upgrading to Segregated Witness
Embedding Segregated Witness inside P2SH
Pay-to-Witness-Public-Key-Hash inside Pay-to-Script-Hash
Pay-to-Witness-Script-Hash inside Pay-to-Script-Hash
Segregated Witness addresses
Transaction identifiers
Segregated Witness’ New Signing Algorithm
Economic Incentives for Segregated Witness
E. Bitcore
Bitcore’s Feature List
Bitcore Library Examples
Prerequisities
Wallet Examples using bitcore-lib
F. pycoin, ku, and tx
Key Utility (KU)
Transaction Utility (TX)
G. Bitcoin Explorer (bx) Commands
Examples of bx Command Use
Index
← Prev
Back
Next →
← Prev
Back
Next →