How to

How To Use Lightning Network: A Guide to Instant, Low-Cost Bitcoin Transactions

Is it difficult to make payments on the Lightning Network? How to open your own Lightning wallet? What to consider when creating a channel? What is routing in the Lightning Network, and how to choose an optimal route? Find the answers to these questions in our article.

is*hosting team 10 Aug 2023 11 min reading
How To Use Lightning Network: A Guide to Instant, Low-Cost Bitcoin Transactions

The Lightning Network, or LN for short, is a decentralized system designed to make instant, high-volume micropayments without the need to entrust third parties with the custody of your funds. As a layer 2 protocol built on top of the Bitcoin blockchain (layer 1), the LN utilizes Bitcoin's robust security features to ensure the safety and reliability of the network.

Unlike Bitcoin's base layer, where transactions can take up to an hour to complete due to the need for block confirmation, the Lightning Network solves the problem of slow speed and high fees for small transfers and micropayments. For example, if you want to pay for a train ticket or buy a coffee using Bitcoin, you'll have to spend about an hour and pay a fairly high fee. Making the same purchase using LN will be much more efficient and profitable.

To overcome these problems, the Lightning Network uses multi-party smart contracts that utilize Bitcoin's built-in scripting capabilities. As a result, payments on the Lightning Network are instant, atomic, and do not require writing to the blockchain. This means they do not require a laborious blockchain validation process to be considered secure. As a payment solution, LN is well suited for a variety of scenarios such as retail point-of-sale transactions, device-to-device money transfers, or any situation where an instant payment is required without the need for third-party confirmation.

In practice, the Lightning Network allows users to send and receive Bitcoin (BTC) with little or no fees. Moreover, its throughput is around 1 million transactions per second (TPS), which is significantly faster than other payment systems such as Solana (65,000 TPS) or Visa (around 24,000 TPS).

As the demand for Bitcoin payments and micropayments grows, it becomes necessary to support higher transaction volumes. However, scaling this demand on a Tier 1 chain would be challenging and could compromise decentralization and reliability. The Lightning Network appears to be a promising solution to efficiently scale Bitcoin without compromising its fundamentals while offering a way to meet the growing demand for reliable and fast transactions. What are the benefits of using Lighting Network?

This article will detail how to set up the Lightning Network, create your Lightning wallet, and transact through payment channels.

Creating a Lightning Wallet and Connecting to the Network

Creating a Lightning Wallet and Connecting to the Network

In order to connect to and use the Lightning Network, users need to set up a Bitcoin wallet that supports Lightning Network features. This involves configuring the wallet software to work with the features and protocols applicable to the Lightning Network.

When choosing a wallet that meets your requirements, you should pay attention to how it interacts with nodes. There are three basic types of interaction with nodes in wallets:

  • Wallets that create and maintain nodes: some wallets create and maintain their own nodes. Such wallets are convenient for those who prefer not to create nodes themselves. Users retain the ability to create and close channels and can request channels from other users. Examples of wallets with this feature are Zap, Eclair, Breez, and Phoenix.
  • Wallets working as ready-made nodes via API: a user creates a node by himself, and the wallet connects to such a node. In this case, users get full control over node and channel management. An example of such a wallet is the popular BlueWallet.
  • Wallets using a common node managed by developers: there are wallets that function by connecting to a common node run and maintained by developers. Such wallets are called custodial wallets. The advantage of such wallets is that users do not have to configure the nodes and channels themselves. However, they must have full trust in the company that provides the wallet, because without the involvement of this custodial service, they will not be able to access their funds. BlueWallet and Wallet of Satoshi are examples of wallets operating on this principle.

Setting up a Lightning Wallet

  • Selecting a Lightning Wallet

Choose the Lightning wallet that fits your needs. There are different options for different platforms (mobile, desktop, or web). Some popular Lightning wallets include BlueWallet, Zap, Phoenix, Eclair, and Joule. Download and install your chosen wallet on your device.

  • Funding your Bitcoin wallet

Before you can use Lightning Network, you must have some amount of Bitcoins (BTC) in your wallet. If you don't already have a Bitcoin wallet, create one by following the instructions provided by your chosen wallet software. Where to store crypto?

  • Launching the Lightning feature

