mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-02 22:04:23 +01:00
So far we were tracking the status by including it either in the paid or the unpaid list. This refactor makes the state explicit, which matches the planned DB schema much better. Signed-off-by: Christian Decker <decker.christian@gmail.com>
45 lines
1020 B
C
45 lines
1020 B
C
#ifndef LIGHTNING_LIGHTNINGD_INVOICE_H
|
|
#define LIGHTNING_LIGHTNINGD_INVOICE_H
|
|
#include "config.h"
|
|
#include <bitcoin/preimage.h>
|
|
#include <ccan/crypto/sha256/sha256.h>
|
|
#include <ccan/list/list.h>
|
|
#include <ccan/tal/tal.h>
|
|
|
|
struct invoices;
|
|
struct lightningd;
|
|
|
|
/* /!\ This is a DB ENUM, please do not change the numbering of any
|
|
* already defined elements (adding is ok) /!\ */
|
|
enum invoice_status {
|
|
UNPAID,
|
|
PAID,
|
|
};
|
|
|
|
struct invoice {
|
|
u64 id;
|
|
enum invoice_status state;
|
|
struct list_node list;
|
|
const char *label;
|
|
u64 msatoshi;
|
|
struct preimage r;
|
|
struct sha256 rhash;
|
|
};
|
|
|
|
#define INVOICE_MAX_LABEL_LEN 128
|
|
|
|
/* From database */
|
|
void invoice_add(struct invoices *i,
|
|
const struct preimage *r,
|
|
u64 msatoshi,
|
|
const char *label,
|
|
enum invoice_status state);
|
|
|
|
void resolve_invoice(struct lightningd *ld, struct invoice *invoice);
|
|
|
|
struct invoice *find_unpaid(struct invoices *i,
|
|
const struct sha256 *rhash);
|
|
|
|
struct invoices *invoices_init(const tal_t *ctx);
|
|
#endif /* LIGHTNING_LIGHTNINGD_INVOICE_H */
|