From d0eb3a79eb4e25d49e0f48e8ca8bdcc905a6acaa Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 3 Jul 2020 20:55:20 +0200 Subject: [PATCH] paymod: Not having a result doesn't mean we failed at getroute Specifically if we split, there is no result, but we shouldn't add a failure message. --- plugins/libplugin-pay.c | 14 ++++++++++++++ plugins/pay.c | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index a06ceb011..fff494f94 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -2098,6 +2098,8 @@ static void presplit_cb(void *d, struct payment *p) } else if (p == root && p->step == PAYMENT_STEP_INITIALIZED) { /* The presplitter only acts on the root and only in the first * step. */ + size_t count = 0; + /* We need to opt-in to the MPP sending facility no matter * what we do. That means setting all partids to a non-zero * value. */ @@ -2142,8 +2144,20 @@ static void presplit_cb(void *d, struct payment *p) * when splitting. */ c->constraints.fee_budget.millisatoshis *= multiplier; /* Raw: Multiplication */ payment_start(c); + count++; } p->step = PAYMENT_STEP_SPLIT; + p->end_time = time_now(); + p->why = tal_fmt( + p, + "Split into %zu sub-payments due to initial size (%s > " + "%dmsat)", + count, + type_to_string(tmpctx, struct amount_msat, &root->amount), + MPP_TARGET_SIZE); + plugin_log(p->plugin, LOG_INFORM, "%s", p->why); + p->result = NULL; + p->route = NULL; } payment_continue(p); } diff --git a/plugins/pay.c b/plugins/pay.c index ec1404c6b..579e82a41 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -1512,7 +1512,9 @@ static void paystatus_add_payment(struct json_stream *s, const struct payment *p /* TODO Add routehint. */ /* TODO Add route details */ - if (p->result != NULL) { + if (p->step == PAYMENT_STEP_SPLIT) { + /* Don't add anything, this is neither a success nor a failure. */ + } else if (p->result != NULL) { if (p->step == PAYMENT_STEP_SUCCESS) json_object_start(s, "success"); else