Skip to content

Fix BOLT11 DuplicatePayment triggering on-chain fallback in unified payment - #1038

Open
elnafateh wants to merge 2 commits into
lightningdevkit:mainfrom
elnafateh:fix/unified-payment-duplicate-fallback
Open

Fix BOLT11 DuplicatePayment triggering on-chain fallback in unified payment#1038
elnafateh wants to merge 2 commits into
lightningdevkit:mainfrom
elnafateh:fix/unified-payment-duplicate-fallback

Conversation

@elnafateh

Copy link
Copy Markdown
Contributor

UnifiedPayment::send previously fell back to the on-chain method after any
BOLT11 error, including Error::DuplicatePayment. Retrying a unified BIP21
payment could pay the recipient twice — once over Lightning, once on-chain.

Error::DuplicatePayment is now treated as terminal and returned to the
caller immediately, preventing the unsafe fallback.

Adds an integration test covering the retry scenario.
#1033

@ldk-reviews-bot

ldk-reviews-bot commented Aug 10, 2026

Copy link
Copy Markdown

👋 Thanks for assigning @ajaysehwal 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.

@ldk-reviews-bot
ldk-reviews-bot requested a review from tnull August 10, 2026 15:10
…ayments

Error::DuplicatePayment is now terminal in UnifiedPayment::send, preventing
a duplicate Lightning payment from falling back to an on-chain payment.
@elnafateh
elnafateh force-pushed the fix/unified-payment-duplicate-fallback branch from d2e30c9 to 981bc8a Compare August 10, 2026 21:30
Comment thread src/payment/unified.rs

@ajaysehwal ajaysehwal Aug 11, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@elnafateh, the BOLT11 fix looks good. DuplicatePayment is now treated as terminal, while other BOLT11 failures still fall back to on-chain as intended.
One adjacent issue is still present in the BOLT12 path: all errors, including DuplicatePayment, still fall through to BOLT11. That said, BOLT12 has a slightly different retry risk because it generates a fresh random PaymentId for each payment. So a retry is unlikely to hit DuplicatePayment; instead, it could successfully start another BOLT12 payment or fall through to BOLT11/on-chain and potentially double-pay.
I don't think this is introduced by this PR, but it may be worth tracking separately.

@elnafateh elnafateh Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @ajaysehwal, glad the BOLT11 fix looks good. Agreed on BOLT12 — I'm tracking it as a separate follow up issue/PR and leaving this one scoped to #1033

@elnafateh
elnafateh requested a review from ajaysehwal August 11, 2026 20:46
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.

3 participants