what is the Lightning Network and how does it work for non-technical people
let's see if I can answer this question as well as I can alright so first of all
the Lightning network is an overlay network which means that it's not a
blockchain it's not a side chain it's not a state chain it's not a drive chain
it's not any kind of chain it's a peer-to-peer network that
operates alongside or on top of Bitcoin and uses Bitcoin in order to secure its
transactions so it uses the consensus rules and security from the Bitcoin
blockchain in order to do something very interesting which is provide very fast
and very cheap transactions so we're going to talk about how that works
next well first of all important to understand lightning is used to make
Bitcoin payments it can also operate on other blockchain such as the litecoin
blockchain and perhaps in the future others too
for now it's bitcoin and litecoin and it's important to understand that
lightning does not have its own currency or its own blockchain it is simply a
network for exchanging Bitcoin transactions let's keep that in mind
first so let's say myself and my friend Rene Pickhardt who's in the chat have a
lightning connection we want to establish a connection so we can send
payments to each other with a lightning Network so what we will do is we will
set up what's known as a payment channel now a payment channel isn't a physical
thing it's not even a network thing it's basically a set up of Bitcoin
transactions in such a way that we can exchange value between the two of us and
the way it works is by using two key features of the Bitcoin blockchain
the first one is multi signature transactions Multi signature
transactions are transactions where it takes two people to sign to move money
or 3 or 4 or any number of people and the second feature it uses is time locks
which is where you can set transaction to not be executable until
some points in the future these two features together are basically all you
need in order to set up a lightning payment channel and any blockchain that
supports these features such as for example litecoin can theoretically be
incorporated into the Lightning Network so let's get back to our example Rene
and I want to open a payment channel so the first thing we do is we create a two
of two multi signature address a two of two multi signature address is basically
an address where if you put money into it it can only be spent from that
address if both of us sign so in the background over a network connection
Rene and I exchanged some keys so that we can set up this multi signature
address so we effectively exchange public keys so that we can set up this
multi signature address now at that point one of us will fund this address
by putting money into it let's say I put one tenth of a Bitcoin into this
transaction so zero point one Bitcoin into this transaction into this address
so I do a regular transaction on the Bitcoin blockchain that sends zero point
one Bitcoin to this multi signature address that transaction is called the
funding transaction because it funds the channel between us so again let's take a
step back what is a payment channel a payment channel is basically an
arrangement between me and Rene and it's an arrangement in this case that allows
us to spend money if we both sign and allows us to keep track of a balance
that we keep in that virtual payment channel that allows us essentially to
transfer money from one party to the other for me to rename from Rene to me
for example using transactions that are potentially broadcast on the Bitcoin
network so I've put zero point one Bitcoin into this multi signature
address after six confirmations this will now be
valid and fully confirmed on the Bitcoin blockchain and now we have a funded
Channel now what is the balance of this channel
an interesting thing in lightning is a payment channel has two balances it has
what is called a local and what is called their remote balance and of
course it depends on their perspective my local balance is the money I have in
the channel and my remote balance is the the money that Rene has in the channel
and for Rene of course it's the opposite his local balance is what he has in the
channel and his remote balance is my balance so in every payment channel
those two balances think of it as a pile of money sitting on one side of the
channel and a pile of money sitting on the other side of the channel when we
opened this channel between us because I funded it into the multi signature
address with a transaction the money is all sitting on my end of the channel
essentially there's zero on the other side and there's zero point one Bitcoin
on my side and that's our current balance I own zero point one Bitcoin
which is in the channel on my side now if I wanted to send money over this
payment channel to Rene now the magic of lightning starts
because I do not need to do an on chain Bitcoin transaction in order to exchange
value with Rene I can't spend out of this channel without Rene's agreement
Rene can't spend out of this channel without my agreement and that means we
don't have to trust each other as part of the address there's also a
script that allows me to get a refund for the money I put in after a period of
time in case Rene just disappears and leaves me hanging so there is a
mechanism to ensure that the money isn't just locked in there and unable to be
retrieved by anyone all right so now we can start exchanging transactions what
we do is let's say I want to send money across this payment channel to Rene what
I'm going to do is I'm going to partially sign a commitment transaction
that spends from this Multi signature address and it creates two outputs one
output which is let's say 0.01 Bitcoin that is spendable to Rene and
one output which is 0.09 Bitcoin which is spendable to me so I took the 0.1
Bitcoin and I took a tenth of that and gave it to Rene and 9/10 back to me and
if Rene agrees he can counter sign that broadcast it on the network and as a
result get that's Bitcoin but there's no reason to broadcast that transaction
because Rene knows that any point in time since it's already signed by me
Rene who's my counterpart in this channel can spend it all they have to do
is apply a signature broadcast it's on the Bitcoin blockchain and the Bitcoin
blockchain will split the money in the proportion of the channel balances
agreed so at this point the channel has a balance of 1 100th of a Bitcoin on
Rene's side 9 hundredths of a Bitcoin on my side and so we've split that balance
effectively what has happened is I've moved 0.01 over to Rene's side but
nobody knows this the only thing that happened is we exchanged a signed
transaction over this peer-to-peer network effectively moving balance
between us now this is the basic concept of a payment channel if Rene wanted to
move money back to me we could then create a new transaction that spends the
original funding transaction that was sent to the multi signature address but
which has a different distribution of balances between Renee and me and
effectively that transfers balance back and forth and back and forth and we can
do this as many times as we want we can send these transactions as fast as we
want to each other hundreds of times per second and each one that we send uses a
clever trick to invalidate the previous transaction so that now only the latest
one can be spent if we decide to close this channel and allocate the balance as
is that's the basic concept of a payment channel
now imagine that Rene has a payment channel to Carol and I have a payment
channel to Rene and I to pay Carol well instead of opening a
new payment channel directly from me to Carol what we can do is we can make an
agreement whereby Carol shares a hash with me and I pay to that hash that's
done in the form of the Lightning invoice and the way we do that is that
Carol has a secret that is hashed and Carol will only reveal that secret when
Carol is paid so I make a payment over my channel to Rene for the amounts that
Carol is to receive and that payment is contingent upon the secret from Carol
Rene then makes a payment on his channel to Carol which is also contingent
on the same secret Rene can do that because he knows that if he gets the
secret from Carol because she cashed his payment he can use that same secret to
get the payment from me which means that there's no risk he doesn't have to
trust Carol he doesn't have to trust me if neither of us come through nothing
happens and the channels are back where they used to be that transaction that is
routed between us is called a hash time lock contract or HT LC and you can
string as many payment channels as you want in this way where I make a promise
to Rene Rene makes a promise that Carol Carol makes a promise to Dave Dave makes
a promise to Elizabeth Elizabeth makes a promise to Franck etc etc and once we
set up all of the promises then the secret flows backwards and each of these
promises gets fulfilled no one can be cheated along the way no one ever has
custody because every channel requires two signatures and agreements between
both parties no one can ever be cheated because if anybody drops out halfway
through then none of the payment chain happens and everything revert back
people can get refunds after a time out if the other party disappears etc so
this is a trustless system nobody has to trust anyone it's a noncustodial system
because no one has custody of the money it's in a multi-sig between the two
parties for every payment channel and because we don't have to wait for
confirmation because we only do that when we close
channels all of the payments in between give us the ability to make very very
fast payments now if in each one of these hops the parties who are
participating ensure that the payment they receive is a few satoshis more than
the payment they send out to the next person that difference of a few
Satoshi's is effectively a routing fee that they can collect and they can tell
the rest of the network routing fees they want in order to forward a payment
and that way there is a mechanism of fees as well in the Lightning Network so
that's the overview of how the Lightning Network works and the most important
things to remember is that the Lightning Network transmits partially signed or
fully signed Bitcoin transactions that's a simplification not exactly it's it's
easier to just transmit the signatures but effectively we're operating in the
realm of Bitcoin transactions perfectly valid Bitcoin transactions that can be
constructed by each of the pairs these transactions are based on spending from
a two of two Multi signature which means that neither party can run away with the
money which means that there's no trust involved when you when you string along
several payment channels in order to make a payment no one has to extend any
trust people can receive refunds if the other parties disappear and the payments
that we are transmitting are Bitcoin transactions that are transmitting
Satoshi so this is just Bitcoin just on a faster basis with private peer-to-peer
transactions that can operate very cheaply
if you enjoyed this video please subscribe like and share all my work is
shared for free so if you want to support it
join me on patreon
you