After funding your Bitcoin wallet, you will need to enable the Lightning feature in the wallet application. The process of starting the Lightning feature depends on the wallet you are using, but it usually involves navigating to the wallet settings and selecting the option to enable Lightning.

  • Connecting to a Lightning Node

To start using the Lightning Network, you need to connect to a Lightning node. There are two main ways to do this:

  • A proprietary Lightning node:

If you are using a non-custodial wallet that allows you to run your own Lightning node, you need to set up your own node. This requires installing and configuring Lightning node software such as LND (Lightning Network Daemon) or c-lightning.

  • Third-party Lightning node:

Some Lightning wallets, especially custodial wallets, can connect to a third-party Lightning node on your behalf. In this case, you don't need to set up your own node; the wallet provider takes care of that for you. However, using a third-party node means that you trust the provider with your funds and privacy.

After setting up and funding your Lighting wallet, you can open channels and make transactions on the Lightning Network.

Payment Channels: Creation, Closure, and Capacity

Payment Channels: Creation, Closure, and Capacity

Any transaction in LN is done through the opening of a payment channel, which is a MultiSig wallet that holds a certain amount of Bitcoins. Payment channels are opened after creating and funding your Lightning wallet.

Opening a channel

  • Selecting a counterparty: when selecting a counterparty to open a channel, its Node ID or public key is usually required.
  • Defining channel parameters: Lightning Network channels have several parameters that can be set when they are created. These parameters include:
  1. Channel Capacity: the total amount of funds that can be allocated to a channel.
  2. Initial Channel Balance: The amount of funds deposited by each party when the channel is opened.
  3. Fees: the fee structure for making payments through the channel.
  4. Timelocks: A timelock is a period during which the funds involved in a transaction cannot be used after the channel is closed or updated.
  • Channel Funding: both parties must provide agreed-upon funds for the initial channel capacity. Each party creates a funding transaction by spending funds from their Bitcoin (or other blockchain) balance and sends it to a Multisig address, which blocks the funds.
  • Confirmation of the funding transaction: the funding transaction must be confirmed by receiving sufficient confirmations on the underlying blockchain network. This ensures that the funds are securely locked in the channel.
  • Finalizing the channel opening: once the funding transaction is confirmed, the channel is established and both parties can start making transactions on the Lightning Network.

Closing the channel

  • Joint Closure: If both parties agree to close the channel after all required transactions have been completed, they agree on the final balances between them. A close transaction is created that expends funds from the Multisig address and distributes the channel funds according to the agreed balances. The closing transaction is broadcast to the blockchain for confirmation.
  • Forced Closure: If one party is unresponsive or uncooperative, the other party can initiate a forced closure. In this case, the parties wait for a predetermined dispute timeout to expire (typically a few days) to ensure that the non-responding party cannot challenge the state of the channel. When the timeout expires, the non-cooperating party broadcasts the last channel state (the last commit transaction) to the blockchain. This transaction closes the channel unilaterally.

Channel Capacity Management

Channel capacity management in the Lightning Network is essential to efficiently sending and receiving payments. Proper management allows you to optimize outbound and inbound capacity, ensuring smooth transactions and efficient channel utilization. Let's take a look at some channel capacity management strategies:

  • Open channels with appropriate capacity: when opening a channel, carefully consider the amount you allocate as channel capacity. It should match the expected volume of usage. Opening channels with too much bandwidth can lock up your funds and reduce your ability to open additional channels, while channels with insufficient bandwidth can limit your ability to make payments.
  • Track channel utilization: Monitor channel activity to determine the bandwidth you need. This will help you determine when to open new channels or rebalance existing channels.
  • Perform channel rebalancing: asymmetric channel utilization can lead to unidirectional payment flows, leaving one party running out of capacity and the other with unused funds. To balance your channel, you can initiate circular payments to move funds to where they are needed. For example, if you have channels A-B and B-B, you can make a payment from channel A to channel B, indirectly rebalancing A-B and B-B. Balancing can also be accomplished by performing atomic swaps, i.e., exchange transactions of one cryptocurrency for another. Another way is to use the Lightning Loop service to swap outgoing Lightning transactions for incoming on-chain transactions to increase inbound bandwidth.
  • Consider the network topology: being strategic about which nodes you open channels with can also affect network connectivity and throughput. Connect to well-functioning nodes that are likely to route payments efficiently.

