– Let’s talk about payment channels. So if you’ve been keeping up with the Bitcoin news cycle you would’ve heard about something called BIP 91 locking in and that being kind of the savior in terms of Bitcoin scaling. You can think of this event as really just the Bitcoin network coming together and agreeing that Segregated Witness is gonna be something that gets activated on the Bitcoin network.
And I high recommend you go and check out my other video about Bitcoin scaling which kind of explains how Segregated Witness will help Bitcoin scale into the future by reducing the size of transactions. But another thing that people are kind of banking on when they talk about SegWit enabling scale for Bitcoin is something called payment channels. Specifically in Bitcoin world, something called the Lightning Network.
Если Вам понравилось видео — поделись с друзьями:
Now I wanna clarify that the Lightning Network is simply a specification for a certain type of payment channel that will exist on Bitcoin, but there’s also other types of payment channels. There’s something called the Raiden Network, which would bring similar functionality to Ethereum. The Lightning Network itself and payment channels were actually possible without SegWit, but without it they were less than ideal. The reason for that is something called transaction malleability. In a nutshell, transaction malleability means that somebody broadcasting a transaction that you signed could potentially tamper with the contents of that transaction.
SegWit allows you to put those malleable pieces of the transaction into something called the witness and then segregate it, so there’s no way that a malicious node or miner could in any way change the contents of that transaction. So understanding that SegWit essentially enables usable payment channels, I wanted to spend today kind of going through what a payment channel is, how it works, how it relates to Bitcoin, and what it might mean for the future. Before we dive into payment channels and Lightning specifically, we need to talk about how transactions are signed and then broadcast across the Bitcoin network today.
I’ve explained this briefly in a previous video which I’ll link below, but the crux of it is that I have my public and my private key. There private key being the thing that I’m able to use to unlock those funds. So when Alice wants to send Bob one Bitcoin, she’s building a transaction that takes inputs that are in her previous wallet and says send them to Bob. She builds this transactions and then she signs it with her private key, basically authorizing that transaction to be valid and people can verify that anywhere in the future. But at that point, Alice has just created and signed that transaction, the rest of the network has no idea about it. And the rest of the network won’t know about it until she broadcasts it out to her peers and then it eventually gets mined and put into a block.
So basically offline, people are creating and signing these transactions all the time and it’s not until they broadcast them to the peer to peer network and then a miner eventually picks them up, which the network in aware of them and they get written into that immutable block chain. And this fundamental work flow is really important to understand in the context of the Lightning Network because the Lightning Network and payment channels are really just Bitcoin. They’re just those transactions, except you never broadcast them. You just share them with another peer. So let’s break that down a little bit.
The magic that actually makes payment channels kind of possible is something called multisig transactions and many of you are probably familiar with these, but rather than me just signing a transaction and that’s the only authorization that is needed, multisig transaction can require multiple people having to sign something before it can be authorized and then validated by the network and there’s all sorts of cool combinations you can do here.
You can say that we want two out of three people or three out of four or four out of seven people having to sign, and this actually lets you create these mini kind of contracts within Bitcoin today. But for Lightning and payment channels, we’re just gonna use what’s called the two of two multisig. And it’s really simple. It basically requires that both parties in this relationship sign with their private keys before money can be moved out of an address. And so let’s talk about how Alice and Bob would go ahead and create a bidirectional payment channel using multisig. So Alice and Bob know that they need to transact regularly between one another.
So they create a multisig address and they both put in 0.5 of a Bitcoin. So Alice sends 0.5 of a Bitcoin in and Bob sends 0.5 of a Bitcoin in. That payment channel is now worth, in tota, one Bitcoin. And to do anything with the funds that are stored in that payment channel, both Alice and Bob both have to sign with their private keys to move things around. And so in the world in payment channels, these two parties coming together to send money into this multisig address is called opening a payment channel. And these amounts that they put in are called commitments, and at this point, all of this activity is actually taking place on-chain, so it’s happening on the Bitcoin network, we’re actually sending this transactions and incurring the transaction fees that go along with them.
And that’s essentially all a payment channel is, is two parties coming together and committing a certain amount, and they can then transact with one another but they both have to sign in order to change the state of that payment channel. So another thing that’s important to know is that the only time you actually ever have to do on-chain transactions is when you’re opening the channel, i.e., both Alice and Bob putting in that 0.5 Bitcoin and when you close it, so that the two parties can then redeem the bitcoin out of that channel.
And this is the core concept behind why a Lightning Network is said to be the scaling solution for Bitcoin, because only those two times, the opening and the closing of the channel, are the times you’re actually having to interact with the Bitcoin network. And so the opening and the closing of the channel are the only two times you actually have to pay the transaction fees which go to the miners who are gonna pick up that transaction and write it into the block chain. And this is where things start to get really, really cool. Once Alice and Bob both have that 0.5 Bitcoin and 0.5 Bitcoin in there, adding up to a total of one Bitcoin for the whole payment channel, they can go ahead and create and sign multiple transactions about the ownership of that one Bitcoin between the two of them. So for example, Bob might say, “I’m actually gonna give you 0.2 of the 0.5 that I had.”
So now the payment channel is still worth one Bitcoin, but Alice has 0.7 Bitcoin and Bob only has 0.3. They can create and sign these transactions but instead of broadcasting them to the network, they just share them with one another. And because of the cryptopography used in that multisig agreement that they had, in order to sign and verify a transaction so that it would ever be valid back on the actual network, both of them have to sign with their private keys.
So over the space of months, they could actually create transactions as long as they’re both signing them every time. And they can create 10s, 20, 30 transactions, but just share them with one another and as they’re both signing with their private keys and this multisig agreement, it invalidates the old state of the channel and makes it so the current state is true. So if they were to broadcast the last transaction back to the network in some way, that payment channel would be closed. And whatever balance they’d agreed on over the space of that month, that then gets written back into the block chain as the new distribution of that one Bitcoin between the two parties.
But whereas Alice and Bob both locked in 0.5 Bitcoin, 0.5 Bitcoin, to a total of one, the balances might have changed so that when the payment channel is closed, Alice has 0.7 and Bob has 0.3. And so you can see where the scale starts to come in here. Because those transactions between those two parties are essentially happening privately, you never have to pay the fee or wait for confirmations of any of that stuff that happens when you’re trying to put it into the Bitcoin block chain. There are essentially no fees and there’s also no block size to worry about.
The throughput is just limited by your ability to have a peer to peer relationship with that other person you’re working with. Alice and Bob just need to have a way of communicating with one another in realtime. And another cool thing is that if Alice and Bob started as friends and then were transacting for a while, but eventually got to a point where they had a falling out and they’re no longer on good terms, it doesn’t really matter, because every time they updated the state of that channel, i.e., the distribution that one Bitcoin, they both signed it with their private keys in that multisig agreement.
If Alice no longer wants to do business with Bob and wants to close the payment channel, she can simply broadcast the last transaction that they both agreed on back to the Bitcoin network and redeem her Bitcoin. It’s not locked away and there’s no way that Bob can run off with the money. And I think it’s really important to understand this core concept because the Lightning Network is just Bitcoin. The only difference is that parties that have a relationship with one another don’t always need to broadcast every single transaction between the two of them back to the Bitcoin block chain. In a way doing so is actually kind of wasteful.
If I’m just transacting and changing a balance of one Bitcoin back and forth between two people, why does the block chain need to know about that necessarily? And this really helps to answer the question also that I get a lot where people say, “Well if we have the Lightning Network “and it scales to 40,000 transactions per second” or some crazy amount like that, why do we need Bitcoin?” And the answer is because the Lightning Network is Bitcoin. It’s just Bitcoin where you’re not putting everything on the block chain. You’re still cryptographically signing the transactions, but sharing them privately with the individuals that are taking part in the transaction. And so that concept covers two people that are transacting with on another.
The use case of it might be if I have a friend that I know I’m gonna be transacting regularly with, we’ll open up a payment channel for a sizeable enough amount, and then we can send money back and forth to one another with no transaction fees and it never has to hit the Bitcoin network. The next obvious question is, well how does this facilitate transactions between a large group of people? So if I wanna send money to somebody on the other side of the world who I don’t currently have an open payment channel with, can I? And the answer is yes, probably. Think of this as kind of that six degrees of separation thing.
I might not have a channel open with that person on the other side of the world, but there’s a chance that my friend, who I do have an open payment channel with does. Or maybe a friend of a friend of a friend has a payment channel open with the person I’m trying to send money to. And so as long as there’s a route from me to the other person, through these payment channels that I have previously set up, then money can make its way across that route. An example to illustrate this would be that Alice wants to send money back and forth with Bob, but unfortunately Alice and Bob don’t have an existing payment channel set up, and they don’t wanna create a new payment channel because that would involve paying a transaction fee on the Bitcoin network and getting everything set up with the commitments.
So Alice and Bob don’t have a connection to one another, but they do have a connection with somebody called David. Alice already has a payment channel with David, and so does Bob. And so as long as those existing payment channels will facilitate the amount of money that Alice and Bob wanna send back to one another, then they can actually send that money through David. Now the challenge here is how do you do this in a trustless way, where you can trust David to be kind of this intermediary between the two of you. And you have to think, this is a very simple example, in the future it might not just be David you’re going through as an intermediary, there might be 20 hops that you have to take before you’re actually getting to the person that you finally wanna transact with.
So there’s a lot of people there that you have to trust to do the right thing. And so the way that the Lightning Network does this is through something called Hashed TimeLock Contracts, and so the simplest way to explain this is that Alice and Bob both give David basically a countdown, a time in which he has to cryptographically prove that a payment was made or received before that deadline, otherwise the money just gets refunded to the last person so it gets back to the previous owners or the person trying to send it. And so really in a nutshell, that’s all the payment channel is. That’s all the Lightning Network is. It’s a bunch of people with these two way contracts that they sign every time they want to change the state of.
And it’s a network of these people, transacting with one another to find routes to pay each other. And you can see how this has a bunch of benefits, because the only time you’re actually putting a transaction on to the Bitcoin block chain and paying the transaction fees is when you open or close a channel, if you keep a channel open for a long period of time, then you can basically send unlimited transactions back and forth with somebody with very minimal to zero transaction cost. And because you’re just cryptographically signing this two of two transaction every time you wanna change the state of the payment channel, payments are settled instantly.You don’t have to wait 10 minutes for the next Bitcoin block to be mined and written into history.
So if this network works, and people start using it and there’s enough viability in these linked wallets and these routes between people, then this could be a very viable solution to scaling Bitcoin. In a way that we’re not actually writing transactions to the Bitcoin block chain anymore, it’s a bunch of private wallets interacting with one another, and only touching the Bitcoin block chain when you wanna pull the money out of that channel. And there’s current implementations of this that people can go and start using once SegWit locks in.
On Litecoin actually, which already has SegWit activated, there’s a running test then I believe for the Lightning Network. So this stuff is definitely on the horizon and I’ve seen some wallets and other pieces of technology around this start to pop up. So over the next six to 12 months, I think this technology is definitely gonna be relatively mainstream, but that’s not to say that the Lightning Network or payment channels are perfect. There’s definitely some drawbacks and challenges that this technology faces.
The first big issue is that offline payments aren’t really supported. Because every time you wanna change the state of a payment channel, the two parties have to sign that transaction, that multisig transaction we talked about, those wallets or those clients essentially have to be talking to one another in realtime. So if a person that you have a payment channel with goes offline and you can’t contact them and they can’t sign to change the state, then your money is kind of stuck in there at the current state of the channel.
The other potential issue is that because the channel can be closed by sending previous transactions back to the Bitcoin network, that means that these clients actually have to be monitoring the Bitcoin block chain at all times to make sure that their private transactions aren’t actually being transmitted and broadcast back to the Bitcoin network. Basically in order to make sure you can keep trusting this person you have a channel open with, you need to constantly be monitoring the status of the Bitcoin block chain and making sure there’s no funny business going on. And the other big challenge is that it’s not actually very good for large transactions.
If you’re relying on these routes that hop multiple people that have existing payment channels open, the amount that you can send to the person at the other end is entirely limited by how large those payment channels are. And so in that Alice, Bob, and then David linking the two situation that I discussed, if Alice and Bob only have payment channels open for say 0.2 of a Bitcoin with David, then that’s the maximum they can actually send to one another through that route.
You can’t magically send one Bitcoin across a payment channel that’s only currently worth 0.2 Bitcoin. And so in that case, Alice and Bob would actually have to open up a new payment channel in order to send money to one another, and if they’re opening another payment channel, which has to happen on the chain anyway, then why wouldn’t they just send the Bitcoin to one another using the traditional on-chain method? Because of this large payment routing issue, the Lightning Network’s specification actually limits payments to 0.04 something of a Bitcoin, which is relatively small really. So for that reason, it’s going to be very interesting to see the real use cases of the Lightning Network.
I guess it could kinda work if people are doing micro transactions between one another, or maybe you have a payment channel open with your local coffee shop, and you transact that way. But getting back to that always online problem, obviously things like Lite Wallets on mobile, or even the desktop really, or web services, aren’t going to have the ability to be constantly monitoring the block chain, and keeping a realtime connection open with all of their peers. And so a lot of people are predicting that what’s gonna happen is these centralized hubs are gonna open up and they’ll offer essentially a Lightning Node as a service, which essentially acts as a hub, and your way to interact with other people on the Lightning Network.
Now in earlier iterations of the Lightning Network, there was talk about this hub and spoke kind of model where you had essentially these large credit unions, which would run a service, and people would interact with it. And then that hub was basically your David in the previous example I gave. They are the ones that are connecting with multiple hundreds of thousands of people with these open payment channels, and you’re simply using that hub to then send to another person that’s connected to that same hub.
The problem with this, and I think the reason the Lightning team moved away from that hub and spoke model, is there is some form of centralization there. If you think about it, if you wanna open a channel that’s bidirectional, i.e. you’re sending money back and forth, the person opening that hub has to have a lot of capital in order to start those payment channels. Say for every user, you wanted to open a payment channel that’s worth $500 bidirectionally so you can send money back and forth, if you have 1,000 users using that hub, that hub actually has to commit $50,000 worth of Bitcoin in order to keep these payment channels open.
So basically the ability to run one of these hubs, or these kind of Lightning Nodes as a service becomes exclusionary for the smaller players. And I think what we’ll see is existing services that have a lot of money, things like exchanges or mining pools, start setting up these hubs and operating. The only problem there is again, it’s kind of a form of centralization sadly. It does mean that it’s gonna scale way better, but if it’s centralized, then is that a trade off that the Bitcoin network and its users are willing to make.
My kind of personal opinion on this is that there are potential use cases for payment channels, I think we just haven’t fully realized them yet. And I’m not sure if necessarily those use cases are going to be aligned with the way that people are using Bitcoin today. But it might be for other things, like micro transactions, recurring transactions that you have with somebody on a regular basis and it makes sense to have a payment channel open for a long period of time, because the whole kind of benefit of the Lightning Network goes away if you’re constantly opening and closing channels all the time and essentially creating transactions on-chain every time you do that.
If you’re still writing transactions to the block chain and having to pay the transaction fees, then the benefit of the Lightning Network kinda goes away. You have to have these payment channels open for a long period of time to kind of reap the benefit of that network. So that’s kind of my simplified breakdown of what a payment channel is, what Lightning does. There’s obviously a lot more to it technically, and I’ll try and link to some resources where you can go and read more about it.
But with Segregated Witness hopefully activating in the next month, I think we’re gonna be hearing a lot more about this technology and start to see wallets supporting it, potentially exchanges supporting it in the future as an alternative to sending on-chain transactions. I hope you found this video useful and it explained payment channels in kind of an easy to understand way. As always, if you like the video, please like and subscribe. I’m trying to produce these videos on a weekly basis, and always open to topic suggestions in the comments below. Again, thanks for watching, I hope you found this useful and I’ll see you next time.