Skip to content

Commit

Permalink
fixup! plugin:added invoice creation event
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker committed Apr 28, 2020
1 parent bc5cbf1 commit 5536da5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lightningd/invoice.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,8 @@ static void gossipd_incoming_channels_reply(struct subd *gossipd,
json_add_u64(response, "expires_at", details->expiry_time);
json_add_string(response, "bolt11", details->bolt11);

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

/* Warn if there's not sufficient incoming capacity. */
if (tal_count(info->b11->routes) == 0) {
Expand Down
14 changes: 9 additions & 5 deletions lightningd/notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,16 @@ void notify_invoice_payment(struct lightningd *ld, struct amount_msat amount,
}

static void invoice_creation_notification_serialize(struct json_stream *stream,
struct amount_msat amount,
struct amount_msat *amount,
struct preimage preimage,
const struct json_escape *label)
{
json_object_start(stream, "invoice_creation");
json_add_string(stream, "msat",
type_to_string(tmpctx, struct amount_msat, &amount));
if (amount != NULL)
json_add_string(
stream, "msat",
type_to_string(tmpctx, struct amount_msat, amount));

json_add_hex(stream, "preimage", &preimage, sizeof(preimage));
json_add_escaped_string(stream, "label", label);
json_object_end(stream);
Expand All @@ -156,8 +159,9 @@ static void invoice_creation_notification_serialize(struct json_stream *stream,
REGISTER_NOTIFICATION(invoice_creation,
invoice_creation_notification_serialize)

void notify_invoice_creation(struct lightningd *ld, struct amount_msat amount,
struct preimage preimage, const struct json_escape *label)
void notify_invoice_creation(struct lightningd *ld, struct amount_msat *amount,
struct preimage preimage,
const struct json_escape *label)
{
void (*serialize)(struct json_stream *,
struct amount_msat,
Expand Down
2 changes: 1 addition & 1 deletion lightningd/notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void notify_warning(struct lightningd *ld, struct log_entry *l);
void notify_invoice_payment(struct lightningd *ld, struct amount_msat amount,
struct preimage preimage, const struct json_escape *label);

void notify_invoice_creation(struct lightningd *ld, struct amount_msat amount,
void notify_invoice_creation(struct lightningd *ld, struct amount_msat *amount,
struct preimage preimage, const struct json_escape *label);

void notify_channel_opened(struct lightningd *ld, struct node_id *node_id,
Expand Down

0 comments on commit 5536da5

Please sign in to comment.