mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
paycore: Prevent multiple concurrent payment groups
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`.
This commit is contained in:
parent
39248b5fa7
commit
ec9040577e
1 changed files with 12 additions and 0 deletions
|
@ -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)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue