Chapter 7. Payment Channels

In this chapter we will dive into payment channels and see how they are constructed. We will start with Alice’s node opening a channel to Bob’s node, building on the examples presented in the beginning of this book.

The messages exchanged by Alice and Bob’s nodes are defined in “BOLT #2: Peer Protocol for Channel Management”. The transactions created by Alice and Bob’s nodes are defined in “BOLT #3: Bitcoin Transaction and Script Formats”. In this chapter we are focusing on the “Channel open and close” and “Channel state machine” parts of the Lightning protocol architecture, highlighted by an outline in the center (peer-to-peer layer) of Figure 7-1.

Payment channels in the Lightning protocol suite
Figure 7-1. Payment channels in the Lightning protocol suite

A Different Way of Using the Bitcoin System

The Lightning Network is often described as a “Layer 2 Bitcoin Protocol,” which makes it sound distinct from Bitcoin. Another way to describe Lightning is as a “smarter way to use Bitcoin” or just as an “application on top of Bitcoin.” Let’s explore that.

Historically, Bitcoin transactions are broadcast to everyone and recorded on the Bitcoin blockchain to be considered valid. As we will see, however, if someone holds a presigned Bitcoin transaction that spends a 2-of-2 multisig output that gives them the exclusive ability to spend that Bitcoin, they effectively own that Bitcoin even if they don’t broadcast ...

Get Mastering the Lightning Network now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.