A Simplified Explanation of Bitcoin’s Lightning Network: Side Bets in a Poker Game

Much like using the internet hasn’t required almost any technical knowledge for some time, the same will occur for Bitcoin as entrepreneurs and developers create ways to simplify onboarding and use.  But we’re not there yet, and people who are introduced to Bitcoin need to have some degree of understanding of how it works to help prevent them from making bad decisions and losing their money.  Now that the Lightning Network is growing in use and popularity, people are also interested in learning something about it.  It’s important to have a simple way of explaining it to the newcomer in language he can easily grasp.

This is my offering of a basic qualitative overview of the Lightning Network.

Imagine sitting at a poker table with a bunch of other people.  At regular intervals, the dealer passes out cards for each hand, you and the other players make bets, everyone agrees who the winner of the hand is, and then the dealer moves the chips in the pot to the winner.  We can approximate this poker table and game to the Bitcoin network.  You and the players are nodes and each of your chip stacks are your bitcoins.  The dealer is the collection of miners.  They facilitate the movement of the chips among players with each hand like the way miners create blocks at ten-minute intervals to update the ledger. 

Everyone at the table, both the players and the dealer, agrees to the rules of the game.  If they couldn’t agree to the rules, none of this would work!  Everyone’s chip stack is viewable by everyone else, so if anyone tries to cheat by adding chips from his pocket, others would notice, call it out, and reject those chips in any bets.

Let’s say that you and some of the other players are degenerate gamblers and want a little more action.  The poker game is great, but the game doesn’t move along fast enough and you want to make some bets while you wait between hands.  A football game is on the TV in the room and Alice, the player sitting next to you, has been watching the game with you.  You and Alice want to make some bets on the football game, and you want to use poker chips to facilitate that.  But if you start flipping random chips from your stacks to each other, the other players might get anxious trying to keep track of that to make sure they can tell that neither of you are trying to cheat.

As a solution, you and Alice agree to open a betting channel between each other.  When the dealer clears a hand and moves the chips in the pot to the winner, you and Alice announce to everyone that each of you are setting aside a few chips, let’s say 10 each, for your side bets on the football game.  Now you and Alice can pass the chips in your channel back and forth whenever you want.  When the football game is over or you otherwise decide to be done betting on the game, you and Alice can close the channel, announcing to everyone what you’re doing when the dealer clears a hand.  If everyone sees that a total of 20 chips are being returned to your stacks, they know that no cheating against the poker game as occurred.  They don’t really care how much or how little the two of you bet in the time between that.  It has no effect on the poker game.

You and Alice each start with 10 chips in your channel, which you separate from the rest of your stacks.  As long as you have enough chips, each of you can put as many chips as you want in, but you might want to consider a few things.  If you lock up a lot of chips in your channel, then it limits how much you can play the poker game.  If you only lock up a few, then you might not have any chips left on your side of the channel after a bet or two.

With your fresh channel open with Alice, you’re ready to make a bet with her.  It’s 3rd and 6 for the home team in the football game.  You bet Alice 2 chips that they’ll make the first down on the next play.  They snap the ball, run a play, and gain 9 yards for the first down!  Alice slides over 2 chips, so the new state of the channel is 12 chips on your side and 8 on Alice’s.  This is fun.  You bet Alice that the next play will be a passing play.  You agree to bet 1 chip.  You’re wrong this time—the next play was a running play, so you slide 1 chip back to Alice.  Now you have 11 chips and Alice has 9. 

Bob and Charlie are sitting nearby and observe the fun that the two of you are having.  They decide that they want in on the action.  Bob opens a channel with Alice and Charlie opens a channel with you making three total channels in your little network.

Eventually the state of your channel with Charlie has 3 chips on your side and 9 on his.  You want to make a bet for 4 chips with him.  But you don’t have enough chips on your side of the channel!  You can’t make the bet.  You’re left with a few options.  You can not make any bets of more than 3 chips to Charlie or your can close the channel and open a new one with a new amount of chips on either side.  It’s kind of a pain, but you and everyone else in your network are still trying to figure out the best ways to work this stuff out.

Later in the football game, the teams line up for a field goal try and you say, “I bet 5 chips that they’re going to make this attempt!”  Alice and Charlie aren’t interested in taking the other side of that bet, but Bob perks up and says he’ll take it.  But there’s a problem: you don’t have a direct channel open to Bob.  The field goal attempt is about to happen, but the poker game is in the middle of a hand and won’t clear in time for you to open a channel with Bob.  That’s when you notice something: although you don’t have a channel open directly to Bob, you do have a channel open to Alice and Alice has a channel with Bob.  You can route your payment to Bob through Alice.  As long as you have 5 chips to send Alice and Alice has 5 chips to send to Bob (and vice versa in the case of this bet), the bet can go through just like any other channel.  Alice doesn’t mind doing this because she although she’s sending 5 chips to Bob, she’s going to get 5 chips from you, so it’s a wash for her.

They miss the field goal.  Alice routes the payment of the bet and everyone is happy.

This is powerful because as more people in the poker game join your “instant” betting network, you can interact with anyone if you’re at least indirectly connected to them.  This is useful because you don’t necessarily want to be tying up a lot of chips in a bunch of channels, but you want to access to as many other players in the network as possible, and consequently you’ll find a happy medium.  With a number of channels open, sometimes you will have a few different options for paths to send chips, so you’ll route through the shortest path.  For example, if you want to bet with Frank and there are two available routing paths to him, you’ll choose the one where you route through Charlie instead of routing through Alice, Dave, and Erin.

Remember when your bet with Charlie failed because you didn’t have enough chips left on your side of the channel?  Now that the network is bigger, you can do some interesting things to fix this without having to open and close channels through the dealer.  You can make a bet and send 3 chips to Charlie even if your channel to Charlie only has 1 chip on your side if you have other channels open to players that have paths to Charlie.  If you make that bet with Charlie and he wins, you can split up the payment between those channels.  In Bitcoin’s Lightning Network, this is called atomic multi-path (AMP) payments.

With that mention of Bitcoin, let’s return the discussion there.  The basics of your betting network at the poker table apply to the Lightning Network with a few different details.  The Lightning Network allows nodes to open and fund channels to make off-chain payments back and forth to each other instantly and extremely cheaply.  A payment can be sent for whatever reason; there doesn’t need to be a bet or some other arrangement where the payment has to be able to flow in one direction or the other (in other words, only one side of the channel needs to provide funds).  Also, the nodes that route payments are sent a small fee to incentivize them to provide the service; likewise, since opening and closing channels makes use of on-chain transactions, typical transaction fees are of course required.  Another important distinction is to remember that most of this activity is automated in the Lightning Network.  Users don’t have to manually look for indirect payment paths and choose the shortest one if the current channels make it possible.  Finally, when all of these operations are performed on the Lightning Network, it is all done without trust between parties and does not compromise security created by on the on-chain layer.

This was meant to be a brief introduction of the Lightning Network for someone who was just introduced to how the first layer of Bitcoin works.  A Bitcoin-specific explanation can be viewed at 10HoursofBitcoin.com.  The details of the Lightning Network can get very complicated very quickly and it is still in its very early stages.  New solutions are being worked on and added, so some patience might be required before it’s ready for mass adoption.  For example, at the time of this writing, the base atomic multi-path pull request has just been merged to the BOLT spec.  But that doesn’t make the Lightning Network any less exciting for what it can do for Bitcoin.

A special thanks is in order to my friend, Birdarchist, who suggested the idea of a poker game to describe the Lightning Network as I struggled to explain it to him.  I hope that the Lightning Network makes a lot more sense to you after reading this.