Blocktime

Episode 35: The Lightning Network: A Deep Dive into Bitcoin's Future

March 26, 2024 Blocktime Powered by Riot
Episode 35: The Lightning Network: A Deep Dive into Bitcoin's Future
Blocktime
More Info
Blocktime
Episode 35: The Lightning Network: A Deep Dive into Bitcoin's Future
Mar 26, 2024
Blocktime Powered by Riot

Unlock the transformative power of Bitcoin's Lightning Network with us on BlockTime as we gear up for the much-anticipated Bitcoin halving. With the market pulsing with renewed vigor, we're bringing you exclusive behind-the-scenes access to Riot Platform's Corsicana Facility. This episode isn't just about the halving; it's about understanding the backbone of Bitcoin's infrastructure and the revolutionary Lightning Network, set to redefine digital finance akin to credit cards.

Follow Blocktime on Twitter: https://twitter.com/BlocktimebyRiot
Follow Blocktime on YouTube: https://www.youtube.com/@RiotPlatforms/podcasts

Show Notes Transcript Chapter Markers

Unlock the transformative power of Bitcoin's Lightning Network with us on BlockTime as we gear up for the much-anticipated Bitcoin halving. With the market pulsing with renewed vigor, we're bringing you exclusive behind-the-scenes access to Riot Platform's Corsicana Facility. This episode isn't just about the halving; it's about understanding the backbone of Bitcoin's infrastructure and the revolutionary Lightning Network, set to redefine digital finance akin to credit cards.

Follow Blocktime on Twitter: https://twitter.com/BlocktimebyRiot
Follow Blocktime on YouTube: https://www.youtube.com/@RiotPlatforms/podcasts

Speaker 1:

Welcome back to Block Time, a podcast produced by Riot Platforms. So it's been an exciting couple of weeks, with the bull market seemingly fully back on, fully sending up. Only To the moon, baby To the moon. Yes, lots of euphoria, lots of volatility as well. So I'd encourage folks to be responsible and to approach it with eyes wide open. Don't just FOMO in, and there's going to be volatility going forward. But I think that we've turned the page on the bear market and now we'll see where it goes from here into the halving. Halving is next month, april 18th, I believe, or 19th around there. It can change a little bit, just depending on how fast the blocks come in and we'll actually have an event around the the halving. Uh, stay tuned on that. We'll get you more details. Um, in new york city, I believe, uh, and like a ball drop kind of thing well, I don't want to give everything away, but also, it's not, it's not set in stone yet.

Speaker 1:

And you know, I think that, for Riot specifically, I mean it's amazing timing, which is that we are going to be energizing the first parts of Corsicana as the halving happens and you know we're on full growth mode. Uh, in course of canada, I think, gabe, you're you're traveling a lot to course canada these days yeah, I've been back and forth quite a bit over the last couple months.

Speaker 2:

Um, we were actually there tuesday, wednesday of this weekend. We got to talk to some of the engineering and construction teams and they were walking us through what the plan was for energization. It's, uh, not as easy as just flipping a switch and turning miners on. It's like multiple days of turning switches and transformers and PDUs on. So it's a long process and we're pretty excited for it. We'll be putting out some content around that as well.

Speaker 1:

Yeah, I mean it's an industrial scale facility, so it is very different from just plugging in a computer at home.

Speaker 2:

Multiple days to turn on the power. It's pretty cool.

Speaker 1:

And we've got a great electrical engineering team, oh yeah.

Speaker 2:

They were explaining it to us. Luis Diaz was explaining it to us and it's like his understanding, his expertise in that field is so cool.

Speaker 1:

It is Glad to have him on our side.

Speaker 1:

Yeah, for sure, all right. So today we're going to talk about a topic that isn't really related to Riot in one regards, which is because it's Lightning and Riot is not a participant on the Lightning network, but it is very related to Riot in the sense that the Lightning Network builds on top of the Bitcoin network and each part of the Lightning Network ultimately is a Bitcoin transaction. So you might have heard about Lightning before and you might have questions about how it works. Today we're going to start by a high-level overview and then we're going to take a deep dive into what the mechanics of it are under the hood. Personally, I'm a huge fan of Lightning. I have been for a little while, although when it first came out I was skeptical. I think that's healthy you should always kind of be a little skeptical on something used on the radar but as it proved itself and as I further understood the technology, I got very excited about it, and in my previous role at Kraken, I was the product manager that worked with the software and design team there to ship lightning integration to our clients, and we'll kind of get into what that means a little bit. So what is Lightning?

Speaker 1:

Lightning can be thought of as a network of Bitcoin smart contracts and a protocol for updating these smart contracts as people move money around. These smart contracts as people move money around. And now you might say well, hold on, pierre. The Bitcoin network already enables people to move money around. Why do we need a secondary layer?

Speaker 1:

It really addresses two limitations of the Bitcoin network. The first is that, on average, a Bitcoin block comes out every 10 minutes. Right, so the Bitcoin miners, they're hashing as fast as they can, but the Bitcoin nodes are setting a difficulty level to slow down how often blocks get found, so that on average, there's only one every 10 minutes. And you know that's not necessarily ideal in some contexts, for example, if you're buying your coffee, you might not want to wait 10 minutes for the payment to settle before you can enjoy your latte. Common example there. But the other part of it too is that sometimes on the Bitcoin network there can be a lot of congestion network there can be a lot of congestion.

Speaker 1:

In a past episode we talked about the transaction fees and how, when due to the block size limit, which helps keep Bitcoin decentralized by keeping the cost of a Bitcoin node low, the flip side to that is that if there's a lot of demand for transactions, there's limited supply of block space, we see transaction fees spike up and they can be very volatile at times. Lightning enables you to sidestep those high transaction fees by opening up channels when fees are low and then closing them when fees are low, and in between those two points of time, fees can be volatile. And you wouldn't know, because your channel is not affected by those on-chain fees when you're sending and receiving payments over it. So, long story short, it's really about enabling fast and cheap payment routing and having kind of a network that is focused on payments, whereas the Bitcoin network might be thought of as more focused on big transactions that are about long-term savings.

Speaker 2:

I know this is premature and probably not the best analogy here, but could you think of Lightning Network as like the credit card of the Bitcoin network?

Speaker 1:

Okay, that's a great analogy. Yes, that is a perfect analogy, because we can think of the Bitcoin network of transactions that you know the miners work on. That's like it's essentially like wire transfers, right? Or the Fed actually has a settlement system within it, and so it's for those high-value transfers that are not at the retail level. And then, to your point, at the retail level, you use your Visa, your MasterCard, and those are high-velocity, low-value payments, although with inflation they're yeah, yeah, yeah.

Speaker 1:

But that's that's the right way to think about it, because it's also the case that you know, especially with a credit card, you pay off your credit card once a month, let's say hopefully. I mean, I try to. But that and that's kind of a way of thinking about lightning as well is that you know you would rebalance your lightning channels by doing a on-chain Bitcoin transaction, hopefully less than once a month, really, because these channels can last forever, and so, ideally, you set up your channels so that they can stay open for years, and that really gives you the most cost savings and the most flexibility in how you're going to spend your money.

Speaker 2:

So, as you're making these small microtransactions, they kind of balance each other out as you're sending money, receiving money, and eventually you need to square with the ledger, which is the whole Bitcoin ledger, as a whole.

Speaker 1:

That's right Now. Another question often about Lightning is why should we be interested in a payments network for Bitcoin when everybody's just in this hodl mindset of don't spend your Bitcoin, sit on them? I think that it's really about the process of how does Bitcoin become a monetary asset that is global in nature and, as we've talked with prior guests Parker Lewis especially comes to mind the store of value use case for Bitcoin is very strong. Eventually, if everybody is using Bitcoin as a store of value, then it does make sense for them to use it as payments between each other, because at that point, they've already gotten comfortable with the idea of holding Bitcoin and that there's an extra cost to constantly having to convert in and out of dollars to send payments, and so it just makes it more efficient to just stay in Bitcoin and send payments within Bitcoin if everybody's already using Bitcoin for their savings Now. Even before that, though, there might be use cases that are uniquely enabled by the technology.

Speaker 1:

Because Lightning and Bitcoin are open source technologies, you don't need to get permission, for example, from Visa, right? So if you're standing up an e-commerce store, maybe you don't meet the criteria that Visa has set out for onboarding merchants onto their platform, and so in that case it would just make more sense for you to go to a permissionless network like the Lightning Network and be able to send and receive payments that way, without having to sign in all sorts of legal paperwork with somebody like Visa or MasterCard. So you know Visa and MasterCard and all the rest. They've got a number of issues with them, as I mentioned, they're proprietary right, so you can't see their source code. So if you have an idea of how oh, I want to use Visa a little bit differently and so I want to be able to modify the Visa software, you can't do that right. You've got to work with their software developers and have them change it, and if they don't want to change it, then you're really out of luck.

Speaker 1:

The second is that you have to trust all of these other payment solutions. You have to trust them with your money and you have to trust them with your information, and you have to trust them with your information, so they have all of this data that then they can go and sell to others and all sorts of privacy concerns around that, or they get hacked right, and then all of their data gets leaked and suddenly people are doing identity theft and they're using your credit card to go on a shopping spree, and they're centralized, so if their network is down, you can't send payments. There isn't some kind of resilient fallback method like there is for Bitcoin. Bitcoin has, over the past decade, 100% uptime, and so, furthermore, with Lightning, as we'll see, you can open up channels with multiple different nodes and that way, if one of the nodes is offline, you can actually route your payments through another channel and another node.

Speaker 1:

Lastly, the existing payment solutions are credit-based, and this is really a double-edged sword. On one hand, there is an advantage for consumers that you can dispute a charge right and then you can get a charge back and essentially claw the money back from the merchant because they didn't deliver the goods right. There might be something that happened with the merchant. But the disadvantage is, perhaps you're a merchant and somebody is defrauding you by doing this kind of chargeback right that you did actually deliver the goods and they just don't want to pay for it, and so they call their credit card company after the fact and they try to scam you out of your money. And there's also a cash flow issue where, if you're a merchant and you're using, you know a credit card provider to receive payments, or you know the time it takes time for that money to actually show up in your bank account, and so during that period of time, you essentially have to front that capital right, so that you're able to pay your employees. You're able to pay for you know the flour that goes into the muffin that you sold, but you're still waiting for the cash to come from the company because there's a delay, as they're waiting to see if there's any charge backs and obviously they also benefit from delaying when they give you the money.

Speaker 1:

