Skip to content

Commit c814cd0

Browse files
committed
wallet/invoice: remove indirection.
We can expose the dbid, rather than pretending we have some "struct invoice" which is actually just the dbid. And don't have a pile of "wallet_" wrappers for redirection. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent c7026e5 commit c814cd0

File tree

8 files changed

+269
-635
lines changed

8 files changed

+269
-635
lines changed

lightningd/invoice.c

Lines changed: 83 additions & 83 deletions
Large diffs are not rendered by default.

lightningd/invoice.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,36 @@ struct htlc_set;
99
struct lightningd;
1010
struct sha256;
1111

12+
/* The information about an invoice */
13+
struct invoice_details {
14+
/* Current invoice state */
15+
enum invoice_status state;
16+
/* Preimage for this invoice */
17+
struct preimage r;
18+
/* Hash of preimage r */
19+
struct sha256 rhash;
20+
/* Label assigned by user */
21+
const struct json_escape *label;
22+
/* NULL if they specified "any" */
23+
struct amount_msat *msat;
24+
/* Absolute UNIX epoch time this will expire */
25+
u64 expiry_time;
26+
/* Set if state == PAID; order to be returned by waitanyinvoice */
27+
u64 pay_index;
28+
/* Set if state == PAID; amount received */
29+
struct amount_msat received;
30+
/* Set if state == PAID; time paid */
31+
u64 paid_timestamp;
32+
/* BOLT11 or BOLT12 encoding for this invoice */
33+
const char *invstring;
34+
35+
/* The description of the payment. */
36+
char *description;
37+
/* The features, if any (tal_arr) */
38+
u8 *features;
39+
/* The offer this refers to, if any. */
40+
struct sha256 *local_offer_id;
41+
};
1242

