Repository navigation
xpay: don't increase the payment counter for check - #9704
Open
coolstack-coder wants to merge 2 commits into
Open
coolstack-coder wants to merge 2 commits into
coolstack-coder wants to merge 2 commits into
Conversation
Andezion
approved these changes
Nov 11, 2026
| l1.rpc.xpay(inv) | ||
|
|
||
| # The first real payment is still payment 0, not payment 2. | ||
| l1.daemon.wait_for_log(r'plugin-cln-xpay: 0: ') |
Collaborator
There was a problem hiding this comment.
maybe match a line that only a real payment writes, for example:
l1.daemon.wait_for_log(r'plugin-cln-xpay: 0: .*Success: preimage=')
(look at attempt_info(. . . "Success: preimage=%s"), at xpay.c at line 1417)
| l1.rpc.xpay(inv) | ||
|
|
||
|
|
||
| def test_xpay_check_keeps_counter(node_factory): |
Collaborator
There was a problem hiding this comment.
maybe also lets cover check xkeysend?
| payment->unique_id = xpay->counter++; | ||
| /* `check` never pays, so don't use up an id for it: the next real | ||
| * payment can have this one. */ | ||
| if (command_check_only(cmd)) |
Collaborator
There was a problem hiding this comment.
so a check payment and a real payment can now have the same id in the logs
daywalker90
force-pushed
the
xpay-check-counter
branch
from
November 11, 2026 14:31
398b698 to
ba073f1
Compare
xpay gives every payment a unique id taken from a plugin-wide counter.
The id names the payment's private askrene layer ("xpay-N") and
prefixes every log line for that payment. `check xpay` builds a payment
too, so each check moves the counter on even though nothing is paid.
Add a test that runs `check xpay` twice and then pays: the payment
should still be payment 0, but today it is payment 2.
Reported-by: Lagrang3 in ElementsProject#9281
new_payment() always took the next id with `xpay->counter++`, and all three xpay entry points (bolt11, bolt12 and keysend) build the payment before they look at command_check_only(). So `check xpay` used up an id each time, and the next real payment's layer and log prefix skipped numbers. A check-only payment returns from preapprove_succeed() before age_layer(), so it never creates its "xpay-N" layer and nothing else holds on to the id. Give it the current counter value without bumping it, so the next real payment gets that id. Fixes: ElementsProject#9281 Changelog-Fixed: xpay: `check xpay` no longer increases the payment counter.
sangbida
force-pushed
the
xpay-check-counter
branch
from
November 23, 2026 06:51
ba073f1 to
ef409cd
Compare
sangbida
enabled auto-merge (rebase)
November 23, 2026 06:51
Collaborator
|
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9281.
check xpaybuilds a payment just like a realxpaycall does, andnew_payment()always took the next id withxpay->counter++. So everycheckused up a payment id. The ids name each payment's private askrene layer (xpay-N) and prefix its log lines, so the next real payment's numbering skipped ahead.A check-only payment returns from
preapprove_succeed()beforeage_layer(), so it never creates a layer and nothing keeps its id. This PR gives it the current counter value without incrementing, so the next real payment gets that id.Commits:
tests:addstest_xpay_check_keeps_counterasxfail(strict=True): twocheck xpaycalls then a realxpay, expecting the payment to log as0:and not2:.plugin-xpay:the fix, which also removes the xfail marker.