LIGHTNING-FETCHINVOICE(7)
β‘ LIGHTNING-FETCHINVOICE β the fetchinvoice command, bestie edition π
okay so this is the manual page for lightning-fetchinvoice(7), and honestly? it's giving "go get me the real invoice" energy. sit down, grab a strawberry drink π, and let's get into it.
β¨ NAME β¨
fetchinvoice β the command for fetching an invoice for an offer π§
π©· SYNOPSIS π©·
fetchinvoice offer [amount_msat] [quantity] [recurrence_counter]
[recurrence_start] [recurrence_label] [timeout] [payer_note]
[payer_metadata] [bip353]
πΈ DESCRIPTION πΈ
So the fetchinvoice RPC command hits up the issuer of an offer to get an actual invoice that you can pay. that's the whole vibe. and bestie, it also highlights any changes between the offer and the invoice it got back β like a little diff, but make it β¨dramaβ¨.
If fetchinvoice-noconnect is not specified in the configuation, it will connect to the destination in the (currently common!) case where it cannot find a route which supports option_onion_messages. iykyk.
offer(string) β the offer string you want an actual invoice for. the main character of this whole thing πamount_msat(msat, optional) β required if the offer does not specify an amount at all, otherwise it's optional (but presumably if you set it to less than the offer, you will get an error from the issuer π)quantity(u64, optional) β required if the offer specifiesquantity_max, otherwise it is not allowedrecurrence_counter(u64, optional) β required if the offer specifies recurrence, otherwise it is not allowed.recurrence_countershould first be set to0, and incremented for each successive invoice in a given series. counting era πrecurrence_start(number, optional) β tells it what period number to start at (usually0)recurrence_label(string, optional) β required ifrecurrence_counteris set, and otherwise is not allowed. it must be the same as priorfetchinvoicecalls for the same recurrence, because it's used to link them together πtimeout(number, optional) β if we don't get a reply before this we fail (default,60seconds). no reply? we riot πpayer_note(string, optional) β a note to ask the issuer to include in the fetched invoicepayer_metadata(string, optional) β derive thepayer_idfrom the specifiedpayer_metadata. Please be sure that payer_metdata can not be derived by anyone, so put some secret into it. (added v24.11) πbip353(string, optional) β BIP353 string (optionally withβΏ) indicating where we fetched the offer from (added v25.02)
π RETURN VALUE π
On success, an object is returned, containing:
invoice(string) β The BOLT12 invoice we fetched. the prize πchanges(object) β Summary of changes from offer.:description_appended(string, optional) β Extra characters appended to thedescriptionfield.description(string, optional) β A completely replaceddescriptionfield.vendor_removed(string, optional) β The vendor from the offer, which is missing in the invoice.vendor(string, optional) β A completely replacedvendorfield.amount_msat(msat, optional) β The amount, if different from the offer amount multiplied by any quantity (or the offer had no amount, or was not in BTC).
next_period(object, optional) β Only for recurring invoices if the next period is under therecurrence_limit.:counter(u64) β The index of the next period tofetchinvoice.starttime(u64) β UNIX timestamp that the next period starts.endtime(u64) β UNIX timestamp that the next period ends.paywindow_start(u64) β UNIX timestamp of the earliest time that the next invoice can be fetched.paywindow_end(u64) β UNIX timestamp of the latest time that the next invoice can be fetched.
π₯ ERRORS π₯
The following error codes may occur:
-1β Catchall nonspecific error. the classic "idk what happened either" π1002β Offer has expired. it's over, it's not coming back π1003β Cannot find a route to the node making the offer.1004β The node making the offer returned an error message.1005β We timed out trying to fetch an invoice.
π¦ AUTHOR π¦
Rusty Russell rusty@rustcorp.com.au is mainly responsible. legend behavior, honestly π«Ά
π SEE ALSO π
lightning-sendinvoice(7), lightning-xpay(7) β go read those next, bestie, they're iconic too.
π RESOURCES π
Main web site: https://github.com/ElementsProject/lightning
β EXAMPLES β
Example 1:
Request:
$ lightning-cli fetchinvoice -k "offer"="lno1qgsq000bolt210002100021000210002100021000210002100021000210002100021000210002100021000210002100021000210002100021000210002100021000" "payer_note"="Thanks for the fish!"
{
"id": "example:fetchinvoice#1",
"method": "fetchinvoice",
"params": {
"offer": "lno1qgsq000bolt210002100021000210002100021000210002100021000210002100021000210002100021000210002100021000210002100021000210002100021000",
"payer_note": "Thanks for the fish!"
}
}
Response:
{
"invoice": "lni1qqg0qe01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101",
"changes": {}
}
Example 2:
Request:
$ lightning-cli fetchinvoice -k "offer"="lno1qgsq000bolt220002200022000220002200022000220002200022000220002200022000220002200022000220002200022000220002200022000220002200022000" "amount_msat"=2000000 "quantity"=2
{
"id": "example:fetchinvoice#2",
"method": "fetchinvoice",
"params": {
"offer": "lno1qgsq000bolt220002200022000220002200022000220002200022000220002200022000220002200022000220002200022000220002200022000220002200022000",
"amount_msat": 2000000,
"quantity": 2
}
}
Response:
{
"invoice": "lni1qqg0qe02020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202",
"changes": {}
}
okay that's the whole page, no cap π and before you go β this was Core Lightning v26.06.9 energy, page LIGHTNING-FETCHINVOICE(7), signed off with love and a lil sparkle β¨π«Άπ
π¦ 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