LIGHTNING-INVOICE(7)
π LIGHTNING-INVOICE(7) β invoice, aka the "pls pay me" command π
okay so before we even start: this is the lightning-invoice(7) manual page, and it's lowkey the most main-character command in the whole RPC lineup. it's how you ask the entire lightning network for money, and it's genuinely not that deep once you get the vibe. let's go π
β¨ NAME β¨
invoice β the command for accepting payments. yeah. that's it. that's the whole thing. it makes invoices so people can give you sats π«Ά
πΈ SYNOPSIS πΈ
invoice amount_msat label description [expiry] [fallbacks] [preimage]
[exposeprivatechannels] [cltv] [deschashonly]
π¦ DESCRIPTION π¦
so the invoice RPC command does one iconic thing: it creates the expectation of a payment of a given amount of milli-satoshi. basically it slides back a unique token that another lightning daemon can use to pay this invoice. and if there happens to be an incoming channel with the capacity to pay it, that token also carries a route hint description for it. it's giving "here's the map, bestie" πΊοΈβ¨
amount_msat(msat_or_any) β the stringany, which creates an invoice that can be paid with any amount (chaotic, love that for you). otherwise it's a positive value in millisatoshi precision. and it's flexible, so it can be:- a whole number
- a whole number ending in
msatorsat - a number with three decimal places ending in
sat - a number with 1 to 11 decimal places ending in
btc
label(one of) β a unique string or number (which is treated as a string, so01is different from1β yes, fr fr, they're not the same). it is never revealed to other nodes on the lightning network, but it can be used to query the status of this invoice. it's your private little handle for it π- (string)
- (integer)
description(string) β a short description of the purpose of payment, e.g.1 cup of coffee. this value is encoded into the BOLT11 invoice and is viewable by any node you send this invoice to (unlessdeschashonlyis true as described below). it must be UTF-8, and cannot use\uJSON escape codes. so no sneaky escape-code nonsense π«expiry(u64, optional) β the time the invoice is valid for, in seconds. if no value is provided the default of604800(1 week) is used. one whole week to pay up, no pressure πfallbacks(array of strings, optional) β one or more fallback addresses to include in the invoice, in order from most-preferred to least. but heads up: note that these arrays are not currently tracked to fulfill the invoice. so they're decorative, essentially π- (string, optional)
preimage(hex, optional) β a 64-digit hex string to be used as the payment preimage for the created invoice. by default, if unspecified, lightningd will generate a secure pseudorandom preimage seeded from an appropriate entropy source on your system. IMPORTANT: if you specify the preimage, you are responsible to ensure appropriate care for generating using a secure pseudorandom generator seeded with sufficient entropy, and keeping the preimage secret. this parameter is an advanced feature intended for use with cutting-edge cryptographic protocols and should not be used unless explicitly needed. > seriously bestie, this is the "do not touch unless you know exactly what you're doing" zone. if you mess up the entropy or leak the preimage, that's on you, not on me πexposeprivatechannels(one of, optional) β if specified, it overrides the default route hint logic, which will use unpublished channels only if there are no published channels. pick your fighter:- (boolean): if True, unpublished channels are always considered as a route hint candidate; if False, never.
- (array of short_channel_ids): array of short channel ids (or a remote alias) β only those specific channels will be considered candidates, even if they are public or dead-ends.
- (short_channel_id, optional)
- (short_channel_id): if it is a short channel id (e.g.
1x1x3), only this specific channel will be considered candidate, even if it is public or dead-end.
cltv(u32, optional) β if specified, sets themin_final_cltv_expiryfor the invoice. otherwise, it's set to the parametercltv-final. β³deschashonly(boolean, optional) β if True, then the bolt11 returned contains a hash of the description, rather than the description itself. this allows much longer descriptions, but they must be communicated via some other mechanism. the default is False. iykyk π₯
π RETURN VALUE π
on success, an object is returned, containing:
bolt11(string) β the bolt11 string. this is the actual invoice, the thing you send people πpayment_hash(hash) β the hash of thepayment_preimagewhich will prove payment.payment_secret(secret) β thepayment_secretto place in the onion.expires_at(u64) β UNIX timestamp of when the invoice expires.created_index(u64) β 1-based index indicating the order this invoice was created in. (added v23.08 β¨)
the following warnings may also be returned:
warning_capacityβ even using all possible channels, there's not enough incoming capacity to pay this invoice. πwarning_offlineβ there would be enough incoming capacity, but some channels are offline, so there isn't.warning_deadendsβ there would be enough incoming capacity, but some channels are dead-ends (no other public channels from those peers), so there isn't.warning_private_unusedβ there would be enough incoming capacity, but some channels are unannounced andexposeprivatechannelsis false, so there isn't.warning_mppβ there is sufficient capacity, but not in a single channel, so the payer will have to use multi-part payments.
π ERRORS π
on failure, an error is returned and no invoice is created. and this part matters: if the lightning process fails before responding, the caller should use lightning-listinvoices(7) to query whether this invoice was created or not. don't just assume it didn't happen π
the following error codes may occur:
-1β catchall nonspecific error. the "something happened but honestly who knows" of error codes.900β an invoice with the given label already exists.901β an invoice with the given preimage already exists.902β none of the specifiedexposeprivatechannelswere usable.
π§ AUTHOR π§
Rusty Russell rusty@rustcorp.com.au is mainly responsible. thank you king π«Ά
π SEE ALSO π
lightning-listinvoices(7), lightning-delinvoice(7), lightning-xpay(7)
β RESOURCES β
main web site: https://github.com/ElementsProject/lightning
π EXAMPLES π
Example 1:
request:
$ lightning-cli invoice -k "amount_msat"=10000 "label"="lbl_l31" "description"="Invoice description l31"
{
"id": "example:invoice#1",
"method": "invoice",
"params": {
"amount_msat": 10000,
"label": "lbl_l31",
"description": "Invoice description l31"
}
}
response:
{
"payment_hash": "paymenthashinvl0310031003100310031003100310031003100310031003100",
"expires_at": 1739000000,
"bolt11": "lnbcrt100n1pnt2bolt11invl030100000000bolt11invl030100000000bolt11invl030100000000bolt11invl030100000000bolt11invl030100000000bolt11invl030100000000bolt11invl030100000000bolt11invl030100000000bolt11invl030100000000bolt11invl030100000000",
"payment_secret": "paymentsecretinvl00310003100031000310003100031000310003100031000",
"created_index": 2
}
Example 2:
request:
$ lightning-cli invoice -k "amount_msat"="50000msat" "label"="lbl_l32" "description"="l32 description"
{
"id": "example:invoice#2",
"method": "invoice",
"params": {
"amount_msat": "50000msat",
"label": "lbl_l32",
"description": "l32 description"
}
}
response:
{
"payment_hash": "paymenthashinvl0320032003200320032003200320032003200320032003200",
"expires_at": 1739000000,
"bolt11": "lnbcrt100n1pnt2bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000",
"payment_secret": "paymentsecretinvl00032003200320032003200320032003200320032003200",
"created_index": 3
}
and that's the whole page bestie π«Ά this was LIGHTNING-INVOICE(7) straight out of Core Lightning v26.06.9 β go forth, make invoices, get paid, slay. periodt. π
β¨
π¦ where this page comes from
- nixpkgs unstable: clightning 26.06.9
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms