From 2acb86bfe3885e661fff25aa5702413ab7c6d0a2 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 27 May 2020 14:49:40 +0200 Subject: [PATCH] paymod: Consider new payments when checking if an attempt is ongoing Without this the flapping behavior tested in `test_pay_retry` would reappear. --- plugins/pay.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/pay.c b/plugins/pay.c index 71df28dca..6b894eb00 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -1507,7 +1507,11 @@ static struct command_result *json_paystatus(struct command *cmd, static bool attempt_ongoing(const char *b11) { struct pay_status *ps; + struct payment *root; struct pay_attempt *attempt; + struct payment_tree_result res; + enum payment_step diff, + final_states = PAYMENT_STEP_FAILED | PAYMENT_STEP_SUCCESS; list_for_each(&pay_status, ps, list) { if (!streq(b11, ps->bolt11)) @@ -1515,6 +1519,14 @@ static bool attempt_ongoing(const char *b11) attempt = &ps->attempts[tal_count(ps->attempts)-1]; return attempt->result == NULL && attempt->failure == NULL; } + + list_for_each(&payments, root, list) { + if (root->bolt11 == NULL || !streq(b11, root->bolt11)) + continue; + res = payment_collect_result(root); + diff = res.leafstates & ~final_states; + return diff != 0; + } return false; }