Skip to content

Commit

Permalink
pay: Check for self-payments before attempting to pay
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cdecker committed Feb 7, 2021
1 parent b52a269 commit 02fa002
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plugins/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 02fa002

Please sign in to comment.