(Source :
https://theblockchaintoday.com/how-does-the-lightning-network-work/)
The main idea is that small transaction don’t need to be on the main blockchain this avoids the transactions per second limit and is also called “the off-chain approach”.
Basically the lightning network makes it able to create multi signature addresses. Simply said, multiple parties can use a same bitcoin address.
For example, I’m shopping often at a supermarket. So I’m opening a payment channel with the supermarket. The payment channel you could compare with a safe deposit box.
I’m sending let’s say 0.3 BTC to our payment channel. The supermarket will have a small amount inside 0.05 for possible returns.
Opening the payment channel happens on the main blockchain so that there is full transparency. The supermarket can see I successfully deposit 0.3 BTC and so is the supermarket ensured that it will get the money as soon as the payment channel closes.
Now that the payment channel is open, I can go to the supermarket and buy my groceries. Let’s say on my first visit I will buy things worth of 0.02 BTC. To pay for it I just simply give a order to the payment channel that 0.02 BTC of my account has to go in to the supermarkets account. which leaves me on 0.28 BTC and the supermarket at 0.07 BTC.
Now the supermarket and me are signing this with our private keys. We then each get a copy of it but don’t do anything else with it.
I can do my groceries for as long as I have balance inside my payment channel.
There is no-limit in the transactions between us. I can make thousands of transactions at the supermarket without that it has any influence on the main blockchain.
The payment channel can be closed at any time by either me or the supermarket. Al we would have to do is take the latest copy of the balance sheet signed by both parties and broadcast it to the bitcoin network.
Miners will then validate the signatures on the balance sheets and if everything is okay it will release the funds according to the balance sheet. This creates a single trans action on the blockchain.