1343
/**
1444
* invoice_check_payment - check if this payment would be valid

lightningd/test/run-invoice-select-inchan.c

Lines changed: 72 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,78 @@ u8 *invoice_path_id(const tal_t *ctx UNNEEDED,
354354
const struct secret *base_secret UNNEEDED,
355355
const struct sha256 *payment_hash UNNEEDED)
356356
{ fprintf(stderr, "invoice_path_id called!\n"); abort(); }
357+
/* Generated stub for invoices_create */
358+
bool invoices_create(struct invoices *invoices UNNEEDED,
359+
u64 *inv_dbid UNNEEDED,
360+
const struct amount_msat *msat TAKES UNNEEDED,
361+
const struct json_escape *label TAKES UNNEEDED,
362+
u64 expiry UNNEEDED,
363+
const char *b11enc UNNEEDED,
364+
const char *description UNNEEDED,
365+
const u8 *features UNNEEDED,
366+
const struct preimage *r UNNEEDED,
367+
const struct sha256 *rhash UNNEEDED,
368+
const struct sha256 *local_offer_id UNNEEDED)
369+
{ fprintf(stderr, "invoices_create called!\n"); abort(); }
370+
/* Generated stub for invoices_delete */
371+
bool invoices_delete(struct invoices *invoices UNNEEDED, u64 inv_dbid UNNEEDED)
372+
{ fprintf(stderr, "invoices_delete called!\n"); abort(); }
373+
/* Generated stub for invoices_delete_description */
374+
bool invoices_delete_description(struct invoices *invoices UNNEEDED,
375+
u64 inv_dbid UNNEEDED)
376+
{ fprintf(stderr, "invoices_delete_description called!\n"); abort(); }
377+
/* Generated stub for invoices_delete_expired */
378+
void invoices_delete_expired(struct invoices *invoices UNNEEDED,
379+
u64 max_expiry_time UNNEEDED)
380+
{ fprintf(stderr, "invoices_delete_expired called!\n"); abort(); }
381+
/* Generated stub for invoices_find_by_label */
382+
bool invoices_find_by_label(struct invoices *invoices UNNEEDED,
383+
u64 *inv_dbid UNNEEDED,
384+
const struct json_escape *label UNNEEDED)
385+
{ fprintf(stderr, "invoices_find_by_label called!\n"); abort(); }
386+
/* Generated stub for invoices_find_by_rhash */
387+
bool invoices_find_by_rhash(struct invoices *invoices UNNEEDED,
388+
u64 *inv_dbid UNNEEDED,
389+
const struct sha256 *rhash UNNEEDED)
390+
{ fprintf(stderr, "invoices_find_by_rhash called!\n"); abort(); }
391+
/* Generated stub for invoices_find_unpaid */
392+
bool invoices_find_unpaid(struct invoices *invoices UNNEEDED,
393+
u64 *inv_dbid UNNEEDED,
394+
const struct sha256 *rhash UNNEEDED)
395+
{ fprintf(stderr, "invoices_find_unpaid called!\n"); abort(); }
396+
/* Generated stub for invoices_get_details */
397+
struct invoice_details *invoices_get_details(const tal_t *ctx UNNEEDED,
398+
struct invoices *invoices UNNEEDED,
399+
u64 inv_dbid UNNEEDED)
400+
{ fprintf(stderr, "invoices_get_details called!\n"); abort(); }
401+
/* Generated stub for invoices_iterate */
402+
bool invoices_iterate(struct invoices *invoices UNNEEDED,
403+
struct invoice_iterator *it UNNEEDED)
404+
{ fprintf(stderr, "invoices_iterate called!\n"); abort(); }
405+
/* Generated stub for invoices_iterator_deref */
406+
const struct invoice_details *invoices_iterator_deref(
407+
const tal_t *ctx UNNEEDED, struct invoices *invoices UNNEEDED,
408+
const struct invoice_iterator *it UNNEEDED)
409+
{ fprintf(stderr, "invoices_iterator_deref called!\n"); abort(); }
410+
/* Generated stub for invoices_resolve */
411+
bool invoices_resolve(struct invoices *invoices UNNEEDED,
412+
u64 inv_dbid UNNEEDED,
413+
struct amount_msat received UNNEEDED)
414+
{ fprintf(stderr, "invoices_resolve called!\n"); abort(); }
415+
/* Generated stub for invoices_waitany */
416+
void invoices_waitany(const tal_t *ctx UNNEEDED,
417+
struct invoices *invoices UNNEEDED,
418+
u64 lastpay_index UNNEEDED,
419+
void (*cb)(const u64 * UNNEEDED, void*) UNNEEDED,
420+
void *cbarg UNNEEDED)
421+
{ fprintf(stderr, "invoices_waitany called!\n"); abort(); }
422+
/* Generated stub for invoices_waitone */
423+
void invoices_waitone(const tal_t *ctx UNNEEDED,
424+
struct invoices *invoices UNNEEDED,
425+
u64 inv_dbid UNNEEDED,
426+
void (*cb)(const u64 * UNNEEDED, void*) UNNEEDED,
427+
void *cbarg UNNEEDED)
428+
{ fprintf(stderr, "invoices_waitone called!\n"); abort(); }
357429
/* Generated stub for json_add_address */
358430
void json_add_address(struct json_stream *response UNNEEDED, const char *fieldname UNNEEDED,
359431
const struct wireaddr *addr UNNEEDED)
@@ -864,79 +936,6 @@ bool wallet_htlcs_load_out_for_channel(struct wallet *wallet UNNEEDED,
864936
/* Generated stub for wallet_init_channels */
865937
bool wallet_init_channels(struct wallet *w UNNEEDED)
866938
{ fprintf(stderr, "wallet_init_channels called!\n"); abort(); }
867-
/* Generated stub for wallet_invoice_create */
868-
bool wallet_invoice_create(struct wallet *wallet UNNEEDED,
869-
struct invoice *pinvoice UNNEEDED,
870-
const struct amount_msat *msat TAKES UNNEEDED,
871-
const struct json_escape *label TAKES UNNEEDED,
872-
u64 expiry UNNEEDED,
873-
const char *b11enc UNNEEDED,
874-
const char *description UNNEEDED,
875-
const u8 *features UNNEEDED,
876-
const struct preimage *r UNNEEDED,
877-
const struct sha256 *rhash UNNEEDED,
878-
const struct sha256 *local_offer_id UNNEEDED)
879-
{ fprintf(stderr, "wallet_invoice_create called!\n"); abort(); }
880-
/* Generated stub for wallet_invoice_delete */
881-
bool wallet_invoice_delete(struct wallet *wallet UNNEEDED,
882-
struct invoice invoice UNNEEDED)
883-
{ fprintf(stderr, "wallet_invoice_delete called!\n"); abort(); }
884-
/* Generated stub for wallet_invoice_delete_description */
885-
bool wallet_invoice_delete_description(struct wallet *wallet UNNEEDED,
886-
struct invoice invoice UNNEEDED)
887-
{ fprintf(stderr, "wallet_invoice_delete_description called!\n"); abort(); }
888-
/* Generated stub for wallet_invoice_delete_expired */
889-
void wallet_invoice_delete_expired(struct wallet *wallet UNNEEDED,
890-
u64 max_expiry_time UNNEEDED)
891-
{ fprintf(stderr, "wallet_invoice_delete_expired called!\n"); abort(); }
892-
/* Generated stub for wallet_invoice_details */
893-
struct invoice_details *wallet_invoice_details(const tal_t *ctx UNNEEDED,
894-
struct wallet *wallet UNNEEDED,
895-
struct invoice invoice UNNEEDED)
896-
{ fprintf(stderr, "wallet_invoice_details called!\n"); abort(); }
897-
/* Generated stub for wallet_invoice_find_by_label */
898-
bool wallet_invoice_find_by_label(struct wallet *wallet UNNEEDED,
899-
struct invoice *pinvoice UNNEEDED,
900-
const struct json_escape *label UNNEEDED)
901-
{ fprintf(stderr, "wallet_invoice_find_by_label called!\n"); abort(); }
902-
/* Generated stub for wallet_invoice_find_by_rhash */
903-
bool wallet_invoice_find_by_rhash(struct wallet *wallet UNNEEDED,
904-
struct invoice *pinvoice UNNEEDED,
905-
const struct sha256 *rhash UNNEEDED)
906-
{ fprintf(stderr, "wallet_invoice_find_by_rhash called!\n"); abort(); }
907-
/* Generated stub for wallet_invoice_find_unpaid */
908-
bool wallet_invoice_find_unpaid(struct wallet *wallet UNNEEDED,
909-
struct invoice *pinvoice UNNEEDED,
910-
const struct sha256 *rhash UNNEEDED)
911-
{ fprintf(stderr, "wallet_invoice_find_unpaid called!\n"); abort(); }
912-
/* Generated stub for wallet_invoice_iterate */
913-
bool wallet_invoice_iterate(struct wallet *wallet UNNEEDED,
914-
struct invoice_iterator *it UNNEEDED)
915-
{ fprintf(stderr, "wallet_invoice_iterate called!\n"); abort(); }
916-
/* Generated stub for wallet_invoice_iterator_deref */
917-
const struct invoice_details *wallet_invoice_iterator_deref(const tal_t *ctx UNNEEDED,
918-
struct wallet *wallet UNNEEDED,
919-
const struct invoice_iterator *it UNNEEDED)
920-
{ fprintf(stderr, "wallet_invoice_iterator_deref called!\n"); abort(); }
921-
/* Generated stub for wallet_invoice_resolve */
922-
bool wallet_invoice_resolve(struct wallet *wallet UNNEEDED,
923-
struct invoice invoice UNNEEDED,
924-
struct amount_msat received UNNEEDED)
925-
{ fprintf(stderr, "wallet_invoice_resolve called!\n"); abort(); }
926-
/* Generated stub for wallet_invoice_waitany */
927-
void wallet_invoice_waitany(const tal_t *ctx UNNEEDED,
928-
struct wallet *wallet UNNEEDED,
929-
u64 lastpay_index UNNEEDED,
930-
void (*cb)(const struct invoice * UNNEEDED, void*) UNNEEDED,
931-
void *cbarg UNNEEDED)
932-
{ fprintf(stderr, "wallet_invoice_waitany called!\n"); abort(); }
933-
/* Generated stub for wallet_invoice_waitone */
934-
void wallet_invoice_waitone(const tal_t *ctx UNNEEDED,
935-
struct wallet *wallet UNNEEDED,
936-
struct invoice invoice UNNEEDED,
937-
void (*cb)(const struct invoice * UNNEEDED, void*) UNNEEDED,
938-
void *cbarg UNNEEDED)
939-
{ fprintf(stderr, "wallet_invoice_waitone called!\n"); abort(); }
940939
/* Generated stub for wallet_offer_find */
941940
char *wallet_offer_find(const tal_t *ctx UNNEEDED,
942941
struct wallet *w UNNEEDED,

0 commit comments

Comments
 (0)