Skip to content

Fix inbound on-chain payment txid not updating after RBF replacement#826

Closed
febyeji wants to merge 2 commits intolightningdevkit:mainfrom
febyeji:fix-rbf-inbound-txid-tracking
Closed

Fix inbound on-chain payment txid not updating after RBF replacement#826
febyeji wants to merge 2 commits intolightningdevkit:mainfrom
febyeji:fix-rbf-inbound-txid-tracking

Conversation

@febyeji
Copy link

@febyeji febyeji commented Mar 14, 2026

Found via CI failure in the onchain_fee_bump_rbf test:

  • When a sender performs multiple RBF fee bumps, the receiver may not update its inbound payment record to reflect the final confirmed replacement transaction. This causes onchain_fee_bump_rbf to fail intermittently:
assertion `left == right` failed: node_a inbound payment txid should be updated to the second replacement txid

Fix

  • find_payment_by_txid now also checks the payment_store (not just pending_payment_store) for onchain payments matching the target txid.
  • New find_payment_by_conflicting_tx method: if a transaction shares inputs with an existing payment's transaction, it must be an RBF replacement. This works regardless of whether intermediate replacements were observed.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Mar 14, 2026

I've assigned @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@febyeji febyeji closed this Mar 14, 2026
@febyeji febyeji reopened this Mar 14, 2026
@febyeji febyeji marked this pull request as ready for review March 14, 2026 15:00
@ldk-reviews-bot ldk-reviews-bot requested a review from tnull March 14, 2026 15:01
@tnull
Copy link
Collaborator

tnull commented Mar 14, 2026

cc @Camillarhi

Copy link
Contributor

@Camillarhi Camillarhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. The fix looks good for the missed-intermediate-bump case, but I think both find_payment_by_txid and find_payment_by_conflicting_tx are reaching into payment_store when pending_payment_store should be enough. Anything still replaceable via RBF hasn't hit ANTI_REORG_DELAY yet, so it's still in pending_payment_store. Payments that have left it are already confirmed and can't be replaced anyway.

@febyeji
Copy link
Author

febyeji commented Mar 15, 2026

Thanks for the review! I've addressed all three points in dbef121.

@Camillarhi
Copy link
Contributor

Before we proceed, could you point us to the specific CI run where the onchain_fee_bump_rbf failure occurred? I reviewed the recent open PRs and couldn't find a failure matching the assertion you described. A link to the failed run would help us confirm the reproduction and validate the fix.

@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@febyeji
Copy link
Author

febyeji commented Mar 16, 2026

@Camillarhi The onchain_fee_bump_rbf failure was occurring on the CBF branch CI: https://github.com/lightningdevkit/ldk-node/actions/runs/23131104958/job/67184465048. After investigation, the root cause turned out to be in the CBF branch's ChainTipChanged handler, not in the RBF tracking logic itself. The fix has been applied directly in the CBF branch.

I think this PR can be closed. Thank you very much for the review feedback.

@febyeji febyeji closed this Mar 16, 2026
@febyeji febyeji deleted the fix-rbf-inbound-txid-tracking branch March 18, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants