From 627e44502f37b49b93ac54856b6c64b3a3983859 Mon Sep 17 00:00:00 2001 From: Lagrang3 Date: Mon, 22 Jun 2026 08:27:28 +0100 Subject: [PATCH 1/2] pytest: listpays: test grouping by calling xpay Changelog-None Signed-off-by: Lagrang3 --- tests/test_pay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pay.py b/tests/test_pay.py index e0b68f097429..0f357547ae76 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -5307,7 +5307,7 @@ def test_sendpay_grouping(node_factory, bitcoind): wait_for(lambda: only_one(l3.rpc.listpeers()['peers'])['connected'] is True) scid = l3.rpc.listpeerchannels()['channels'][0]['short_channel_id'] wait_for(lambda: [c['active'] for c in l1.rpc.listchannels(scid)['channels']] == [True, True]) - l1.rpc.pay(inv, amount_msat='10000msat') + l1.rpc.xpay(inv, amount_msat='10000msat') # And finally we should have all 3 attempts to pay the invoice pays = l1.rpc.listpays()['pays'] From 232250bbf9597f4ee5cf478cdf261e4ec092b8e3 Mon Sep 17 00:00:00 2001 From: Lagrang3 Date: Mon, 22 Jun 2026 08:29:28 +0100 Subject: [PATCH 2/2] listsendpays: discriminate ongoing payment by groupid A payment attempt in listpays is defined as pair (payment hash, group id). If we query xpay for ongoing payments we must discriminate using both values. Fixes flaky test tests/test_pay.py:test_sendpay_grouping ``` FAILED tests/test_pay.py::test_sendpay_grouping - AssertionError: assert ['pending', 'pending', 'complete'] == ['failed', 'failed', 'complete'] ``` Changelog-None Signed-off-by: Lagrang3 --- plugins/xpay/listpays.c | 3 ++- plugins/xpay/xpay.c | 6 ++++-- plugins/xpay/xpay.h | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/xpay/listpays.c b/plugins/xpay/listpays.c index e1c9de5a8a11..020fb2968a6c 100644 --- a/plugins/xpay/listpays.c +++ b/plugins/xpay/listpays.c @@ -159,7 +159,8 @@ static void add_new_entry(struct plugin *plugin, if (pm->state & PAYMENT_COMPLETE) json_add_string(ret, "status", "complete"); - else if (pm->state & PAYMENT_PENDING || attempt_ongoing(plugin, pm->payment_hash)) + else if (pm->state & PAYMENT_PENDING || + attempt_ongoing(plugin, pm->payment_hash, pm->sortkey.groupid)) json_add_string(ret, "status", "pending"); else json_add_string(ret, "status", "failed"); diff --git a/plugins/xpay/xpay.c b/plugins/xpay/xpay.c index 7cf2c2061ccc..d9a3c297ff8b 100644 --- a/plugins/xpay/xpay.c +++ b/plugins/xpay/xpay.c @@ -2510,13 +2510,15 @@ static struct payment *new_payment(const tal_t *ctx, return payment; } -bool attempt_ongoing(struct plugin *plugin, const struct sha256 *payment_hash) +bool attempt_ongoing(struct plugin *plugin, const struct sha256 *payment_hash, + u64 groupid) { struct xpay *xpay = xpay_of(plugin); const struct payment *payment; list_for_each(&xpay->payments, payment, list) { - if (sha256_eq(&payment->payment_hash, payment_hash)) + if (sha256_eq(&payment->payment_hash, payment_hash) && + payment->group_id == groupid) return true; } return false; diff --git a/plugins/xpay/xpay.h b/plugins/xpay/xpay.h index 886380d5c49f..44d4305aef3d 100644 --- a/plugins/xpay/xpay.h +++ b/plugins/xpay/xpay.h @@ -7,6 +7,7 @@ struct plugin; struct sha256; /* Are we still attempting this payment? If so, we won't list is as failed. */ -bool attempt_ongoing(struct plugin *plugin, const struct sha256 *payment_hash); +bool attempt_ongoing(struct plugin *plugin, const struct sha256 *payment_hash, + u64 groupid); #endif /* LIGHTNING_PLUGINS_XPAY_XPAY_H */