From e677486fcc3486fb8add6cdd7f380a9063b4bf84 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sun, 7 Feb 2021 21:00:02 +0100 Subject: [PATCH] pay: Check for self-payments before attempting to pay This duplicates the check in libplugin-pay.c, with a more concise error message. Both are needed since pay may not be the only entrypoint. --- plugins/pay.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/pay.c b/plugins/pay.c index c32d332e3..69517a666 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -2105,6 +2105,11 @@ static struct command_result *json_paymod(struct command *cmd, p->amount = *msat; } + if (node_id_eq(&my_id, p->destination)) + return command_fail(cmd, JSONRPC2_INVALID_PARAMS, + "This payment is destined for ourselves. " + "Self-payments are not supported"); + p->local_id = &my_id; p->json_buffer = tal_steal(p, buf); p->json_toks = params;