2020-12-14 11:51:48 +10:30
lightning-createinvoice -- Low-level invoice creation
=====================================================
SYNOPSIS
--------
2020-12-15 10:13:42 +10:30
**createinvoice** *invstring* *label* *preimage*
2020-12-14 11:51:48 +10:30
DESCRIPTION
-----------
The **createinvoice** RPC command signs and saves an invoice into the
database.
doc: Correct `createinvoice`'s `invstring` description
The existing description is incorrect. `createinvoice` doesn't actually
work when supplied with a custom-encoded bolt11 invoice without the
final 520 signature bits appended. If a users tries to do so, some of
their tagged fields will be incorrectly truncated.
`createinvoice` actually expects that the signatures are there, and it
simply ignores them.
See common/bolt11.c's bolt11_decode_nosig:
/* BOLT #11:
*
* The data part of a Lightning invoice consists of multiple sections:
*
* 1. `timestamp`: seconds-since-1970 (35 bits, big-endian)
* 1. zero or more tagged parts
* 1. `signature`: Bitcoin-style signature of above (520 bits)
*/
if (!pull_uint(&hu5, &data, &data_len, &b11->timestamp, 35))
return decode_fail(b11, fail, "Can't get 35-bit timestamp");
> while (data_len > 520 / 5) {
const char *problem = NULL;
u64 type, data_length;
2022-11-07 12:20:19 -05:00
The *invstring* parameter is of bolt11 form, but the final signature
is ignored. Minimal sanity checks are done. (Note: if
2021-01-14 14:06:59 +10:30
**experimental-offers** is enabled, *invstring* can actually be an
unsigned bolt12 invoice).
2020-12-14 11:51:48 +10:30
The *label* must be 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.
2020-12-15 10:13:42 +10:30
The *preimage* is the preimage to supply upon successful payment of
the invoice.
2020-12-14 11:51:48 +10:30
RETURN VALUE
------------
2021-05-26 15:20:01 +09:30
(Note: the return format is the same as lightning-listinvoices(7)).
[comment]: # (GENERATE-FROM-SCHEMA-START)
On success, an object is returned, containing:
2022-09-06 07:03:09 +09:30
2021-05-26 15:20:01 +09:30
- **label** (string): the label for the invoice
2023-01-30 16:54:16 +10:30
- **payment\_hash** (hash): the hash of the *payment\_preimage* which will prove payment
2021-05-26 15:20:01 +09:30
- **status** (string): Whether it has been paid, or can no longer be paid (one of "paid", "expired", "unpaid")
- **description** (string): Description extracted from **bolt11** or **bolt12**
2022-09-06 07:15:06 +09:30
- **expires\_at** (u64): UNIX timestamp of when invoice expires (or expired)
2021-05-26 15:20:01 +09:30
- **bolt11** (string, optional): the bolt11 string (always present unless **bolt12** is)
- **bolt12** (string, optional): the bolt12 string instead of **bolt11** (**experimental-offers** only)
2022-09-06 07:15:06 +09:30
- **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)
2023-01-30 16:54:16 +10:30
- **payment\_preimage** (secret, optional): the proof of payment: SHA256 of this **payment\_hash**
2022-09-06 07:15:06 +09:30
- **local\_offer\_id** (hex, optional): the *id* of our offer which created this invoice (**experimental-offers** only). (always 64 characters)
2022-11-10 21:03:13 -05:00
- **invreq\_payer\_note** (string, optional): the optional *invreq\_payer\_note* from invoice\_request which created this invoice (**experimental-offers** only).
2021-09-03 19:37:59 +09:30
2021-05-26 15:20:01 +09:30
[comment]: # (GENERATE-FROM-SCHEMA-END)
2020-12-14 11:51:48 +10:30
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.
SEE ALSO
--------
lightning-invoice(7), lightning-listinvoices(7), lightning-delinvoice(7),
2021-05-26 15:20:01 +09:30
lightning-getroute(7), lightning-sendpay(7), lightning-offer(7).
2020-12-14 11:51:48 +10:30
RESOURCES
---------
Main web site: < https: / / github . com / ElementsProject / lightning >
2023-01-30 16:54:16 +10:30
[comment]: # ( SHA256STAMP:fffebe36aa6671261082894e8b1429035c08f797064a60b03e3e9ea10ea71038)