Now let's contrast that with Bitcoin payments and specifically, you know, with Lightning payments. So, first of all, it's not credit based, right, it's a cash system. Both Lightning and Bitcoin are cash systems, meaning that, just like if you hand somebody a $100 bill, if you want the $100 bill back, you can't just call your bank and say, hey, if you want the $100 bill back, you can't just call your bank and say, hey, I need this bill back. You're going to have to, you're probably going to have to involve law enforcement, maybe get a court to get your money back. And the other part of it too, of course, is that Bitcoin and Lightning are open source.

Speaker 1:

I think that the key about open source isn't just that it's permissionless and you can just use it and download it, and the software is free. The other part of it is what I've seen over the past 15 years is that it can innovate faster than proprietary systems because you have software developers from all around the world who are able to freely contribute to it. They don't have to get hired by Visa or by the Federal Reserve in order to contribute innovations, so there's kind of a free market of innovations, and then consumers get to choose what are the solutions that are solving the problem in the best way for them, and so that's a huge advantage for open source. So, even though there have been criticisms of Bitcoin and of Lightning, quite a few of these criticisms have been addressed through open source solutions. Third is that with both Bitcoin and Lightning, you don't have to trust anyone other than yourself. Right? Which big caveat there?

Speaker 2:

because People make mistakes. We're human.

Speaker 1:

Yeah, exactly, and arguably.

Speaker 2:

you know, I trust myself less than I trust you know my wife, or lots of other people Gabe, for example, when it comes to video editing.

Speaker 1:

So you know, that does mean that you do have a tremendous amount of responsibility, because that means you have to secure your own private keys, you have to responsibly use your computer and not accidentally delete anything or forget to back something up. But I think that it speaks to where we're at as a society that trust in institutions has dramatically decreased over the past 50 years, especially when we start talking about the banking system. People trust the banking system less and less as they see more and more bailouts and they also see kind of the. Well, I'll leave it there, because we got a lot of material to get through today. And then, of course, it's decentralized, so you're not having to worry about whether one of your peers is offline, and this is true at the Bitcoin level. It's also true at the Lightning level. So let's keep moving here as we Unless, gabe you have it.

Speaker 1:

Okay. So when people talk about lightning, they describe it as a layer two. So layer one is Bitcoin network. Layer zero, I'd argue, is the electricity grid. That, to me, is kind of the backbone of civilization.

Speaker 1:

I was having a conversation with an electrical engineer from Texas A&M yesterday and you know he did make the point that even water relies on, at scale, water purification. Right, there's lots of water treatment plants everywhere and if the electricity is out those water treatment plants stop working. And we saw that firsthand with Winter Storm Uri not so long ago, storm Yuri not so long ago my water at my home, when I had a newborn at home, just went bad. Right, it started and we got an alert saying hey, don't drink the water because the water treatment plant is offline. And so electricity, I do think, is layer zero for not just the Bitcoin network but for all of civilization, think is layer zero for not just the Bitcoin network but for all of civilization. So layer two solutions are all about taking the best properties of layer one and then identifying ways that we can actually have some trade offs that are interesting, and we'll talk about the trade offs for lightning, but first I want to talk about kind of what the stack is for Lightning so, and how that compares to the Bitcoin network. So, on both the Bitcoin network and the Lightning network, you have nodes, and so these nodes are open source software that you can run on your laptop, you can run on your phone, you can run on a server. They're not energy intensive.

Speaker 1:

Like Bitcoin mining is right, because Bitcoin mining is all about hash rate and hashing the nodes, the Bitcoin nodes. All they have to do is, for each block, they have to do one hash, which is to verify that the winning hash from the miner is correct, whereas the miners are doing trillions of hashes per second in order to find that winning hash and miner is correct, whereas the miners are doing trillions of hashes per second in order to find that winning hash. And so there's a big asymmetry there between the Bitcoin nodes and the Bitcoin miners, which is really the checks and balances that make the system work. The Lightning nodes do a lot more work than the Bitcoin nodes, because the Lightning node first of all has to connect to a Bitcoin node, so it's getting all of its data from the Bitcoin node and it's looking at all of the transactions that the Bitcoin node is seeing on this public ledger and it's picking out transactions that are related to the Lightning network. We'll see what that means in a little bit and then the Lightning Nodes are essentially taking a subset of the Bitcoin transactions and then building a map of them that are connecting these transactions together, and we'll get into that with these channels.

Speaker 1:

So, just to further motivate, there are already some fantastic lightning wallets out there. My favorite to use is called Phoenix. Phoenix is available on iOS and Android. With Phoenix, you're able to back up your private key to iCloud or Google Cloud if you're on Android, which makes it really convenient and gives you peace of mind there. Any kind of lightning wallet you should really treat it the same way that you treat your physical wallet, your leather wallet. Right, that it is about you're walking around money, right? You don't put $500,000 of cash in your leather wallet, right? You only put well, I ride around with $100. Stacks.

Speaker 1:

Yes, I know that some people you know they might have $1,000, but I'm not there yet.

Speaker 1:

I'm working towards that, and so it really is. You know, because on mobile, that is a hot wallet, and so there is an added cybersecurity risk. You might also just lose your phone or get locked out of your iCloud account. You know there's things that can happen. So you really should see Lightning as a checking account, whereas Bitcoin in cold storage is more like a savings account, right, except that you get to be your own bank. You don't have to rely on a bank, and with Phoenix you're actually you are still your own bank because the keys are on the device, and so it is self-custodial in that sense. Another option is Breeze. Breeze has done excellent work as well. They're on iOS and Android too, and so that's really, if you're that's for spending and then for receiving as a merchant.

