mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 08:34:20 +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:
committed by
Rusty Russell
parent
39248b5fa7
commit
ec9040577e
@@ -910,12 +910,24 @@ send_payment_core(struct lightningd *ld,
|
|||||||
return sendpay_success(cmd, payments[i]);
|
return sendpay_success(cmd, payments[i]);
|
||||||
|
|
||||||
case PAYMENT_PENDING:
|
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! */
|
/* Can't mix non-parallel and parallel payments! */
|
||||||
if (!payments[i]->partid != !partid) {
|
if (!payments[i]->partid != !partid) {
|
||||||
return command_fail(cmd, PAY_IN_PROGRESS,
|
return command_fail(cmd, PAY_IN_PROGRESS,
|
||||||
"Already have %s payment in progress",
|
"Already have %s payment in progress",
|
||||||
payments[i]->partid ? "parallel" : "non-parallel");
|
payments[i]->partid ? "parallel" : "non-parallel");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payments[i]->partid == partid) {
|
if (payments[i]->partid == partid) {
|
||||||
/* You can't change details while it's pending */
|
/* You can't change details while it's pending */
|
||||||
if (!amount_msat_eq(payments[i]->msatoshi, msat)) {
|
if (!amount_msat_eq(payments[i]->msatoshi, msat)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user