From 917bea676484d8de8718277c3f370242b5761d53 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 5 Oct 2021 18:03:05 +0200 Subject: [PATCH] pay: Mark completed payments as such by nullifying `cmd` We want to avoid returning duplicate results when cross-completing, so mark them as completed when we return a result. --- plugins/libplugin-pay.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index ad873743e..ecbe072b3 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -1904,6 +1904,7 @@ static void payment_finished(struct payment *p) plugin_notification_end(p->plugin, n); if (command_finished(cmd, ret)) {/* Ignore result. */} + p->cmd = NULL; return; } else if (p->aborterror != NULL) { /* We set an explicit toplevel error message, @@ -1915,6 +1916,7 @@ static void payment_finished(struct payment *p) payment_notify_failure(p, p->aborterror); if (command_finished(cmd, ret)) {/* Ignore result. */} + p->cmd = NULL; return; } else if (result.failure == NULL || result.failure->failcode < NODE) { if (p->on_payment_failure != NULL) @@ -1933,6 +1935,7 @@ static void payment_finished(struct payment *p) payment_notify_failure(p, msg); if (command_finished(cmd, ret)) {/* Ignore result. */} + p->cmd = NULL; return; } else { @@ -2002,6 +2005,7 @@ static void payment_finished(struct payment *p) payment_notify_failure(p, failure->message); if (command_finished(cmd, ret)) { /* Ignore result. */} + p->cmd = NULL; return; } } else {