From c35df400b2586656984b1477c1dc30b945890e54 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 18 May 2020 18:47:21 +0200 Subject: [PATCH] paymod: Maintain a list of current and past payments We need to keep them around so we can inspect them later. We'll also need a background cleanup every once in a while to free some memory. More on that in a future commit. --- plugins/libplugin-pay.h | 1 + plugins/pay.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/libplugin-pay.h b/plugins/libplugin-pay.h index 6eb366861..31f8bde0b 100644 --- a/plugins/libplugin-pay.h +++ b/plugins/libplugin-pay.h @@ -103,6 +103,7 @@ enum payment_step { struct payment { /* The command that triggered this payment. */ struct command *cmd; + struct list_node list; const char *json_buffer; const jsmntok_t *json_toks; diff --git a/plugins/pay.c b/plugins/pay.c index 499919f5d..731ace680 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -27,6 +27,8 @@ static struct node_id my_id; static unsigned int maxdelay_default; static LIST_HEAD(pay_status); +static LIST_HEAD(payments); + struct pay_attempt { /* What we changed when starting this attempt. */ const char *why; @@ -1719,7 +1721,7 @@ static struct command_result *json_paymod(struct command *cmd, struct bolt11 *b11; char *fail; struct dummy_data *ddata; - p = payment_new(cmd, cmd, NULL /* No parent */, paymod_mods); + p = payment_new(NULL, cmd, NULL /* No parent */, paymod_mods); ddata = (struct dummy_data*)p->modifier_data[0]; @@ -1763,6 +1765,7 @@ static struct command_result *json_paymod(struct command *cmd, p->destination = p->getroute_destination = &b11->receiver_id; p->payment_hash = tal_dup(p, struct sha256, &b11->payment_hash); payment_start(p); + list_add_tail(&payments, &p->list); return command_still_pending(cmd); }