Browse Source

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.
paymod-02
Christian Decker 5 years ago
parent
commit
c35df400b2
  1. 1
      plugins/libplugin-pay.h
  2. 5
      plugins/pay.c

1
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;

5
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);
}

Loading…
Cancel
Save