invoices: display the payer note if it's for local offer, allow in fetchinvoice.

We don't do it for sendinvoice (yet?).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: `fetchinvoice` can take a payer note, and `listinvoice` will show the payer_notes received.
This commit is contained in:
Rusty Russell
2021-07-02 09:41:35 +09:30
parent 12dd3a439b
commit 2cb16a65c4
12 changed files with 59 additions and 9 deletions

View File

@@ -830,7 +830,7 @@ static struct command_result *json_fetchinvoice(struct command *cmd,
const jsmntok_t *params)
{
struct amount_msat *msat;
const char *rec_label;
const char *rec_label, *payer_note;
struct out_req *req;
struct tlv_invoice_request *invreq;
struct sent *sent = tal(cmd, struct sent);
@@ -847,6 +847,7 @@ static struct command_result *json_fetchinvoice(struct command *cmd,
&invreq->recurrence_start),
p_opt("recurrence_label", param_string, &rec_label),
p_opt_def("timeout", param_number, &timeout, 60),
p_opt("payer_note", param_string, &payer_note),
NULL))
return command_param_failed();
@@ -997,6 +998,12 @@ static struct command_result *json_fetchinvoice(struct command *cmd,
invreq->features
= plugin_feature_set(cmd->plugin)->bits[BOLT11_FEATURE];
/* invreq->payer_note is not a nul-terminated string! */
if (payer_note)
invreq->payer_note = tal_dup_arr(invreq, utf8,
payer_note, strlen(payer_note),
0);
/* Make the invoice request (fills in payer_key and payer_info) */
req = jsonrpc_request_start(cmd->plugin, cmd, "createinvoicerequest",
&invreq_done,