Speaker 1:

A great open source solution is BTC Pay Server. Btc Pay Server supports both Lightning and on-chain payments, so the other really neat part about BTC Pay Server is that it has lots of integrations with e-commerce platforms. It has lots of integrations with e-commerce platforms, so if you're using Magento or PrestoShop or WooCommerce, you're able to connect to your BTC pay server with an API and it's self-custodial, so you're actually operating your own payment processor. You don't have to rely on Stripe or any other third-party payment processor. You're running it yourself. The cash goes straight into your Lightning or Bitcoin wallet and there's a thriving community around BTC Pay Server. It is an open-source solution and, by the way, phoenix and Breeze are open-source as well.

Speaker 1:

So lots of user interfaces to dive into and to play around with Lightning. You don't have to know the command line, right. You can just go download an app and use it. Okay, so let's start getting some intuitions about how the Lightning network functions. So the Lightning nodes are maintaining a set of channels. Each channel represents a Bitcoin transaction, so you open a channel by having a multi-sig with another Lightning node, so you'll have a two of two multisig and we'll describe that. But the channels start out with some amount of Bitcoin on your side and some amount of Bitcoin on their side, and you can think of it as an abacus, right? If I don't know, do kids still learn about math on abacus?

Speaker 2:

Definitely not, but I think that through media we, what they are like cartoons still use Abacus.

Speaker 1:

Somehow we know what they are because I've never used one. You've got beads on both sides of a wire and you can move the beads back and forth, and so you can think of each bead as representing some quantity of Bitcoin, and the total number of beads is the capacity of that channel, and so your inbound capacity is how many beads are on the opposite side that could be sent your way, and your outbound capacity is how many beads are on your side, how much money do you have that you could send out through the channel, and then when you send a payment. So, for example, here, if I want to send 250,000 Satoshis, let's explain that for folks not familiar Satoshis are a fraction of a Bitcoin, so each Bitcoin has 100 million Satoshis in it, just like each dollar has 100 pennies in it. That makes it easier to reason about when we're talking about small amounts, because now, if you're talking about anything less than $60,000 worth of Bitcoin, it's just easier to talk about Satoshi's, probably.

Speaker 1:

You don't want to say out all the decimal points 0.000025 BTC BTC yeah and oh, you know, I'll add this little trivia On Lightning. You can use milli-Satoshis, so a milli-Satoshi is a thousandth of a Satoshi.

Speaker 2:

Which is a hundred millionth of a Bitcoin.

Speaker 1:

Right, okay. So you're really talking about micro-micro um now you know you're paying for a newspaper. You're paying for, yeah, a word in a newspaper. Yeah, uh, newspapers are getting expensive that's right.

Speaker 2:

Paper's not free.

Speaker 1:

No, not anymore um, but you know, uh, if it's an online newspaper, right that? Um, there's been a lot of talk of like having uh micropayment paywalls so that you can read an article without having to provide your credit card information right, because it's just like you're paying a nickel, right you? Don't need to buy in a whole month subscription for something that you just want to read one article, yeah yeah, so hopefully the new york times adopts Bitcoin and Lightning so that they can set up micropayments for articles on New York Times.

Speaker 2:

Yeah, we just don't want Instagram to get a hold of that and be like I want to see this one picture from my favorite racing team. I have to pay you know, satoshi to see it.

Speaker 1:

Well, you'd get less advertising. That's a point, yeah well, perhaps, um, but also, maybe you shouldn't be spending so much time on instagram.

Speaker 2:

Yeah, well, sometimes you know, when the servers just don't work. You can't, did you?

Speaker 1:

hear about that this week. Oh, yes, yes. Centralized services, yeah, um, okay. So when you send 250,000 Satoshis over a channel, the bead goes in that direction, and you have to send a little bit more than that because there is actually a routing fee. So Lightning is a little bit different than Bitcoin when it comes to fees.

Speaker 1:

In Bitcoin, a transaction fee is charged based on how much data your transaction is consuming on the network. So you might actually be consuming very little data while moving a billion dollars worth of Bitcoin and you might end up paying a nickel of transaction fees because of how little data you consumed. Conversely, maybe you're sending a very small amount of value, but because you are sending it to lots of different people let's say, lots of different addresses you might be consuming lots of data and have to pay a high transaction fee. Lightning is different because your transaction fee, or as it's called, a routing fee, is based on the value that is being sent. It's not based on the amount of data being consumed, and so it's a percentage of the payment. It's a very small percentage generally. So if you compare it to Visa, so Visa you might be paying like 3% fee to Visa. With Lightning it's more like you're paying like 0.05% and if you have a Lightning channel open directly to where you are sending the payment, you don't pay any fee because there's no node that you have to hop through. So Lightning can be in some scenarios, um, so that routing fee gets paid to, uh, the routing nodes that are between you and your ultimate destination of, uh, your payment and uh, all of the nodes are connected, or that they can be connected through channels. So the one of the things is that you can actually you can either manually manage your channels and choose who you're opening a channel with, or you can just let your lightning wallet choose for you and have just like an autopilot, so that you're not having to think about that, and I think that that automation is going to continue to improve and it really makes it convenient so that you don't have to even know how Lightning works. You can just send and receive payments you know, just like you would with Cash App or any other kind of traditional system. Oh, speaking of Cash App, they have a Lightning integration so you can actually go buy Bitcoin on Cash App and then you can use it as your Lightning wallet. Essentially, it is custodial, right, because the Cash App company, square, has the keys for the wallet, but it's very convenient because somebody else is managing everything for you. You don't have to back it up, although you still have to back up your cash app password.