How to make Lightning payments

How to make Lightning payments

Once a channel is created, users have access to public channels throughout the network, and Lightning nodes look for the best route to make the transaction. That's why when a user pays a new merchant, they can do so instantly by simply scanning a QR code, without having to open a direct channel. How does Lightning Network work?

Making a payment through the Lightning Network is as easy as any other digital payment method, and all it takes is the following steps:

Sending Lightning payments

  1. Create an Invoice

    To receive a payment through Lightning, you need to create an invoice. Open your Lightning wallet and find the "Receive" or "Create Invoice" option. Enter the amount requested and any additional information such as a description or expiration date. Once you specify the required details, your wallet will generate a Lightning invoice.
  2. Sending the invoice 

    Once the invoice is created, your Lightning wallet will provide you with a payment request. This request is usually in the form of a QR code or text string containing a payment hash. Send this payment request to the person or entity from whom the payment is expected.
  3. Payment Confirmations

    Once you've shared the invoice, the payer can scan the QR code or copy the payment request into his Lightning Wallet. He will initiate the payment from his wallet to yours.

Receiving Lightning payments

  1. Create a payment

    Open your Lightning Wallet and find the option to make a payment or scan a QR code. Use this feature to scan the QR code of the payer's account or enter a text string manually.
  2. Confirm and submit the payment

    Review the payment details in Wallet, including the amount and payee. After making sure the details are correct, proceed to submit the payment. Your Lightning Wallet will use the Lightning Network to route the payment to the recipient.
  3. Transaction Confirmation

    After submitting the payment, wait for the transaction to be confirmed by the payer's wallet. Once the payment is successfully confirmed, the transaction will be completed.

Although Lighting Network has sufficient security for transactions, it is not completely confidential. If maximum anonymity on the network is important to you, you can use a dedicated IP address thanks to VPN from is*hosting.

Lightning Network Routing

Lightning Network Routing

Routing in the Lightning Network is based on the concept of finding a path between sender and receiver through a network of payment channels. Each payment channel represents a bilateral agreement between two parties to execute an off-chain transaction. These channels can be interconnected to form a network that allows payments to be made through multiple channels.

When a user initiates a payment to another user, the Lightning Network attempts to find the most efficient and cost-effective route through the network to complete the transaction. This process is called routing. Lightning Network nodes that provide routing are called "routers" or "intermediaries."

A sender initiates a payment by creating a Lightning Network payment request. This request contains the payment amount, destination node information, and a unique hash of the payment. Next, the sender node looks at a list of neighboring nodes that are directly connected links to find potential routes to the destination node.

The sender node queries the neighboring nodes for information about their links and available routing capabilities. This request is called Onion Packet and is encrypted at different layers to ensure confidentiality. The query propagates through the Lightning Network, with each node checking its channels and forwarding the query to its neighbors until it reaches the destination node.

As the request propagates through the network, the nodes gather information about the available routes to the destination node. Factors such as channel bandwidth, liquidity, commission, and reliability are taken into account to select the most efficient path for payment.

After reaching the destination node, a response is generated confirming the availability of the destination node and the selected path for payment. This response follows the same path in the reverse direction to the source node, confirming the selected route.

After confirming the route, the source node starts forwarding the payment to intermediate nodes along the path. Each intermediate node checks the incoming payment against the data specified in the Onion Package to ensure the integrity of the payment.

As the payment travels through the channels, the payment channel balances are updated using a mechanism called Hash Time-Locked Contracts (HTLCs). HTLCs provide secure routing of funds without the risk of double-spending or loss.

Once a payment reaches the destination node, the HTLC is considered complete and the destination node confirms the successful completion of the payment. This confirmation follows the same route in the reverse direction to the source node, confirming the completion of the payment.

