Bitcoin (p2p payment) network is slow and has high fees. Lightning network (LN) supposedly fixes both issues. LN is a bit complicated but remember that it has lower fees and it is faster to complete transaction. I am no pro in LN or explaining it, so what i am trying to do here is to write it all out in simple steps. Here is one definition of LN “Lightning is a decentralized network using smart contract functionality in the blockchain to enable instant payments across a network of participants”. The main driver of LN are payment channel(s). Those channels are of-(block)chain bi-directional channels which allow peers to transact of-chain.
Here is a general simplified operation of LN:
- Peers open a channel which is broadcasted to blockchain. This is accomplished by an “opening transaction” on the main blockchain.
- Once channel is open, peers can transact of-chain any number of times without impacting main chain.
- When peers are done exchanging funds, a channel is closed which is done via “closing transaction” on the main blockchain.
The juice of LN is in the “opening” and “closing” transaction. Here how it works in a nutshell:
- Peers agree on value of their future transactions.
- Peers send (incomplete transaction, requires both signatures to be valid) some amount of BTC to a multi-signature bitcoin address (like a safe-box) with some time constrain. If nothing happens before time expires, all peers get their money back. This is a setup (“opening transaction”). Note that during a time constrain, any counter party can bail since they will only need their own signature to get funds.
- Issue new incomplete transactions with different balances (smart contracts) AND time constrain that is lower than original (newer), people can adjust their balances (i.e payments) and this is done of-chain.
- When time expires, the newest contract from #3 will be verified and funds will go to peers (“closing transaction”).
In any case this is a poor’s man attempt on explaining LN.