Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions doc/developers-guide/plugin-development/event-notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,19 @@ A notification for topic `invoice_creation` is sent every time an invoice is cre
}
```

If the invoice is associated with a BOLT 12 offer, an `offer_id` field will be present:

```json
{
"invoice_creation": {
"label": "unique-label-for-invoice",
"preimage": "0000000000000000000000000000000000000000000000000000000000000000",
"msat": 10000,
"offer_id": "b1d1062abc09790a68be83e4c257614a57978e4053a954bfee5909ed71e23e03"
}
}
```

Before version `23.11` the `msat` field was a string with msat-suffix, e.g: `"10000msat"`.

### `warning`
Expand Down
6 changes: 3 additions & 3 deletions lightningd/invoice.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ invoice_complete(struct invoice_info *info,
json_add_u64(response, "created_index", details->created_index);

notify_invoice_creation(info->cmd->ld, info->b11->msat,
&info->payment_preimage, info->label);
&info->payment_preimage, info->label, NULL);

if (warning_no_listincoming)
json_add_string(response, "warning_listincoming",
Expand Down Expand Up @@ -1725,7 +1725,7 @@ static struct command_result *json_createinvoice(struct command *cmd,
NULL))
return fail_exists(cmd, label);

notify_invoice_creation(cmd->ld, b11->msat, preimage, label);
notify_invoice_creation(cmd->ld, b11->msat, preimage, label, NULL);
} else {
struct tlv_invoice *inv;
struct sha256 offer_id, *local_offer_id;
Expand Down Expand Up @@ -1822,7 +1822,7 @@ static struct command_result *json_createinvoice(struct command *cmd,
local_offer_id))
return fail_exists(cmd, label);

notify_invoice_creation(cmd->ld, &msat, preimage, label);
notify_invoice_creation(cmd->ld, &msat, preimage, label, local_offer_id);
}

response = json_stream_success(cmd);
Expand Down
10 changes: 7 additions & 3 deletions lightningd/notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,26 +221,30 @@ void notify_invoice_payment(struct lightningd *ld,
static void invoice_creation_notification_serialize(struct json_stream *stream,
const struct amount_msat *amount,
const struct preimage *preimage,
const struct json_escape *label)
const struct json_escape *label,
const struct sha256 *offer_id)
{
if (amount != NULL)
json_add_amount_msat(stream, "msat", *amount);

json_add_preimage(stream, "preimage", preimage);
json_add_escaped_string(stream, "label", label);
if (offer_id)
json_add_sha256(stream, "offer_id", offer_id);
}

REGISTER_NOTIFICATION(invoice_creation)

void notify_invoice_creation(struct lightningd *ld,
const struct amount_msat *amount,
const struct preimage *preimage,
const struct json_escape *label)
const struct json_escape *label,
const struct sha256 *offer_id)
{
struct jsonrpc_notification *n = notify_start(ld, "invoice_creation");
if (!n)
return;
invoice_creation_notification_serialize(n->stream, amount, preimage, label);
invoice_creation_notification_serialize(n->stream, amount, preimage, label, offer_id);
notify_send(ld, n);
}

Expand Down
3 changes: 2 additions & 1 deletion lightningd/notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ void notify_invoice_payment(struct lightningd *ld,
void notify_invoice_creation(struct lightningd *ld,
const struct amount_msat *amount,
const struct preimage *preimage,
const struct json_escape *label);
const struct json_escape *label,
const struct sha256 *offer_id);

void notify_channel_opened(struct lightningd *ld,
const struct node_id *node_id,
Expand Down
3 changes: 2 additions & 1 deletion lightningd/test/run-invoice-select-inchan.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ void notify_disconnect(struct lightningd *ld UNNEEDED, const struct node_id *nod
void notify_invoice_creation(struct lightningd *ld UNNEEDED,
const struct amount_msat *amount UNNEEDED,
const struct preimage *preimage UNNEEDED,
const struct json_escape *label UNNEEDED)
const struct json_escape *label UNNEEDED,
const struct sha256 *offer_id UNNEEDED)
{ fprintf(stderr, "notify_invoice_creation called!\n"); abort(); }
/* Generated stub for notify_invoice_payment */
void notify_invoice_payment(struct lightningd *ld UNNEEDED,
Expand Down
Loading