Featured Partner

What Information Does A Lightning Network Invoice Contain?

Featured Partner Contributor
Font Size:

The best way to understand What is a Lightning Network Invoice is to correlate it with regular normal invoices. A lightning invoice has the same purpose as normal invoices as they request payment. 

The lightning invoice and the address are similar in that both are sent from the payee to the payer to facilitate payment. The length of lightning invoices makes it common to represent them as QR codes.

A lightning invoice contains information regarding the payment amount, payment destination, metadata, and a message. 

In this blog, let us find out what information is contained in lightning invoices.

An example of a Lightning invoice

Lightning invoices are payment requests sent over the Lightning Network. You will find a description, an amount in Bitcoin to pay, and a URL for making the payment on the payment request URL.

An example of a Lightning invoice would be this: “The following URL requires 0.001 BTC: lnbc100u1pwfzpwpp5stmjf95pzmnn8nhgq9f9qd3q3z2k8lgw3zjqh4q7q2s4s9qdgqyqcqzysxqhq0gj7e3qjqhvj6yh8d45pfjy9z0vj7hkxz8jfk92u.”

Scheme for URIs

A lightning invoice can be prefixed with Lightning: to indicate which software can be used to pay it. The URI scheme allows your browser or operating system to redirect you to your Lightning wallet, where you can confirm payment by following a Lightning link. 

Lightning Invoices

Lightning invoices have a human-readable part and a data part.

A case-sensitive approach

Lightning Network invoices are typically all lowercase, like other bech32 encoded strings. QR codes can save space by encoding only uppercase characters, which is why you might see more uppercase Lightning invoices. QR codes for lightning invoices may only decode in uppercase.

Prefixes

Lightning invoices start with ln for Lightning Network. A native Segwit address is identified by two letters:

  • Bc for Bitcoin
  • Tb for Testnet Bitcoin
  • Bs for Bitcoin Signet
  • Bcrt for Bitcoin Regtest

The invoice must also include the appropriate checksum at the end since it is Bech32 encoded.

The amount

Prefixes are followed by amounts. Lightning invoices typically include an amount, but invoices without amounts are possible. Lightning Invoices refer to bitcoin, not satoshi. 

Adding a multiplier to an amount is possible to make round invoices more space-efficient. A Lightning invoice for a single satoshi would appear as 10n, a hundred satoshi as 1u, and a milli-satoshi as 10p.

Lightning invoice prefixes and amounts are human-readable, so savvy users can immediately identify them as Lightning invoices.

Timestamp

In the data part, Unix timestamps constitute the first element.

Tagged

It’s possible to add another piece of information with tags. Payees have to provide some data, but other data can be optional.

Fields defined as yet include the following

p (1): Payment_hash SHA256 with 256 bits. Later, a preimage is revealed during payment and can be proof of purchase.

s (16): Forwarding nodes are prohibited from probing the payment recipient using a 256-bit secret.

d (13): The purpose of payment may be described herein UTF-8, for example, ‘1 cup of coffee’ or a cup of coffee. The tag h must be used instead if this field is not set.

n (19): The payee node’s 33-byte public key can go here.

h (23): Field d may include a hash of the longer description if there is not enough space. There needs to be a description of how the full description is communicated in this document.

x (6): Seconds until expiration.

c (24): This is the last HTLC’s min_final_cltv_expiry. It is usually set to 18.

f (9): Lightning payments can fail for any reason so you can include a fallback on-chain address.

r (3): This entry contains extra routing information for a private route. Here are the routing hints: 

The public key (264 bits)

short_channel_id (64 bits)

short_channel_id (64 bits)

  • fee_base_msat (32 bits, big-endian)
  • fee_proportional_millionths (32 bits, big-endian)
  • cltv_expiry_delta (16 bits, big-endian)
  • 9 (5): This 5-bit value contains the features this payment supports or requires.

A signature

The invoice will be signed as the last step. The invoice has a public key so you can verify the signature.

Link (LNURL)

LNURLs, or Lightning Network URLs, are proposed standards for Lightning payer-payee interactions.

LNURLs are bech32 encoded URLs that are prefixed with Inurl. Typically, Lightning wallets will decode URLs and contact URLs and wait for a JSON object containing instructions, including the Inurl tag.

Most commonly, LNURLs initiate withdrawals or create static payment links.

Members of the editorial and news staff of the Daily Caller were not involved in the creation of this content.

Tags : fp0132
Featured Partner