From b88a55b2a410c5c4ec23d8e18f699dcbb8df17eb Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 10 Jul 2020 13:31:16 +0200 Subject: [PATCH] paymod: Only wait on blockheight if we need to We were wrongfully identifying all payment failures as blockheight mismatches. --- plugins/libplugin-pay.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index cfa24bdbe..029838ba6 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -1973,7 +1973,7 @@ static void waitblockheight_cb(void *d, struct payment *p) struct out_req *req; struct timeabs now = time_now(); struct timerel remaining; - u32 blockheight; + u32 blockheight = p->start_block; int failcode; const u8 *raw_message; if (p->step != PAYMENT_STEP_FAILED) @@ -1990,7 +1990,7 @@ static void waitblockheight_cb(void *d, struct payment *p) raw_message = p->result->raw_message; remaining = time_between(p->deadline, now); - if (failcode != 17 /* Former final_expiry_too_soon */) { + if (failcode == 17 /* Former final_expiry_too_soon */) { blockheight = p->start_block + 1; } else { /* If it's incorrect_or_unknown_payment_details, that tells us @@ -2006,7 +2006,7 @@ static void waitblockheight_cb(void *d, struct payment *p) * 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) + if (blockheight <= p->start_block) return payment_continue(p); plugin_log(p->plugin, LOG_INFORM,