From fbd8cf149501029f343b7248acc856c988588b5a Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 27 May 2020 14:47:13 +0200 Subject: [PATCH] paymod: Keep a copy of the serialized bolt11 in the root payment We frequently query by the bolt11 string, so keeping it around saves us from having to parse the query or serialize the parsed one. --- plugins/libplugin-pay.h | 4 ++++ plugins/pay.c | 1 + 2 files changed, 5 insertions(+) diff --git a/plugins/libplugin-pay.h b/plugins/libplugin-pay.h index f01c9def7..448a00593 100644 --- a/plugins/libplugin-pay.h +++ b/plugins/libplugin-pay.h @@ -202,6 +202,10 @@ struct payment { * attempt. Modifiers need to leave failures alone once this is set to * true. Set only on the root payment. */ bool abort; + + /* Serialized bolt11 string, kept attachd to the root so we can filter + * by the invoice. */ + const char *bolt11; }; struct payment_modifier { diff --git a/plugins/pay.c b/plugins/pay.c index 1261f9d51..71df28dca 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -1780,6 +1780,7 @@ static struct command_result *json_paymod(struct command *cmd, ? tal_dup(p, struct secret, b11->payment_secret) : NULL; p->invoice = tal_steal(p, b11); + p->bolt11 = tal_steal(p, b11str); payment_start(p); list_add_tail(&payments, &p->list);