Browse Source

paymod: Do not assume that parsing the waitsendpay result succeeds

Suggested-by: ZmnSCPxj
Signed-off-by: Christian Decker
Reference: #3846
fixup-0.9.0
Christian Decker 4 years ago
parent
commit
3b54847ae4
  1. 8
      plugins/libplugin-pay.c

8
plugins/libplugin-pay.c

@ -627,10 +627,13 @@ static void channel_hints_update(struct payment *root,
static void payment_result_infer(struct route_hop *route,
struct payment_result *r)
{
int i, len = tal_count(route);
int i, len;
assert(r != NULL);
if (r->code == 0 || r->erring_index == NULL || route == NULL)
return;
len = tal_count(route);
i = *r->erring_index;
assert(i <= len);
@ -659,13 +662,14 @@ payment_waitsendpay_finished(struct command *cmd, const char *buffer,
assert(p->route != NULL);
p->result = tal_sendpay_result_from_json(p, buffer, toks);
payment_result_infer(p->route, p->result);
if (p->result == NULL)
plugin_err(
p->plugin, "Unable to parse `waitsendpay` result: %.*s",
json_tok_full_len(toks), json_tok_full(buffer, toks));
payment_result_infer(p->route, p->result);
if (p->result->state == PAYMENT_COMPLETE) {
payment_set_step(p, PAYMENT_STEP_SUCCESS);
p->end_time = time_now();

Loading…
Cancel
Save