How Lightning Invoices Work: Decoding BOLT11 Step by Step
This article was translated from Japanese with AI. Read the original (日本語) · Report a translation issue
When you send or receive payments over the Lightning Network, have you ever come across a string like the one below?
lnbc20m1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqsfpp3qjmp7lwpagxun9pygexvgpjdc4jdj85fr9yq20q82gphp2nflc7jtzrcazrra7wwgzxqc8u7754cdlpfrmccae92qgzqvzq2ps8pqqqqqqpqqqqq9qqqvpeuqafqxu92d8lr6fvg0r5gv0heeeqgcrqlnm6jhphu9y00rrhy4grqszsvpcgpy9qqqqqqgqqqqq7qqzq9qrsgqdfjcdk6w3ak5pca9hwfwfh63zrrz06wwfya0ydlzpgzxkn5xagsqz7x9j4jwe7yj7vaf2k9lqsdk45kts2fd0fkr28am0u4w95tt2nsq76cqw0
This is called a Lightning invoice: a payment request that contains the information needed for the transfer.
It is usually generated when the person receiving the payment presses the "Receive" button in their wallet.
This article covers the basics of invoices, breaks down the information they contain, and even shares some lesser-known trivia along the way.

The "Lightning Decoder" above is a site that decodes invoices. Comparing its output with the explanations in this article should make things easier to follow, so feel free to use it alongside.
Let's get into it.
What is an invoice?
An invoice is a payment request for the Lightning Network, defined in BOLT #11.
When creating one, the recipient generates a piece of secret data called the "preimage" and includes its hash (payment_hash) in the invoice. The preimage is secret information that must not be revealed to anyone until the very moment the payment completes, and using it as the key is what guarantees the atomicity of the payment.
If you want to learn more about how the preimage is involved in payments, see this article.
The basic structure of a Lightning invoice
An invoice consists of a human-readable part and a data part, and is encoded in Bech32. It is normally written entirely in lowercase, but when turned into a QR code it is often written in uppercase for better space efficiency.
The main components of an invoice are as follows.
Human-readable part
- Prefix
- Amount
Data part
- Timestamp
- Tagged fields (zero or more)
- Signature
Between the human-readable part and the data part sits the digit "1". It acts as the separator defined by Bech32.

Prefix
An invoice begins with ln, which stands for Lightning Network, followed by a dedicated identifier, modeled on the definitions in BIP173, that indicates the network, such as mainnet or testnet.
lnbc: Bitcoin Mainnet
lntb: Testnet Bitcoin
lntbs: Bitcoin Signet
lnbcrt: Bitcoin regtest
In other words, when you receive a payment on Lightning mainnet, the invoice will always start with lnbc, so it's a good idea to check.
Amount
After the prefix comes the part that represents the amount.
Normally the recipient specifies an amount when creating an invoice, but it's also possible to create one without an amount. In other words, this part can be skipped.
Amounts are denominated in BTC rather than satoshis (sats). To save space, they are expressed with multipliers: for example, 1 sat is written as 10n, 100 sats as 1u, and 1 msat as 10p.
| Unit | Multiplier | In sats |
|---|---|---|
| m (milli) | 0.001 | 100,000 |
| u (micro) | 0.000001 | 100 |
| n (nano) | 0.000000001 | 0.1 |
| p (pico) | 0.000000000001 | 0.0001 |
Timestamp
The data part begins with a 35-bit timestamp.
The timestamp is the time elapsed since 00:00 UTC on January 1, 1970, commonly known as epoch seconds (Unix time / Unix timestamp).
Since Bech32 encodes 5 bits per character, 35 ÷ 5 = 7, which means the timestamp is represented by exactly 7 alphanumeric characters.
Tagged fields
Tagged fields are data units in TLV (Type-Length-Value) format that can store information used when making the payment.
Their basic structure consists of three elements in the order type, data_length, data.
| Element | Size | Contents |
|---|---|---|
type |
5 bits | What kind of information it is (identifier) |
data_length |
10 bits | Length of data |
data |
data_length × 5 bits |
The actual contents |
Everything is in 5-bit units because Bech32 encoding represents 5 bits per character (32 possible characters).
Currently defined tagged fields
The currently defined tagged fields are listed below. To create an invoice, p (payment_hash) and s (payment_secret) are required. In addition, exactly one of d (short description) or h (description hash) must be included.
| Type character | Field name | Contents |
|---|---|---|
p | payment_hash | 256-bit SHA256 payment_hash. Its preimage is revealed later in the payment process and serves as proof of payment. |
s | payment_secret | 256-bit secret. Prevents forwarding nodes from probing for the recipient. |
d | description | A short description of the payment's purpose in UTF-8, e.g., "one cup of coffee." If this field is not set, the h tag must be used instead. |
m | metadata | Additional metadata to attach to the payment. |
n | node_id | Can contain the 33-byte public key of the recipient's node. |
h | hash | If the description doesn't fit in the d field, the hash of a longer description can be included here. How the full description is communicated is not specified here. |
x | expiry | Expiry time in seconds. The default is 3600 seconds. |
c | cltv | min_final_cltv_expiry_delta for the last HTLC in the route. The default is usually 18. |
f | fallback | Can contain an on-chain fallback address in case the Lightning payment fails for some reason. |
r | route hints | One or more entries containing additional routing information for private routes. Each route hint contains: • pubkey (264 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 | features | One or more 5-bit values indicating the features supported or required to receive this payment. |
The advantage of the Type-Length-Value format is that when a reader encounters a type it doesn't recognize, it can look at data_length and know it can safely skip that many bits (the length of the data). This means new fields (types) can be added in the future without breaking older implementations.
Signature
At the end of the invoice is a 520-bit digital signature made with the recipient's private key. The signature is created over the SHA256 hash of the human-readable part plus the data part (excluding the signature), so if even a single character of the invoice is tampered with, the signature will no longer match.
Since Bech32 uses 5 bits per character, 520 ÷ 5 = 104 characters, which appear as the signature right at the end of the invoice (just before the checksum).
Summary
A Lightning invoice is a payment request defined in BOLT #11 and encoded in Bech32 format.
It is broadly divided into two parts, the human-readable part (prefix + amount) and the data part (timestamp + tagged fields + signature), separated by 1.
- Prefix: Indicates the network, e.g.,
lnbc. - Amount: Expresses a BTC-denominated amount concisely using the
m/u/n/pmultipliers. Can be omitted. - Timestamp: Records the time of creation in epoch seconds (35 bits).
- Tagged fields: Store variable supplementary information in TLV format, such as
p(payment_hash) andd(description). - Signature: A 520-bit digital signature made with the recipient's private key that detects any tampering with the contents.
Thanks to these mechanisms, a Lightning invoice can convey who to pay, how much, for what, and by when in a single compact, tamper-resistant string.

