From 2649de54f20c122d6c3461ee4fbe95bf35871a26 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 17 Jun 2020 13:51:00 +0200 Subject: [PATCH] paymod: Do not wait for a blockheight if we're already there We want to differentiate a wrong block-height from other failure reasons, such as an unknown `payment_hash`, so we skip the `waitblockheight` if we're already at the correct height. --- plugins/libplugin-pay.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index b554bec22..8f13316a5 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -1990,6 +1990,13 @@ static void waitblockheight_cb(void *d, struct payment *p) return payment_continue(p); } + /* If we are already at the desired blockheight there is no point in + * waiting, and it is likely just some other error. Notice that + * start_block gets set by the initial getinfo call for each + * attempt.*/ + if (blockheight < p->start_block) + return payment_continue(p); + plugin_log(p->plugin, LOG_INFORM, "Remote node appears to be on a longer chain, which causes " "CLTV timeouts to be incorrect. Waiting up to %" PRIu64