Speaker 1:

Make sure you have two FA not enabled Um, but uh, that is um an option there, the um. So you know the lightning network, uh, when I mentioned outbound capacity, so that's really important for people who are spending money, they need to have outbound capacity, and then merchants need to have inbound capacity. So in that regard, they're pretty symbiotic. But you still need some kind of mechanism to balance those two. You still need some kind of mechanism to balance those two. And so that's where the routers, the Lightning nodes that are actually, you know, helping connect all the users with the merchants, they're the ones that are managing the liquidity and the capacity between these two different sets of users and making sure everything stays balanced so that the payments don, so that, uh, the payments don't fail right when when they get sent Um.

Speaker 1:

Now, uh, the there are. You know, as I mentioned, like you should think about lightning for small payments, um, primarily because, uh, first of all, the fees are charged based on the value of the payment. So if you're sending $5,000 worth of Bitcoin, you might end up paying a higher routing fee on Lightning than you would have if you had sent a Bitcoin transaction. So there's a threshold where it just makes sense to switch to on-chain to send your payment. And also, you know, it just might be the case that the Lightning channels just don't have enough capacity to send that payment at any fee. Now that's happening less and less because of innovation. You know. The open source protocol added a new feature where the nodes can split up a large payment into many small payments, and that allows for greater payment reliability.

Speaker 1:

Okay, so to recap the advantages of Lightning over traditional Bitcoin transactions Lightning payments are instant, they're a lot less expensive for small value, and also another interesting property of them is that they have better privacy than on-chain right, because on-chain transactions you're committing all this data to the global public ledger, right?

Speaker 1:

So it's very transparent. Everybody can see all the Bitcoin transactions. Now it's pseudonymous, right. It's numbers and letters, so they don't necessarily know the identities behind the transactions, but nevertheless it is public, whereas Lightning Payments yes, opening and closing the channel is public, because those are Bitcoin transactions that go on the global ledger, but all the payments that happen in between. Those are happening off-chain, just between the Lightning nodes, and those are not being globally broadcasted, and so you don't necessarily see all the Lightning payments happening. And sometimes that leads to critics saying, oh, nobody's using Lightning. It's like, well, you don't know if nobody's using Lightning or not, because it does have significantly better privacy. Having said that, you know, when I was working at Kraken and we launched Lightning, it was hugely popular. So people are definitely using Lightning. That I have zero doubts about because I have seen the data kind of you know from the inside.

Speaker 1:

So Lightning does have some requirements that you wouldn't necessarily have with a Bitcoin node, for example, or a Bitcoin miner, for that matter. First of all, you have to be online 24-7 and monitoring all of the on-chain transactions. Just in case one of your peers somebody you've opened a channel with if they try to cheat and take your money, you have to be watching the chain and that way you can punish them by taking all the money back. So we'll talk about that as we go into some of the more advanced concepts here. So you have to be online, which I mean at this point. Personally, I'm online too much, so I don't think that's an issue, and it is a hot wallet, as I mentioned earlier. So the keys are connected to the internet. It's not like cold storage and you have to continuously be backing up the data, right? So with an on-chain cold storage, you might have 12 or 24 seed words and you just need to back it up once, and then you can actually send and receive Bitcoin transactions using that private key, and the private key won't change, right? Or the data that you need to back up won't change. That's not the case with Lightning. With Lightning, every time you send a Lightning payment, you need to back up your data, and the software does this automatically in most cases or hopefully, at this point, all cases so you don't need to worry about it, but it is something to be conscious of, especially if you're a software developer who's contributing to Lightning software. Okay, so now let's dive into what I would call intermediate lightning.

Speaker 1:

So what is lightning? What are the Bitcoin transactions? What are the smart contracts? Right? I think that's the key question here. So a Bitcoin transaction that is opening a lightning channel is a two of two, multi-sig. Now let's start with what a single sig, one of one, is. So when you are receiving Bitcoin so let's say I'm going to receive Bitcoin from Gabe I will generate an address using my private key. So this public address is derived from the private key and it's something that I can share with Gabe, and I know that if he has it, he can't steal my Bitcoin. He can't guess the private key by just using the address, and then he'll take that address and he'll put it into his Bitcoin wallet and he'll put in some amount. Right, he's going to send me 500 Bitcoin, yeah, yeah, I mean, come on.

Speaker 2:

It's a lot of.

Speaker 1:

Bitcoin. Well, yeah, you owe me and he's buying a car from me, so that's a fancy car.

Speaker 2:

It's a nice car. It's a real nice car.

Speaker 1:

It's a collector's item, and so then his wallet will take that address and put it into a Bitcoin smart contract, and what the smart contract says is that the only person in the world that can unlock these Bitcoin going forward is whoever controls the private key and can prove cryptographically that they control the private key of this address right, which is my address.

Speaker 1:

