Book description
The Lightning Network (LN) is a rapidly growing second-layer payment protocol that works on top of Bitcoin to provide near-instantaneous transactions between two parties. With this practical guide, authors Andreas M. Antonopoulos, Olaoluwa Osuntokun, and Rene Pickhardt explain how this advancement will enable the next level of scale for Bitcoin, increasing speed and privacy while reducing fees.
Ideal for developers, systems architects, investors, and entrepreneurs looking to gain a better understanding of LN, this book demonstrates why experts consider LN a critical solution to Bitcoin's scalability problem. You'll learn how LN has the potential to support far more transactions than today's financial networks.
This book examines:
- How the Lightning Network addresses the challenge of blockchain scaling
- The Basis of Lightning Technology (BOLT) standards documents
- The five layers of the Lightning Network Protocol Suite
- LN basics, including wallets, nodes, and how to operate one
- Lightning payment channels, onion routing, and gossip protocol
- Finding paths across payment channels to transport Bitcoin off-chain from sender to recipient
Publisher resources
Table of contents
-
Preface
- Intended Audience
- Conventions Used in This Book
- Code Examples
- Using Code Examples
- References to Companies and Products
- Addresses and Transactions in This Book
- O’Reilly Online Learning
- How to Contact Us
- Acknowledgments by Andreas
- Acknowledgments by René
- Acknowledgments by Olaoluwa Osuntokun
- Contributions
- Sources
- I. Understanding the Lightning Network
- 1. Introduction
-
2. Getting Started
- Alice’s First Lightning Wallet
- Lightning Nodes
- Lightning Explorers
- Lightning Wallets
- Balancing Complexity and Control
- Downloading and Installing a Lightning Wallet
- Creating a New Wallet
- Loading Bitcoin onto the Wallet
- From Bitcoin to Lightning Network
- Buying a Cup of Coffee Using the Lightning Network
- Conclusion
-
3. How the Lightning Network Works
- What Is a Payment Channel?
- Payment Channel Basics
- Routing Payments Across Channels
- Payment Channels
- Invoices
- Delivering the Payment
- Source-Based Pathfinding
- Peer-to-Peer Communication Encryption
- Thoughts About Trust
-
Comparison with Bitcoin
- Addresses Versus Invoices, Transactions Versus Payments
- Selecting Outputs Versus Finding a Path
- Change Outputs on Bitcoin Versus No Change on Lightning
- Mining Fees Versus Routing Fees
- Varying Fees Depending on Traffic Versus Announced Fees
- Public Bitcoin Transactions Versus Private Lightning Payments
- Waiting for Confirmations Versus Instant Settlement
- Sending Arbitrary Amounts Versus Capacity Restrictions
- Incentives for Large Value Payment Versus Small Value Payments
- Using the Blockchain as a Ledger Versus as a Court System
- Offline Versus Online, Asynchronous Versus Synchronous
- Satoshis Versus Millisatoshis
- Commonality of Bitcoin and Lightning
- Conclusion
- 4. Lightning Node Software
- 5. Operating a Lightning Network Node
- II. The Lightning Network in Detail
- 6. Lightning Network Architecture
-
7. Payment Channels
- A Different Way of Using the Bitcoin System
- Bitcoin Ownership and Control
- Constructing a Payment Channel
-
Constructing the Channel
- Peer Protocol for Channel Management
- Channel Establishment Message Flow
- The Funding Transaction
- Generating a Multisignature Address
- Constructing the Funding Transaction
- Holding Signed Transactions Without Broadcasting
- Refund Before Funding
- Constructing the Presigned Refund Transaction
- Chaining Transactions Without Broadcasting
- Solving Malleability (Segregated Witness)
- Broadcasting the Funding Transaction
- Sending Payments Across the Channel
- The Commitment Transaction
- Advancing the Channel State
- Closing the Channel (Cooperative Close)
- Conclusion
- 8. Routing on a Network of Payment Channels
- 9. Channel Operation and Payment Forwarding
-
10. Onion Routing
- A Physical Example Illustrating Onion Routing
- Introduction to Onion Routing of HTLCs
- Wrapping the Onion Layers
-
Sending the Onion
- The update_add_htlc Message
- Alice Sends the Onion to Bob
- Bob Checks the Onion
- Bob Generates Filler
- Bob De-Obfuscates His Hop Payload
- Bob Extracts the Outer HMAC for the Next Hop
- Bob Removes His Payload and Left-Shifts the Onion
- Bob Constructs the New Onion Packet
- Bob Verifies the HTLC Details
- Bob Sends the update_add_htlc to Chan
- Chan Forwards the Onion
- Dina Receives the Final Payload
- Returning Errors
- Keysend Spontaneous Payments
- Conclusion
- 11. Gossip and the Channel Graph
- 12. Pathfinding and Payment Delivery
- 13. Wire Protocol: Framing and Extensibility
- 14. Lightning’s Encrypted Message Transport
- 15. Lightning Payment Requests
-
16. Security and Privacy of the Lightning Network
- Why Is Privacy Important?
- Definitions of Privacy
- Process to Evaluate Privacy
- Anonymity Set
- Differences Between the Lightning Network and Bitcoin in Terms of Privacy
- Attacks on Lightning
- Cross-Layer De-Anonymization
- Lightning Graph
- Centralization in the Lightning Network
- Economic Incentives and Graph Structure
- Practical Advice for Users to Protect Their Privacy
- Unannounced Channels
- Routing Considerations
- Conclusion
- References and Further Reading
- 17. Conclusion
- A. Bitcoin Fundamentals Review
- B. Docker Basic Installation and Use
- C. Wire Protocol Messages
- D. Sources and License Notices
- Glossary
- Index
- About the Authors
Product information
- Title: Mastering the Lightning Network
- Author(s):
- Release date: November 2021
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781492054863
You might also like
book
Bitcoin and Lightning Network on Raspberry Pi: Running Nodes on Pi3, Pi4 and Pi Zero
Compile and run Bitcoin full nodes, lightning nodes, and user-friendly web-apps that help abstract the complexities …
article
From ChatGPT to HackGPT: Meeting the Cybersecurity Threat of Generative AI
Emerging generative AI technologies such as ChatGPT are putting new tools in the hands of hackers. …
video
The Complete 2020 Ethereum and Solidity Developer Bootcamp
The Complete 2020 Ethereum & Solidity Developer Bootcamp is for anyone who wants to get started …
book
Introducing Blockchain Applications: Understand and Develop Blockchain Applications Through Distributed Systems
Deepen your understanding of blockchain technology and develop your own blockchain applications. This book provides a …