Throughout the process, if any part of the route becomes unavailable or unresponsive, Lightning Network nodes dynamically explore alternative routes to complete the payment. This routing process ensures fast and efficient payments on the Lightning Network while maintaining the security and privacy of participants.

Selecting the optimal route

Because different transactions may have different requirements and constraints, there is no universally accepted optimal route to complete them. Lightning Network and wallet applications often make routing decisions automatically, considering factors such as channel bandwidth, fees, and node reliability to find appropriate routes for transactions.

  • Channel liquidity: each Lightning Network node maintains a network of channels with other nodes. The liquidity or bandwidth of these channels is critical for routing.
  • Commissions: Lightning Network channels may have different pricing policies set by the channel operators. The commissions of each channel along the path are taken into account when selecting a route. Generally, lower tariffs are preferred, but it is important to weigh them against other factors such as channel liquidity and reliability.
  • Distance and reliability: the distance between nodes and their reliability play an important role in routing decisions. Lightning Network uses onion routing where payment information is encrypted and transmitted through intermediary nodes. Long routes with many hops create additional potential points of failure or delay. Typically, shorter and more direct routes are chosen to improve reliability and reduce the probability of failure.
  • Routing Algorithms: Lightning Network nodes use different routing algorithms to find paths for transactions. Some algorithms prioritize lower fees, while others prioritize shorter paths or a combination of factors. Different routing algorithms may produce different results, so nodes can apply algorithms that match their preferences or are optimized for specific tasks.
  • Network Topology: The overall structure and topology of the network can affect routing decisions. Nodes with more links and channels occupy a central position in the network and can offer more routing options.

Commissions on the Lightning Network

Commissions on the Lightning Network

The Lightning Network uses commissions to incentivize participants to process and route payments through their channels. Commissions are calculated based on the amount transferred and paid to participants who successfully secure a transaction.

When a payment is processed through multiple channels, each network participant involved in routing may charge a small commission. These fees are typically much lower than transaction fees on the Bitcoin blockchain.

There are two types of fees that routing nodes can charge:

Base Fee: This is a flat fee charged for each payment sent over the channel, regardless of the amount of the payment. For example, if a routing node charges a base fee of 1 Satoshi, it will be deducted from every payment it forwards.

Fee Rate: This is a prorated fee based on the value of the payment. It is usually a very small percentage of the payment amount. For example, if the commission rate is 0.0001%, then a payment of 1,000 Satoshi will be charged a fee of 1 Satoshi.

The total commission for a Lightning payment is the sum of the base commissions of all channels used in the payment path, plus the commission rate multiplied by the payment amount in each channel. For example, if a payment is divided into three channels with base commissions of 100 satoshi each and a commission rate of 0.1%, and the payment amount is 10,000 satoshi, the total commission would be (3 * 100) + (10,000 * 0.001) = 300 + 10 = 310 satoshi.

Commissions on the Lightning Network can vary depending on network congestion and channel operators' policies. Some Lightning wallets may give users the option to choose between different commission rate settings, allowing users the flexibility to choose between the speed and cost of payments.

Because commissions can vary from channel to channel and can change over time, it can be difficult to accurately estimate the costs of Lightning payments. However, some wallets and services provide commission estimation tools that can give users an idea of expected transaction costs.

Lightning Network Use Cases

Lightning Network Use Cases

Lightning Network is a revolutionary solution that has become one of the most promising advancements in the cryptocurrency industry. With its capabilities, Lightning Network has spawned a myriad of innovative use cases, changing the way we interact with digital assets.

One example of an LN use case is Satoshi's Place, a collaborative art project that showcases the creative potential of the Lightning Network. Users can paint pixels on a digital canvas using Lightning payments, with a small fee charged for each pixel. This unique approach allows for dynamic artwork where users can create, modify and purchase pixels in real time.

Tippin.me makes it possible to express gratitude for valuable content on social networks such as Twitter. Through integration with Lightning Network, users can instantly send micropayments in the form of tips to content creators, showing their support and gratitude.

The Fold App combines the convenience of spending Bitcoins with the ability to receive them back as rewards. By utilizing the Lightning Network, users can spend Bitcoins at popular retailers and make instant transactions. The in-app rewards system allows users to earn Bitcoins while shopping and then spend the accumulated rewards at participating stores.

