DEV Community

Peter Tyonum
Peter Tyonum

Posted on

Lightning Network: Your Gateway to Bitcoin Payments

Amongst other things, bitcoin was introduced to facilitate borderless payments regardless of the amount, bring financial services to the unbanked while preserving users privacy without a central authority. Functionally, it has achieved all of these but has not been a preferred payment method for many probably because of the time it takes for payment to be confirmed and the transaction fees. In this article, we will look at how lightning network handles transactions faster, cheaper and more privately.

Lightning network is a second layer technology built on top of Bitcoin that has made making payments faster, cheaper and more private. Making payments (transactions) on Lightning networks are secure and does not require users to trust the other party similar to Bitcoin. But what makes lightning network more exciting? Let’s look at it more closely.

On the bitcoin blockchain, when a transaction is constructed, it is broadcasted to the entire bitcoin peer to peer network, accepted and mined into a block. It is then confirmed (confirmation here implies adding more mined blocks after the block that has your transaction in it and the recommended amount of confirmations are 6). However, in lightning network, transactions are not broadcasted to the network (except opening and closing transactions), but instead sent directly to a person (a node) on the Lightning peer to peer network.

You might be wondering if payments on the lightning network are not broadcasted and confirmed on the bitcoin blockchain network, how then are they secure? are there no chances someone is going to be cheated? Lightning network makes use of the game theory otherwise called fairness protocol that serve as a deterrent for would-be cheaters. In Lightning network, payment can be made in a channel (a financial relationship between two parties on the LN network) or be sent through (routed) the network to a node. Let’s look at each scenario and how it is uninteresting and financially punishable for any party to attempt to cheat.

When two parties establish a channel on the Lightning network, they have a direct pathway to send payments to each other. These payments are built on the channel opening transaction called funding transaction which is confirmed on the bitcoin blockchain. Subsequent transactions (commitments) are no longer broadcasted but are valid transactions. These transactions simply update the channel state (the balance between the parties in the channel). See figure below.
Image description

adopted from Mastering Lightning Network.

As I have stated earlier, all the (commitment) transactions are valid transactions that are not just broadcasted to the bitcoin network. If one of the parties broadcast any of the prior commitment transaction to the bitcoin network in an attempt to cheat the other party, the other party stand a chance to revoke and claim the entire balance of the channel. This is because the transaction outputs are timelock for the party who broadcasted the transaction while the other party can claim those outputs immediately and also claim the balance of the party that broadcasted the transaction.

In situations where parties are not in a channel but there is need to send payment, they can simply generate an invoice which contain a payment hash, their node id on the network, the amount to be paid, an optional description and the invoice expiry date. The payer (their node) will find a path that requires the least number of hops and fees to send such transaction to the party. They will then route the payment to the recipient and receive acknowledgment. Payments made through this method either succeeds or fails, there is no in-betweens.

It is also worth noting that, payments made on lightning network remains private between the parties involved. No third party node has explicit knowledge of the amount, source and destination in a transaction and the nodes propagating such payments do not have knowledge of the origin or destination. These make such payments more private unlike bitcoin transactions where such transactions are public while the users are anonymous.

Fees in lightning network are very low because they are paid for routing payments unlike in Bitcoin. While miners in the Bitcoin network usually order transactions according to the highest fees per unit (bytes) of transaction weight, nodes on the lightning network with lower fees for routing are more attractive to route payments.

You may not necessarily understand the technical details of how lightning work but it exists to make to make it easier for you to make secure, cheap and faster transactions. There are many implementations of lightning wallets such as Eclair, c-lightning, lnd, muun amongst others that will make it easier for you to use bitcoin for your payments.

Thank you for reading and I welcome your comments.

Top comments (0)