A Brief Guide on how to Create Lightning Network Invoices

HashFlare

ComputerUniverse Введи промокод FW7FRUX при покупке и получи скидку 5 евро

Lightning Network capacity increases by 10 BTC in two days, total now at 50 BTC

In this article, BTCManager will go through the information contained in a Lightning Network invoice and do a quick recap of how to create an invoice using Bitcoin’s Lightning Network.

Lightning Network Invoices

Being able to create invoices on the Lightning Network is a novelty that was only recently made possible, but should prove to be a relatively useful innovation. According to BlockFuse, the importance of invoices is that they are capable of streamlining and facilitating payments and as such, it is a much-awaited feature that is finally operational.

The sole purpose of invoices on the Lightning Network is mainly to facilitate payments. An invoice will generally contain the required information to allow for transactions between two parties. Once a Lightning Network invoice is created it is stored on a node which is responsible for managing and storing a Lightning Network invoice database.  

The Lightning Network is a second layer payment protocol that works on top of the Bitcoin, Litecoin and Monero blockchains and was created to deal with the scalability issue. The Lightning Network allows for fast transactions between participating nodes and features a peer-to-peer system for making micropayments of cryptocurrency through an alternative network of bidirectional payment channels without delegating custody of funds.

The Lightning Network also decreases transaction cost since the fees are much lower than on-chain operations.

Creating Invoices on the Lightning Network

A Lightning Network invoice is divided into two main parts; the human-readable part and the data part. Let’s understand how can we read simple information from the Lightning Network invoice.

The first part of the invoice refers to the network, so this is represented by “lnt” which refers to the Bitcoin Test Network. The following information refers to the number of tokens that are being sent which is represented by “1u,” meaning one token unit.

The two parts of the invoice are separated by the number one, and the following strain refers to the rest of the information related to the transaction itself.

These include:

  • When the invoice was created.
  • The node ID which receives the payment.
  • The time of the invoice expiration. Contrary to Bitcoin invoices, Lightning Network invoices have an expiry.
  • A description of this invoice.
  • A backup bitcoin address.
  • A route to make the payment.
  • Other relevant information such a transaction signature

To start using Lightning Network invoice payments, one can use the Lightning Network Daemon which contains the invoice protocol.

Lightning Network Invoices for Business

Some options allow Lightning Network invoices to be leveraged for businesses and applications.  

Fall Back Address Function

As said before, the fall back addresses allows for a Bitcoin (BTC) address to be used as a fail-safe if a transaction fails. By enabling this function all Lightning Network transactions that fail will be issued in an on-chain payment directly to the Bitcoin blockchain.

Description

The Lightning Network invoices allow for a memo line to be added.  This can be used to keep track of where payments are coming from and why.  

Description Hash

This allows for information regarding the payment to be attached to the receipt when you make the payment by scanning the QR code, your Lightning Network wallet stores the description hash. A small business can then upload the itemized receipt to a website which one can look up at a later time by providing the description hash.

AddIndex

AddIndex adds a sequence number to all invoices to keep track of their status. This function is well suited for subscriptions as it can keep track of invoices for which haven’t been paid.

Users can also send invoices using a QR Code.

LN Invoice QR Code

LN Invoice QR Code

(Source: BlockFuse)

To be valid, the invoice needs to have the following information:

  • Destination: The public key of the person receiving the Lightning Network payment.
  • Payment_hash: The hash of the preimage that is used to lock the payment.
  • Num_satoshis: The number of satoshis to be paid.
  • Expiry: Time when your node marks the invoice as invalid.
  • Timestamp: Time when the invoice was created.  
  • Cltv_expiry: Delta to use for time-lock of CLTV extended to the final hop

This is the required information that must be present for an invoice to be valid, but there are a lot of details that can be included, such as a description or a fall back address which acts like a security feature in case the Lightning Network transaction fails.

Lightning Network invoices have shown to behave flexibly as they are capable of providing a lot more information regarding payment. For now, Lightning Network invoices are still a little bit difficult for the average joe to handle, but pretty soon the industry should see new developments that will enable easier ways to use the feature.

Like BTCMANAGER? Send us a tip!
Our Bitcoin Address: 3AbQrAyRsdM5NX5BQh8qWYePEpGjCYLCy4