From 581c1597f09d752475ee386d6897d38e2e33ed2f Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 3 Jul 2020 17:22:58 +0200 Subject: [PATCH] paymod: Don't assume that the first payment was executed at all With the `presplit`-modifier we actually skip execution of the root altogether which results in the root not having a result at all. Instead we should use the result returned by `payment_collect_result`. --- plugins/libplugin-pay.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index acaa02f2c..f2a9e7b21 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -1105,22 +1105,22 @@ static void payment_finished(struct payment *p) } else { struct payment_result *failure = result.failure; assert(failure!= NULL); - ret = jsonrpc_stream_fail(cmd, p->result->code, + ret = jsonrpc_stream_fail(cmd, failure->code, failure->message); - json_add_u64(ret, "id", p->result->id); + json_add_u64(ret, "id", failure->id); - json_add_u32(ret, "failcode", result.failure->failcode); + json_add_u32(ret, "failcode", failure->failcode); json_add_string(ret, "failcodename", - result.failure->failcodename); + failure->failcodename); if (p->bolt11) json_add_string(ret, "bolt11", p->bolt11); json_add_hex_talarr(ret, "raw_message", - p->result->raw_message); + result.failure->raw_message); json_add_num(ret, "created_at", p->start_time.ts.tv_sec); - json_add_string(ret, "message", p->result->message); + json_add_string(ret, "message", result.failure->message); json_add_node_id(ret, "destination", p->destination); json_add_sha256(ret, "payment_hash", p->payment_hash);