And so his wallet will broadcast that transaction to the Bitcoin nodes. The nodes will verify that transaction, add it to the backlog of transactions to the mempool and then a mining pool will include that transaction in a block. The mining pool will send the block header data to the miners. The miners will hash that block header until they find a winning hash. They'll send the winning hash back to the mining pool and then the mining pool will broadcast that winning block to the nodes. The nodes will verify that everything is copacetic with the block. Then they will update the ledger the UTXO set kind of the balance sheet of everybody's balances using the transactions that are in that block, and at that point the transaction is finalized. So at that point I would be able to go spend those Bitcoin. So then I would you know if I'm sending Gabe back 505 Bitcoin? I don't know. He lent it to me so.

Speaker 2:

I got to pay back interest, right?

Speaker 1:

Gabe doesn't lend for free, so at that point I would have to unlock the Bitcoin and my wallet would take my private key, right? Presumably, the private key is in the wallet, although if it's cold storage, a whole different thing. You got a signing device. Anyway, the private key is used to sign the transaction and it's the same private key that we derived the address from. And so, basically, what the nodes are verifying is two pieces of data One, they have the address that Gabe had put into the output and they have the digital signature that I created and they check.

Speaker 1:

Okay, do these match up? Because the digital signature, you can actually verify it using the public key, using the address. You don't need the private key to verify the digital signature. You do need it to create the digital signature, and so, unless somebody has stolen my private key, I'm the only one with it, right? So I'm the only one who is authorized to unlock these Bitcoin that went to my address, and at that point I've unlocked it, and now I can take the address that Gabe provided, and so on and so forth, right? So now we've completed the loop.

Speaker 1:

Okay, so that's single signature, multi-signature, two of two in this case, although you can have any variation, right, you can have two of three, you can have one of two, you can have three of five, and now with Taproot you can have like 500 of 500. So something I've thought about is that Congress should have a multi-sig and so that way they could only spend it by uh, I'll bring their hardware wallets, you know, and and signing the transaction, but I don't think we would ever transact anything that might be a good thing.

Speaker 1:

Um well, if they set it to be a majority, then presumably that's what they should be doing anyway. Right of, they got to have a majority of the votes, a majority of the uh, and then they can send out. But maybe they wouldn't be able to do it for other reasons, maybe age-related, maybe tech-savvy.

Speaker 2:

Well, that aside, is there anything that's going to be bipartisan enough for somebody to say, yeah, let's do that.

Speaker 1:

That's fair. That's fair. So with Lightning it is a two of two, and so the two are your node and then the other node that you're opening a channel with and basically what you're establishing is that in order for these Bitcoin to be unlocked, going forward, you're both going to have to provide a digital signature of the same transaction, so you're both going to have to agree on the transaction. Now that might sound a little risky because this counterparty, this node, is just any other lightning node on the Lightning network. So it sounds like at first glance, uh-oh, I have to trust the person I'm opening a channel with to co-sign the transaction with me at some point in the future and we'll see why that's not necessarily the case. But let's first talk about, kind of so that first transaction, that two of two transaction that we're going to send out to the Bitcoin network. That's called the funding transaction. And then all of the transactions that happen off-chain, that do not get broadcasted to the network, are called commitments and they are in the payment channel on the Lightning Network. And then the last commitment is going to be the closing transaction and that's what we're going to broadcast back to the Bitcoin network in order to say, hey, that transaction you saw a while ago, the funding transaction. We're now closing that tab, we're closing it out and the channel no longer exists.

Speaker 1:

Okay, so let's talk about the commitment transactions. So these are Bitcoin transactions, right, they're just like any other Bitcoin transaction, but they're not broadcasted transaction, but they're not broadcasted. So we just keep it between us and they are asymmetric. So it's really interesting, because there isn't one commitment transaction. There are two commitment transactions and they are mirror opposites of each other. You have a transaction that I have signed and I have a transaction that I have signed and I have a transaction that you have signed, and so, at any point, either one of us could sign the transaction we have and have a two of two and broadcast it to the network, thereby closing that channel, right?

Speaker 1:

Right, we're both mutually agreeing not to do that, even though we both have the option to do it. So when we send a Lightning payment, what we do is that we create two new transactions and we revoke the old ones. So we void them and say, okay, the old two commitment transactions no longer on the table, they're gone. So we don't have the option to broadcast either one of those and we've got a new set of commitment transactions. And, interestingly, that new set of commitment transactions has a new set of outputs, meaning that there are now different balances in the payment channel. So your outbound capacity has changed and the inbound capacity has changed, and so only the value of the transactions sorry, well, the relative value, because the total value of the transaction is the same, right, because the sum of the two outputs is always going to be what's the total channel capacity, but how they're divvied up between the two counterparties, that's what's changing, and so that is what the payment is is that we're voiding the old balances and we're creating new balances, and the delta is the payment amount.

Speaker 2:

How secure is it to cancel out and void those previous transactions and say you know, someone who's a bad actor wants to go and say I don't want to agree to this channel anymore. Let me go terminate this channel on old. You know ledger Great question Good anymore.

Speaker 1:

Let me go terminate this channel on old uh, you know, ledger great question, good. So in order to prevent somebody from cheating, uh, you have to stay online to punish them. And so what happens is that if, if I broadcast a revoked transaction because, because I'm trying to scam Gabe, right? So I'm thinking well, you know what, it's Friday night, gabe's probably not at his computer, his computer's probably off, so I'm going to broadcast a transaction that is the old version and that is basically. You know, if I sent you a payment, then I could claw it back by broadcasting the old version of the transaction. But little do I know.

Speaker 1:

Gabe actually is home, he's online and his node sees that I did this because it's looking at the Bitcoin blockchain and it sees hey, hold on, this guy broadcasted an old version of the commitment transaction. He's trying to scam us. So your node would automatically create a punishment transaction that would take all the money out of the channel, including whatever balance I had when I was trying to scam. And so it is a punishment in the sense that you're not just taking what is what was rightfully yours, you're taking what is now rightfully yours because it's kind of like, hey, if I steal a pen, the judge might say, hey, you got to pay back two pens because you got to make the person whole and you need to be punished for having, you know, being a jerk.

Speaker 2:

You mentioned that you have to be online. What does that necessarily mean? Can you kind of expand on that?

Speaker 1:

Yeah, so I was kind of personifying it by you actually being at your computer. But, realistically, your computer stays on, your node is running, just like for the kids out there BitTorrent if they use BitTorrent that you're seeding or that you're downloading You've got to keep the software open for it to continue running.

Speaker 2:

So again, I'm not trying to tear down Lightning transactions here.

Speaker 1:

No, no, no, please do. These are great questions.

Speaker 2:

But what happens if, say, one of those nodes goes down because the internet connection fails?

Speaker 1:

Yes, great question. So, thanks to all the open source innovation, we have what's called watchtowers, where you can actually delegate being online to a third party. Now you don't have to trust them in the sense that they can't steal your money. You just have to trust that they're going to be online. And so that's one thing. The second thing is that there's a time lock.

Speaker 1:

So if I'm trying to scam you and I broadcast that commitment transaction, that commitment transaction actually has a hard-coded time lock that says that, all right, you can, you can broadcast it to the bitcoin network, but you're not going to be able to spend the bitcoin until three days from now, giving you time to come back online. So you might come back the next day and be like and then your node is downloading all the blocks that have happened and it's like hey, hold on. Six hours ago, pierre tried to scam us. Let's broadcast that punishment transaction. So that time lock gives you a safety net of okay, I can come back online. So you don't have to be online 24-7, per se, and you can actually configure the time lock to be however long or short you want it to be, depending on what you think the odds are of you being offline or if you've got a watchtower and all that Interesting.

Speaker 2:

Yeah.

Speaker 1:

Now these are perfect questions, because something that the Bitcoin and Lightning developers emphasize a lot is this adversarial mindset of we're talking about money. So you know, we know people are going to try to steal the money right, so we've got to design systems that are pretty airtight from the security perspective.

Speaker 2:

For sure.

Speaker 1:

Yeah, okay, and I'm glad that you intuited those questions.

Speaker 1:

So that's good adversarial thinking, all right. So that was kind of zooming in on one channel. Now we can connect multiple channels together to do what's called routing A little bit of lightning history. When Satoshi Nakamoto first released Bitcoin in 2009, he had a very early version of payment channels. It's very rudimentary. It didn't have the time locks. It was kind of like the first approximation, the first try, first attempt at this. It's full of holes, so it didn't really get any interaction, but it just shows that from the get-go, there was some thinking of well, not every transaction has to be on the blockchain.

Speaker 1:

We can actually think of the Bitcoin blockchain. We use the metaphor of Visa and of the Fed. Another metaphor that I like a lot is the court, as we were talking about in our last episode. Sometimes, as a last resort, you have to adjudicate a dispute by going to court and presenting your evidence, and that's the way we can think about the Bitcoin blockchain is that if you have a dispute on the Lightning Network, you can take them to court, ie the Bitcoin blockchain. You can present the evidence, which is the Bitcoin smart contracts, and the nodes will adjudicate the dispute based on that. So it's kind of a fallback mechanism or a you know last resort.

Speaker 1:

Okay routed payments, okay routed payments. So let's say we've got three nodes connected by two channels. We've got me, gabe and Alice, and the question is how do I send Bitcoin to Alice? And I have a channel open with Gabe. Gabe has a channel open with Alice. So the first step is that Alice will send me what's called a lightning invoice. We can also call it a lightning address, but we try not to use the word address, because we already use that for the Bitcoin network and this is not like a Bitcoin address at all. Lightning invoice has a lot more information in it, including a secret. The secret. Call it R, I can just call it a secret. The R is kind of it's a cryptography symbol, but Alice if Alice. So Alice wants to receive Bitcoin.

Speaker 1:

So the first step is that Alice's lightning node has to generate an invoice and then she'll send that invoice to me. And the invoice it's. It is like a Bitcoin address in the sense that it's just random numbers and letters, but it's much longer than a Bitcoin address, and so usually what you have with an invoice is a QR code or you know it's kind of it's hidden because it's just so long, you wouldn't. Bitcoin address is relatively short, anyway. So Alice provides the lightning invoice to me. I input it into my lightning wallet and I say, all right, let's pay this invoice. Input it into my lightning wallet and I say, all right, let's pay this invoice. Uh, the invoice also has Alice's node lightning node pub key. So that is basically the unique identifier of her lightning node, um, and it has the amount of uh, you know that she is expecting for me to pay her Um.

Speaker 1:

Now my lightning wallet will say hey, are you sure you want to send this amount to this Alice node? And I'm sorry, alice sends me a hash of the secret, so she doesn't send me the secret, it's a hash of the secret. And then I will then go to Gabe and I've got the hash and I'll give you the hash, and then Gabe will give the hash to Alice and Alice will know that it is actually a hash of the secret, because Alice has the secret, so she can take that hash and compare it to the hash that she had generated. Now, at that point Alice gives the secret R to Gabe and then Gabe gives me the secret from Alice Big game of telephone. Now it's cryptographic, so we're not losing the context when we're playing this game of telephone. Now it's cryptographic, so we're not losing uh, the context uh, when we're playing this game of telephone, and thankfully it's all automated in the background.

