From b606f46cfbb5321cef4c3ad2e214dfa104980cf6 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Thu, 2 Jul 2020 14:39:28 +0200 Subject: [PATCH] paymod: Fix waitsendpay error parsing for unknown failure codes It turns out that the `failcodename` doesn't get populated if the `failcode` isn't a known error from the enum (duh...) so don't fail parsing if it's missing. --- plugins/libplugin-pay.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index 493abb598..a06ebc81e 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -531,7 +531,7 @@ static struct payment_result *tal_sendpay_result_from_json(const tal_t *ctx, msgtok = json_get_member(buffer, toks, "message"); rawmsgtok = json_get_member(buffer, datatok, "raw_message"); if (failcodetok == NULL || failcodetok->type != JSMN_PRIMITIVE || - failcodenametok == NULL || failcodenametok->type != JSMN_STRING || + (failcodenametok != NULL && failcodenametok->type != JSMN_STRING) || (erridxtok != NULL && erridxtok->type != JSMN_PRIMITIVE) || (errnodetok != NULL && errnodetok->type != JSMN_STRING) || (errchantok != NULL && errchantok->type != JSMN_STRING) || @@ -545,7 +545,11 @@ static struct payment_result *tal_sendpay_result_from_json(const tal_t *ctx, else result->raw_message = NULL; - result->failcodename = json_strdup(result, buffer, failcodenametok); + if (failcodenametok != NULL) + result->failcodename = json_strdup(result, buffer, failcodenametok); + else + result->failcodename = NULL; + json_to_u32(buffer, failcodetok, &result->failcode); result->message = json_strdup(result, buffer, msgtok);