Skip to content

Commit

Permalink
paycore: Prevent multiple concurrent payment groups
Browse files Browse the repository at this point in the history
One of the fundamental constraints of the payment groups idea is that
there may only ever be one group in flight at any point in time, so if
we find a group that is in flight, any new `sendpay` or `sendonion`
must match its `groupid`.
  • Loading branch information
cdecker authored and rustyrussell committed Oct 13, 2021
1 parent 39248b5 commit ec90405
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lightningd/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,12 +910,24 @@ send_payment_core(struct lightningd *ld,
return sendpay_success(cmd, payments[i]);

case PAYMENT_PENDING:
/* At most one payment group can be in-flight at any
* time. */
if (payments[i]->groupid != group) {
return command_fail(
cmd, PAY_IN_PROGRESS,
"Payment with groupid=%" PRIu64
" still in progress, cannot retry before "
"that completes.",
payments[i]->groupid);
}

/* Can't mix non-parallel and parallel payments! */
if (!payments[i]->partid != !partid) {
return command_fail(cmd, PAY_IN_PROGRESS,
"Already have %s payment in progress",
payments[i]->partid ? "parallel" : "non-parallel");
}

if (payments[i]->partid == partid) {
/* You can't change details while it's pending */
if (!amount_msat_eq(payments[i]->msatoshi, msat)) {
Expand Down

0 comments on commit ec90405

Please sign in to comment.