LN Markets has revolutionized the world of derivatives trading by using the Lightning Network for Bitcoin-based futures contracts. Lightning payments enable instant settlement, reducing trading fees and providing a smoother user experience than traditional exchanges. Traders can now transact faster, making the market more dynamic and helping to increase liquidity in the ecosystem.

OpenNode is a payment processing tool that allows merchants to accept Lightning Network payments for goods and services. OpenNode enables seamless transactions using Bitcoin and Lightning for online businesses. This use case promotes the acceptance of cryptocurrencies as a viable payment instrument, furthering the proliferation of digital assets.

Bitcoin Beach is an ambitious community initiative succeeding in promoting the use of Bitcoin and the Lightning Network for everyday transactions in El Salvador. Local businesses and individuals accept Bitcoin payments through the Lightning Network, fostering a vibrant and self-sufficient local economy. This pioneering project highlights the potential of the Lightning-based micro-economy and serves as an inspiring example for its wider adoption.

LNURL is a protocol that enables payments on the Lightning Network using QR codes or clickable links. It demonstrates the versatility of this technology. LNURL demonstrates the efficiency and ease of Lightning Network transactions for a variety of usage scenarios, whether paying content creators, participating in an online giveaway, or accessing exclusive content through paywalls.

The Future of Lighting Network

Despite the rapid development and proliferation of the Lightning Network, the network has a number of limitations that affect its effectiveness. For example, the network's capacity is limited by the number of payment channels and the funds locked in those channels. If the network experiences a surge in the number of transactions or usage, it could lead to congestion, higher fees, and slower transactions.

Maintaining sufficient liquidity is also necessary for the efficient operation of the Lightning Network. Liquidity refers to the amount of Bitcoins available in the channels for transactions. An uneven distribution of funds across channels can lead to imbalances, making it difficult to route payments between remote nodes.

While the Lightning Network has made some progress in terms of user-friendly wallets and interfaces, it is still relatively more complex for the average user compared to traditional Bitcoin transactions. Setting up payment channels and managing funds on the Lightning Network may not be as intuitive and straightforward as simple on-chain transactions.

Some aspects of the Lightning Network, such as the need for well-connected and constantly online nodes to facilitate routing, may lead to centralization over time. Large nodes with more liquidity may emerge, raising concerns about possible control and privacy in the network.

Lightning Network creates new attack vectors and risks, e.g., attackers may steal funds through forced channel closure or other forms of mismanagement. While improvements to the protocol are aimed at improving security, the risk of losing funds due to technical or user error still exists.

Nevertheless, despite the limitations and possible risks, the popularity of cryptocurrencies and the transactions conducted on their blockchains is growing, so Lightning Network is one promising solution to help further the development of this area.

As the Lightning Network develops, a growing number of cryptocurrency exchanges, including Kraken, OKEx, Bitstamp, Bitfinex, and the financial trading app Robinhood, are beginning to support it. In particular, Robinhood has announced plans to integrate Lightning Network into its platform to enable faster bitcoin transactions and increase convenience for its users.

In addition, the Lightning Network is becoming more prevalent for everyday transactions. In El Salvador, where bitcoin was recognized as legal tender in June 2021, merchants are using the Lightning Network to facilitate small transactions. State-owned wallet Chivo also plans to integrate the Lightning Network, marking a significant deployment of the technology.

Lightning Network's impact isn't limited to Bitcoin. Blockstream has developed its own implementation of c-Lightning, built in the C programming language, which has become popular among developers. In addition, the well-known cryptocurrency Litecoin has also created its own version of the Lightning Network, known as Litecoin Lightning Network, which continues to grow steadily.

Overall, the Lighting Network is a promising solution despite the limitations and challenges inherent in emerging technologies. With the network's steady growth, as well as new developments that improve its productivity and security, LN has the potential to solve the scalability challenges facing blockchain-based cryptocurrencies.

Personal VPN

Stay anonymous online with a dedicated IP and don't endanger your personal data.

Get $5.00/mo