2017-08-28 17:06:01 +01:00
|
|
|
#ifndef LIGHTNING_LIGHTNINGD_INVOICE_H
|
|
|
|
#define LIGHTNING_LIGHTNINGD_INVOICE_H
|
2016-09-06 08:17:49 +01:00
|
|
|
#include "config.h"
|
2017-02-02 04:05:45 +00:00
|
|
|
#include <bitcoin/preimage.h>
|
2017-06-20 06:45:03 +01:00
|
|
|
#include <ccan/crypto/sha256/sha256.h>
|
|
|
|
#include <ccan/list/list.h>
|
|
|
|
#include <ccan/tal/tal.h>
|
2016-09-06 08:17:49 +01:00
|
|
|
|
2017-01-04 02:48:47 +00:00
|
|
|
struct invoices;
|
2017-08-28 17:09:01 +01:00
|
|
|
struct lightningd;
|
2016-09-06 08:17:49 +01:00
|
|
|
|
2017-10-03 17:31:07 +01:00
|
|
|
/* /!\ This is a DB ENUM, please do not change the numbering of any
|
|
|
|
* already defined elements (adding is ok) /!\ */
|
|
|
|
enum invoice_status {
|
|
|
|
UNPAID,
|
|
|
|
PAID,
|
|
|
|
};
|
|
|
|
|
2016-09-06 08:17:49 +01:00
|
|
|
struct invoice {
|
2017-10-03 17:31:07 +01:00
|
|
|
u64 id;
|
|
|
|
enum invoice_status state;
|
2016-09-06 08:17:49 +01:00
|
|
|
struct list_node list;
|
|
|
|
const char *label;
|
2016-09-06 08:17:49 +01:00
|
|
|
u64 msatoshi;
|
2017-02-02 04:05:45 +00:00
|
|
|
struct preimage r;
|
2017-11-21 06:27:15 +00:00
|
|
|
u64 expiry_time;
|
2016-09-06 08:17:49 +01:00
|
|
|
struct sha256 rhash;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define INVOICE_MAX_LABEL_LEN 128
|
|
|
|
|
|
|
|
/* From database */
|
2017-10-04 13:45:00 +01:00
|
|
|
void invoice_add(struct invoices *invs,
|
|
|
|
struct invoice *inv);
|
2016-09-06 08:17:49 +01:00
|
|
|
|
2017-08-28 17:09:01 +01:00
|
|
|
void resolve_invoice(struct lightningd *ld, struct invoice *invoice);
|
2016-09-06 08:17:49 +01:00
|
|
|
|
2017-01-04 02:48:47 +00:00
|
|
|
struct invoice *find_unpaid(struct invoices *i,
|
2016-09-06 08:17:49 +01:00
|
|
|
const struct sha256 *rhash);
|
2016-09-06 08:17:49 +01:00
|
|
|
|
2017-04-01 11:58:30 +01:00
|
|
|
struct invoices *invoices_init(const tal_t *ctx);
|
2017-08-28 17:06:01 +01:00
|
|
|
#endif /* LIGHTNING_LIGHTNINGD_INVOICE_H */
|