From 1e6d5d82aa3ec340c2f70f557fed114824b3941e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 21 Nov 2017 16:57:15 +1030 Subject: [PATCH] invoice: record expiry in data structure. We don't enforce it yet, but you can query it. Signed-off-by: Rusty Russell --- lightningd/invoice.c | 4 ++++ lightningd/invoice.h | 1 + 2 files changed, 5 insertions(+) diff --git a/lightningd/invoice.c b/lightningd/invoice.c index 1c96f7de4..58aebaf13 100644 --- a/lightningd/invoice.c +++ b/lightningd/invoice.c @@ -152,6 +152,9 @@ static void json_invoice(struct command *cmd, return; } + /* Expires at this absolute time. */ + invoice->expiry_time = time_now().ts.tv_sec + expiry; + wallet_invoice_save(cmd->ld->wallet, invoice); /* Construct bolt11 string. */ @@ -227,6 +230,7 @@ static void json_add_invoices(struct json_result *response, json_add_hex(response, "rhash", &i->rhash, sizeof(i->rhash)); json_add_u64(response, "msatoshi", i->msatoshi); json_add_bool(response, "complete", i->state == PAID); + json_add_u64(response, "expiry_time", i->expiry_time); json_object_end(response); } } diff --git a/lightningd/invoice.h b/lightningd/invoice.h index ad998d919..2a2473e25 100644 --- a/lightningd/invoice.h +++ b/lightningd/invoice.h @@ -23,6 +23,7 @@ struct invoice { const char *label; u64 msatoshi; struct preimage r; + u64 expiry_time; struct sha256 rhash; };