From a43d0301376427aa447b4b62930ca2d60e5f9bec Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 8 Jul 2020 21:10:45 +0200 Subject: [PATCH] paymod: Reset the step if we're waiting for a block This was causing the state flapping test to fail, since we were yielding control of the io_loop, waiting for the blockheight to be reached, and not setting the status beforehand. An interim `paystatus` call would then find a failed leaf and deduce the entire payment failed. Setting it back to the previous state keeps the overall payment pending while we wait. --- plugins/libplugin-pay.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index bb0a753ad..79b6ad5f7 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -2016,6 +2016,12 @@ static void waitblockheight_cb(void *d, struct payment *p) " seconds to catch up to block %d before retrying.", time_to_sec(remaining), blockheight); + /* Set temporarily set the state of the payment to not failed, so + * interim status queries don't show this as terminally failed. We're + * in control for this payment so nobody else could be fooled by + * this. The callback will set it to retry anyway. */ + payment_set_step(p, PAYMENT_STEP_RETRY); + req = jsonrpc_request_start(p->plugin, NULL, "waitblockheight", waitblockheight_rpc_cb, waitblockheight_rpc_cb, p);