LIGHTNING-CREATEINVOICE(7)

πŸ“¦
version 26.06.9 Β· 2 versions
, in nixpkgs unstable

πŸ’– LIGHTNING-CREATEINVOICE(7): createinvoice, low-level invoice creation πŸ’–

okay bestie, welcome to the group chat for createinvoice β€” low-level invoice creation, no cap. this is LIGHTNING-CREATEINVOICE(7), and we're keeping every single fact exactly while making it make sense. ✨


🌸 NAME 🌸

createinvoice -- Low-level invoice creation


✨ SYNOPSIS ✨

createinvoice invstring label preimage

πŸ’… DESCRIPTION πŸ’…

the createinvoice RPC command signs and saves an invoice into the database. literally. 🫢

  • invstring (string) β€” the bolt11/bolt12 invoice, but the final signature is ignored. Minimal sanity checks are done.
  • label (one of) β€” a unique string or number (which is treated as a string, so 01 is different from 1); it is never revealed to other nodes on the lightning network, but it can be used to query the status of this invoice.:
    • (string)
    • (integer)
  • preimage (hex) β€” the preimage to supply upon successful payment of the invoice.

🫢 RETURN VALUE 🫢

(Note: the return format is the same as lightning-listinvoices(7)). On success, an object is returned, containing:

  • label (string) β€” The label for the invoice.
  • payment_hash (hash) β€” The hash of the payment_preimage which will prove payment.
  • status (string) (one of "paid", "expired", "unpaid") β€” Whether it has been paid, or can no longer be paid.
  • description (string) β€” Description extracted from bolt11 or bolt12.
  • expires_at (u64) β€” UNIX timestamp of when invoice expires (or expired).
  • created_index (u64) β€” 1-based index indicating order this invoice was created in. (added v23.08)
  • bolt11 (string, optional) β€” The bolt11 string (always present unless bolt12 is).
  • bolt12 (string, optional) β€” The bolt12 string instead of bolt11
  • amount_msat (msat, optional) β€” The amount of the invoice (if it has one).
  • pay_index (u64, optional) β€” Incrementing id for when this was paid (status paid only).
  • amount_received_msat (msat, optional) β€” Amount actually received (status paid only).
  • paid_at (u64, optional) β€” UNIX timestamp of when invoice was paid (status paid only).
  • paid_outpoint (object, optional) β€” Outpoint this invoice was paid with (status paid only). (added v23.11):
    • txid (txid) β€” ID of the transaction that paid the invoice (status paid only). (added v23.11)
    • outnum (u32) β€” The 0-based output number of the transaction that paid the invoice (status paid only). (added v23.11)
  • payment_preimage (secret, optional) β€” The proof of payment: SHA256 of this payment_hash.
  • local_offer_id (hex, optional) (always 64 characters) β€” The id of our offer which created this invoice.
  • invreq_payer_note (string, optional) β€” The optional invreq_payer_note from invoice_request which created this invoice.

😭 ERRORS 😭

on failure, an error is returned and no invoice is created. if the lightning process fails before responding, the caller should use lightning-listinvoices(7) to query whether this invoice was created or not. πŸ’€

The following error codes may occur:

  • -1 β€” Catchall nonspecific error.
  • 900 β€” An invoice with the given label already exists.

πŸ‘‘ AUTHOR πŸ‘‘

Rusty Russell rusty@rustcorp.com.au is mainly responsible. main character energy, fr fr πŸ‘‘


πŸ¦‹ SEE ALSO πŸ¦‹

go read these bestie:


🌈 RESOURCES 🌈

Main web site: https://github.com/ElementsProject/lightning


πŸ“ EXAMPLES πŸ“

Example 1:

Request:

$ lightning-cli createinvoice -k "invstring"="lnbcrt100n1pnt2bolt11invl010300000000bolt11invl010300000000bolt11invl010300000000bolt11invl010300000000bolt11invl010300000000bolt11invl010300000000bolt11invl010300000000bolt11invl010300000000bolt11invl010300000000bolt11invl010300000000" "label"="lbl_l13" "preimage"="0101010101010101010101010101010101010101010101010101010101010101"

{
  "id": "example:createinvoice#1",
  "method": "createinvoice",
  "params": {
    "invstring": "lnbcrt100n1pnt2bolt11invl010300000000bolt11invl010300000000bolt11invl010300000000bolt11invl010300000000bolt11invl010300000000bolt11invl010300000000bolt11invl010300000000bolt11invl010300000000bolt11invl010300000000bolt11invl010300000000",
    "label": "lbl_l13",
    "preimage": "0101010101010101010101010101010101010101010101010101010101010101"
  }
}

Response:

{
  "label": "lbl_l13",
  "bolt11": "lnbcrt100n1pnt2bolt11invl020100000000bolt11invl020100000000bolt11invl020100000000bolt11invl020100000000bolt11invl020100000000bolt11invl020100000000bolt11invl020100000000bolt11invl020100000000bolt11invl020100000000bolt11invl020100000000",
  "payment_hash": "paymenthashinvl0210021002100210021002100210021002100210021002100",
  "amount_msat": 100000,
  "status": "unpaid",
  "description": "l13 description",
  "expires_at": 1739000000,
  "created_index": 7
}

bye bestie β€” this LIGHTNING-CREATEINVOICE(7) page is serving Core Lightning v26.06.9 source/version energy; the footer date isn't listed here, so no invented numbers πŸ’œβœ¨

πŸ“¦ where this page comes from