Speaker 2:

So yeah, I'm like there's no way that I'm doing all of this work right? Yeah, it's all in the background.

Speaker 1:

Yeah, no no, this is. This is block time, taking a deep dive into uh, the mechanics of the lightning network.

Speaker 1:

Um, and at that point, that's what allows us to move the Bitcoin, because that's what allows us to update all of the commitment transactions that are involved here, which would be a total of four commitment transactions. Right, because we've got two channels. Each channel has two commitment transactions and then, you know, if we have, let's see in this diagram, we've got five uh nodes. This is from Mastering the Lightning Network, a book written by uh, andreas Antonopoulos, uh and uh and Lalu, and I think there's another co-author on there. Um, let me look up the. I don't, I don't want to, uh't want to not give them credit, because it's actually an excellent book, highly recommend. If this episode has been intriguing to you, google Mastering the Lightning Network. It's available on your favorite bookstore. Oh, of course, rene Pickhart. Rene is an excellent lightning researcher, and so you've got three of the top names in Bitcoin and Lightning. Lalu you might also know him by his name on Twitter Roastbeef. He is one of the principal developers for Lightning Labs Lightning Node, which I've used extensively, so I owe him personally a huge debt of gratitude. But from their book they've got an example with five nodes and so that way you're able to see, okay, what happens when you've got multiple hops. I believe you can have up to 15 hops. I believe you can have up to 15 hops. Now, generally you're not doing 15 hops because that gets expensive, right? Because now you're paying a routing fee to every node that's in there. It's just generally you're doing like four hops, or three hops is what I've seen as going on in the network. Now I do have an advanced lightning course which gets further into depth on the commitment transactions and the time locks and the hash time lock contracts, htlcs and the R values and all this. So perhaps in a future episode we'll do advanced Lightning. I myself need to refresh on it because I taught that advanced course once in 2019. So it's been five years and I need to refresh myself on it.

Speaker 1:

But let's keep moving here to the closing transaction. The closing transaction can happen in two different ways. One is that you can have a cooperative closing transaction where we're both agreeing that we want to close the channel and this allows us to really have a very small transaction that goes on from a data perspective. Right, it's a small transaction from a data perspective, and the other advantage of the cooperative close is that we can go and immediately spend the Bitcoin. There's no time lock because we're both proactively agreeing on the balance. We're both proactively agreeing on the balance. Now we can also have a let's see. There's also a non-cooperative close, which is really what we were discussing earlier about having a situation where either it's honest and the only reason it's not cooperative is because one of the nodes is offline, and so at that point we can't do a cooperative close, and so we put the latest commitment transaction on chain and got to wait for the time lock. But then eventually the time lock elapses and we can spend the Bitcoin. Or somebody is trying to cheat, in which case they you know, they put an old commitment transaction on the chain and now, hopefully, we have a punishment transaction to dispute that, and that way we can catch the bad guy. Okay, so you know, let's close it out there.

Speaker 1:

I know that that was a lot of material and at this point, you know, I'd like to actually take a look at the current state of the lightning network, because we can actually see how many channels are public. You can have private channels, meaning that you don't broadcast. Sorry, you do still broadcast the channel opening to the Bitcoin network, but you don't tell everyone else on the Lightning network that this is a Lightning channel, perhaps because if it's a mobile wallet that you're using, you're not a router, because if it's a mobile wallet that you're using, you're not a router. So you don't necessarily want to clutter up the public Lightning Network set of channels. Now, if I look at the handy-dandy Lightning Network dashboard, at this point there are upwards of 16,000 nodes and there are about 40 to, let's say, 60,000 channels, and so the Lightning Network has grown tremendously, and hopefully this episode will get you interested in it and start experimenting with it.

Speaker 1:

Now, the cool thing about the Lightning Network is because it is for low value. You can stand up a Lightning Node and just put $50 worth of Bitcoin on it and start sending payments back and forth with your friends online. Another really neat part about Lightning is that it's really strongly integrated with a new social network called Noster. Noster emerged as an alternative to Twitter because Noster is open source, and so it was created by Bitcoiners who wanted to be able to send Lightning payments to each other without having to doing it natively inside of the social media app, and that's a really fun way to send Lightning, so you can tip other Nostra users using Lightning if you like their. They're not tweets, they're messages Posts.

Speaker 2:

Posts yeah, yeah sure, All right.

Speaker 1:

well, thanks for joining us this week. This was a change of pace. Right, we weren't so much talking about mining and electricity in the grid, but I hope that you found it fascinating and that you can kind of see that Bitcoin as an open platform is continuing to grow, continuing to provide lots of interesting solutions for folks globally, and I hope to see you next week. If you enjoyed this episode, don't forget to share, subscribe, leave a five-star review and, of course, if you have any questions, feel free to send them in. Always happy to bring up some audience questions on the show. Thanks and see you next week. Thank you.

Lightning Network Overview and Benefits
Trust, Decentralization, and Lightning Network
Understanding Lightning Network and Micropayments
Understanding Lightning Network Transactions
Understanding Lightning Network Transaction Security
Understanding the Lightning Network