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.
This commit is contained in:
Christian Decker 2021-02-07 21:00:02 +01:00
parent 9869083a79
commit e677486fcc

View File

@ -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;