== Third Edition Changes === 1. Introduction * Bitcoin Uses, Users, and Their Stories Minor changes to the stories, updating to reflect current common uses and current price === 2. How Bitcoin Works * Buying a [line-through]#Cup of Coffee# Laptop Updated Alice and Bob's story. Buying a cup of coffee is no longer sensible "on-chain", due to the value of Bitcoin and on-chain fees. Instead, small retail purchases are now a use-case for the Lightning Network. In the updated story, Alice is buying a laptop from an e-commerce store run by Bob. * Bitcoin Transactions Updated all the transactions to use native-Segwit addresses that start with "bc1", instead of legacy bitcoin addresses that start with "1". * 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 * 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 * 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 * PHP * Python * Ruby * Go * Rust * C# * Objective-C === 4. Keys, Addresses * Introduction * Public Key Cryptography and Cryptocurrency * Private and Public Keys * Private Keys * Public Keys * Elliptic Curve Cryptography Explained * Generating a Public Key * Bitcoin Addresses * Base58 and Base58Check Encoding * Key Formats * Implementing Keys and Addresses in C++ * Implementing Keys and Addresses in Python * Advanced Keys and Addresses * Encrypted Private Keys (BIP-38) * Pay-to-Script Hash (P2SH) and Multisig Addresses * Vanity Addresses * 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) * Creating an HD Wallet from the Seed * Using an Extended Public Key on a Web Store === 6. Transactions * Introduction * Transactions in Detail * Transactions—Behind the Scenes * Transaction Outputs and Inputs * Transaction Outputs * Transaction Inputs * Transaction Fees * Adding Fees to Transactions * Transaction Scripts and Script Language * Turing Incompleteness * Stateless Verification * Script Construction (Lock + Unlock) * Pay-to-Public-Key-Hash (P2PKH) * Digital Signatures (ECDSA) * How Digital Signatures Work * Verifying the Signature * Signature Hash Types (SIGHASH) * ECDSA Math * The Importance of Randomness in Signatures * *NEW: Schnorr Signatures* * Bitcoin Addresses, Balances, and Other Abstractions === 7. Advanced Transactions And Scripting * Introduction * Multisignature * Pay-to-Script-Hash (P2SH) * P2SH Addresses * Benefits of P2SH * Redeem Script and Validation * Data Recording Output (RETURN) * Timelocks * Transaction Locktime (nLocktime) * Check Lock Time Verify (CLTV) * Relative Timelocks * Relative Timelocks with nSequence * 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 * Segregated Witness * Why Segregated Witness? * How Segregated Witness Works * Soft Fork (Backward Compatibility) * Segregated Witness Output and Transaction Examples * Upgrading to Segregated Witness * Segregated Witness’ New Signing Algorithm * Economic Incentives for Segregated Witness * *NEW: Segwit v1: Taproot* * *NEW: MAST * * *NEW: Tapscript* * *NEW: Taproot * === 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 * NEW Neutrino * NEW Compact Blocks * 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 * Segnet—The Segregated Witness Testnet * Regtest—The Local Blockchain * *NEW: Signet - The POA Test 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 * Consensus Attacks * Changing the Consensus Rules * Hard Forks * Hard Forks: Software, Network, Mining, and Chain * Diverging Miners and Difficulty * Contentious Hard Forks * Soft Forks * Criticisms of Soft Forks * Soft Fork Signaling with Block Version * BIP-34 Signaling and Activation * BIP-9 Signaling and Activation * NEW BIP-8 Activation * *NEW: Speedy Trial 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 === B. Transaction Script Language Operators, Constants, And Symbols === C. Bitcoin Improvement Proposals === D. Bitcore === E. Pycoin, Ku, And Tx === F. Bitcoin Explorer (Bx) Commands === *NEW: BTCD*