The Lightning network allows Bitcoin users to exchange bitcoins on the Bitcoin blockchain. The processus is done with the use of complex mathematical algorithms in interaction with Bitcoin’s user base. The algorithms make lightning fast payments at a fraction of the transaction fees. People have always complained regarding Bitcoin’s scalability issues, but the lightning network could solve these problems by making the transactions much faster and by reducing the transaction fees.
The Lightning network will allow any cryptocurrency that is Lightning network enabled to perform atomic swaps. This is the exchange from a cryptocurrency to another one in a matter of seconds, all with little to no fees and heightened security. Atomic swaps make it possible to trade coins cross-chain directly without having to go through a third party, like an exchange. The transactions can also be executed on-chain or off-chain.
To make sure every user respects the conditions of the transaction or the contract, atomic swaps use a Hashed TimeLock Contract (HTLC). For the swap to be successful, both traders are held responsible by a multisignature transaction system. If the swap isn’t verified in a certain timeframe, the timelock will ensure each traders will get back the funds they wanted to trade. For the swap to be successful, a hashlock uses a cryptographic algorithm that makes the funds accessible for each party once they both have signed off on their respective transactions.
Bilateral Payment Channel
The first thing to do to get started with Lightning network is to create a payment channel. They are the transaction pathways in which the Lightning network transfers value. To set up one, you must open a transaction directly on the blockchain for this channel. This process takes place off-chain and the Bitcoin network needs some time to know you are opening a transaction.
After that, both parties will keep their own balance sheet of the exchanges that are made on the channel. All transactions and balances will be recorded with this network every time funds are moved in or out.
For the payment channel to be functionnal, multi-signature wallet addresses must be used by both users involved in the transaction. Funds will be held in a multi-signature wallet and both parties can access the funds with a private key . Three things can unlock the funds held in the wallet:
- both parties sign a finished transaction with each one’s private key,
- if one person choose to finalize the transaction by himself,
- if a maximum time limit is reached, both parties’ funds will be returned to their own respective wallet.
To make a transfer of value between two parties, by signing a commitment transaction, each party will update their own balances in the payment channel. This type of transaction divides funds between the two traders’ mutual agreement. Transactions will be paid once the channel is closed. When both parties accept the transfer, the balance sheet will automatically update in the channel, since both participants will have shared their own hashes.
To effectuate recurring transactions, it is important to update the account balances every time. A new value is then created for the new transaction that is added to the previous account value. This method ensure that none of nobody is able to cheat and manipulate the agreement.
Closing a Payment Channel
To close the payment channel, both parties have to sign a transaction with their private keys to share their final account balances to the blockchain. Miners will then validate it and store it on the public ledger. The only interaction that each participant will have with Bitcoin is in the opening transaction and in the closing transaction.
The Lightning network is going to help Bitcoin with its scalability problems. It is an off-chain system that processes only the opening and the closing transaction on the blockchain. All other transactions are occurring through another secondary layer. The Lightning network will considerably reduce the transaction time and transaction fees of every coin on its network.