Skip to content

Commit

Permalink
paymod: Fix waitsendpay error parsing for unknown failure codes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cdecker committed Jul 6, 2020
1 parent 4a9b4bd commit de74b45
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugins/libplugin-pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,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) ||
Expand All @@ -547,7 +547,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);

Expand Down

0 comments on commit de74b45

Please sign in to comment.