Lightning for Builders Foundations

Introduction: why the Lightning Network exists

Bitcoin settles; Lightning moves. What problem Lightning solves, how it keeps Bitcoin's trust model, and what it costs you in return.

15 minBeginner1 / 17

Draft: this lesson is still waiting for review.

What you'll learn

  • Explain why Bitcoin alone struggles with small, frequent payments
  • Describe Lightning as payment channels on top of Bitcoin, without a trusted middleman
  • Name two things Lightning asks of its users in return

Key terms

Lightning Network (mtandao wa Lightning)
A network on top of Bitcoin for fast payments with very small fees.
channel (chaneli)
A payment link between two Lightning nodes, locked by a Bitcoin transaction.
block (bloku)
A batch of transactions added to the blockchain about every 10 minutes.
fee (ada)
A small amount you pay to get your transaction into a block or routed over Lightning.

Bitcoin adds a block about every ten minutes, and each block has limited space. When many people want to pay at once, the fees rise. That is fine for saving or for large payments, but nobody wants to wait ten minutes and pay a big fee for a cup of tea.

Payment channels

The Lightning Network fixes this with payment channels. Two people lock some bitcoin into a shared output on the blockchain once. After that, they can pay each other thousands of times by exchanging signed messages, without touching the blockchain at all. When they are done, they close the channel and the final balance is written on-chain.

Channels link up. If Alice has a channel with Bob, and Bob has one with Chan, Alice can pay Chan through Bob, and Bob can't steal the money on the way. That network of channels is the Lightning Network.

What stays the same

Lightning doesn't add a bank or a company in the middle. Every channel is enforced by Bitcoin's own rules: if someone cheats, the other side can prove it on-chain and take the funds. You keep your own keys.

What Lightning asks of you

  • Be online. Your node has to watch the blockchain so nobody closes a channel with an old balance. (Watchtowers can do this for you.)
  • Manage liquidity. You can only send what is on your side of a channel, and only receive what is on the other side.
  • Accept some complexity. Channels open, close and need balancing. This path teaches how.

Meet the lab

This path follows Mastering the Lightning Network, and its characters live on your laptop: Alice, Bob, Chan and Dina, four real Lightning nodes on a private test network. From the next lesson you'll give them commands and watch payments move.

Reflect

Write your answer down, or talk it over with a friend or your chama.

  1. Which of your daily payments would you never make on-chain, and why?
  2. What does it mean for a payment system to be 'trustless', and is Lightning fully trustless?

Check yourself

Question 1 of 4Why are small everyday payments hard to make directly on-chain?

Further reading

Adapted from Mastering the Lightning Network. Andreas M. Antonopoulos, Olaoluwa Osuntokun and René Pickhardt. Licence: CC BY-SA 4.0.