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
@elnafateh
elnafateh requested a review from ajaysehwal August 11, 2026 20:46
Comment thread src/payment/unified.rs
log_error!(self.logger, "Failed to send BOLT11 invoice: DuplicatePayment. This is part of a unified payment. Aborting to avoid duplicate payment.");
return Err(Error::DuplicatePayment);
},
Err(e) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like this error can be just a persistence error happening in send/send_internal, with the payment being initiated. Fall back would be a duplicate payment.

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.

No, persistence failures return a separate PersistenceFailed variant, so aborting on DuplicatePayment here is safe.

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