Chapter 9. Channel Operation and Payment Forwarding

In this chapter we will bring together payment channels and hash time-locked contracts (HTLCs). In Chapter 7, we explained the way Alice and Bob construct a payment channel between their two nodes. We also looked at the commitment and penalty mechanisms that secure the payment channel. In Chapter 8, we looked at HTLCs and how these can be used to route a payment across a path made of multiple payment channels. In this chapter we bring the two concepts together by looking at how HTLCs are managed on each payment channel, how the HTLCs are committed to the channel state, and how they are settled to update the channel balances.

Specifically, we will be discussing “Adding, settling, failing HTLCs” and the “Channel state machine” that form the overlap between the peer-to-peer layer and the routing layer, as highlighted by an outline in Figure 9-1.

Channel operation and payment forwarding in the Lightning protocol suite
Figure 9-1. Channel operation and payment forwarding in the Lightning protocol suite

Local (Single Channel) Versus Routed (Multiple Channels)

Even though it is possible to send payments across a payment channel simply by updating the channel balances and creating new commitment transactions, the Lightning protocol uses HTLCs even for “local” payments across a payment channel. The reason for this is to maintain the same protocol design regardless of whether a payment is only one hop (across ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.