Skip to content

Commit

Permalink
doc: Correct createinvoice's invstring description
Browse files Browse the repository at this point in the history
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 ElementsProject#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;
  • Loading branch information
dongcarl authored and rustyrussell committed Feb 6, 2023
1 parent 4560781 commit 4998e70
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/lightning-createinvoice.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ DESCRIPTION
The **createinvoice** RPC command signs and saves an invoice into the
database.

The *invstring* parameter is of bolt11 form, but without the final
signature appended. Minimal sanity checks are done. (Note: if
The *invstring* parameter is of bolt11 form, but the final signature
is ignored. Minimal sanity checks are done. (Note: if
**experimental-offers** is enabled, *invstring* can actually be an
unsigned bolt12 invoice).

Expand Down

0 comments on commit 4998e70

Please sign in to comment.