Lightning
Lightning for Builders
All 17 chapters of Mastering the Lightning Network, simplified, with a live lab on your laptop.
Run real Lightning nodes on regtest: create invoices, open channels, route payments, and dig into HTLCs, onions and the network graph, with the book's commands and Python. Needs a laptop with Docker.
17 lessons, 600 min
StartFoundations
- 1Introduction: why the Lightning Network existsBitcoin settles; Lightning moves. What problem Lightning solves, how it keeps Bitcoin's trust model, and what it costs you in return.15 minBeginnerReadingQuiz
- 2Getting started: your lab and your first paymentStart the four-node lab on your laptop, connect it to this page, and make Dina's first invoice and Alice's first payment.40 minBeginnerReadingQuizLabRead first: Introduction: why the Lightning Network exists
- 3How the Lightning Network worksOpen a channel yourself, confirm it on-chain, and pay through it, to see the three moves every channel makes: open, update, close.45 minBeginnerReadingQuizLabRead first: Getting started: your lab and your first payment
Nodes
- 4Lightning node softwareLND, c-lightning and Eclair all speak the same protocol but feel different to use. Ask all three the same question.30 minIntermediateReadingQuizLab
- 5Operating a Lightning Network nodeRunning a node is a job: set the fees you charge for routing, back up your channels, and know what to watch.35 minIntermediateReadingQuizLabRead first: How the Lightning Network works
Inside Lightning
- 6Lightning Network architectureA map of the whole protocol, layer by layer, so every later lesson has a place to fit.20 minIntermediateReadingQuiz
- 7Payment channelsLook inside a real channel: find its funding transaction on-chain and see how commitment transactions and revocation keep both sides honest.40 minIntermediateReadingQuizLabRead first: How the Lightning Network works
- 8Routing on a network of payment channelsHow Alice pays Dina through two strangers without trusting either: hash time-locked contracts, step by step, then a real two-hop payment.45 minIntermediateReadingQuizLabRead first: Payment channels
- 9Channel operation and payment forwardingTwo ways to end a channel: a cooperative close that settles at once, and a force close where the time lock makes you wait. Do both.40 minIntermediateReadingQuizLabRead first: Routing on a network of payment channels
The network
- 10Onion routingHow each node on a route learns only its neighbours: build and peel a toy onion in Python, then compare it with the real Sphinx format.45 minIntermediateReadingQuizLabRead first: Routing on a network of payment channels
- 11Gossip and the channel graphHow every node learns the map of the network from its peers, and what that map contains. Read Alice's graph in Python.35 minIntermediateReadingQuizLab
- 12Pathfinding and payment deliveryWrite your own route finder over Alice's real channel graph, then see why real nodes also learn from failed attempts and split large payments.50 minIntermediateReadingQuizLabRead first: Gossip and the channel graph
Protocol
- 13Wire protocol: framing and extensibilityWhat a Lightning message looks like as bytes, how TLV fields let the protocol grow, and why feature bits follow the 'it's OK to be odd' rule. Parse a real init message.40 minIntermediateReadingQuizLab
- 14Lightning's encrypted message transportEvery peer link is encrypted and authenticated with the Noise protocol before a single Lightning message flows. What the handshake does, and what your node's connections look like.25 minIntermediateReadingQuizLab
- 15Lightning payment requestsTake an invoice apart: the human-readable part that holds the amount, the tagged fields inside, and the signature. Write a decoder for the amount.35 minIntermediateReadingQuizLab
Security and next steps
- 16Security and privacy of the Lightning NetworkWhat an attacker can learn or break: probe a route's hidden balance yourself, then survey jamming, fee attacks and the defences.45 minIntermediateReadingQuizLabRead first: Routing on a network of payment channels
- 17Conclusion: what to build nextYou have run every layer of Lightning yourself. Where the protocol is heading, and how to turn what you learned into a tool people use.15 minIntermediateReadingQuiz
What's next
Finish the final project, then show your PR to the Bitsacco community for feedback and mentoring.