Skip to content

fix/unified payment bolt12 duplicate fallback - #1097

Closed
Bartok9 wants to merge 2 commits into
lightningdevkit:mainfrom
Bartok9:fix/unified-payment-bolt12-duplicate-fallback
Closed

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

Conversation

@Bartok9

@Bartok9 Bartok9 commented Sep 13, 2026

Copy link
Copy Markdown
  • fix(close_channel): error when no matching channel found
    Closes close_channel returns Ok when no channel matches the user_channel_id #1084

    Previously close_channel and force_close_channel returned Ok(()) when
    no matching UserChannelId was found for the counterparty, silently
    succeeding without initiating a close. Now returns Err(ChannelClosingFailed),
    matching update_channel_config.

    AI-assisted: generated by Sera (Hermes Agent), verified manually.
    Tests compile; integration test requires bitcoind/electrs binaries
    (architecturally incompatible electrs binary in this cron environment,
    same failure affects all integration tests)

    Signed-off-by: Bartok9 259807879+Bartok9@users.noreply.github.com

  • fix: BOLT12 arm of UnifiedPayment::send returns DuplicatePayment/PersistenceFailed errors
    The BOLT12 arm of UnifiedPayment::send was using a .map_err() + if let Ok pattern
    that caused Critical errors (DuplicatePayment, PersistenceFailed) to fall through to the
    BOLT11/onchain payment methods. This could result in double-payment if:

    1. A BOLT12 payment fails with PersistenceFailed (e.g., payment store insert fails after
      ChannelManager accepted the payment)
    2. The code falls through to BOLT11 attempt
    3. BOLT11 also fails with PersistenceFailed
    4. The code falls through to on-chain broadcast
    5. User is charged twice (once via Lightning, once via on-chain)

    This fix mirrors the BOLT11 arm fix in PR Fix BOLT11 DuplicatePayment triggering on-chain fallback in unified payment #1038. Both DuplicatePayment and
    PersistenceFailed are now terminal errors that abort the unified payment entirely.

    Fixes: BOLT12 leg falls through to BOLT11/on-chain on already-initiated errors #1060

Closes lightningdevkit#1084

Previously close_channel and force_close_channel returned Ok(()) when
no matching UserChannelId was found for the counterparty, silently
succeeding without initiating a close. Now returns Err(ChannelClosingFailed),
matching update_channel_config.

AI-assisted: generated by Sera (Hermes Agent), verified manually.
Tests compile; integration test requires bitcoind/electrs binaries
(architecturally incompatible electrs binary in this cron environment,
same failure affects all integration tests)

Signed-off-by: Bartok9 <259807879+Bartok9@users.noreply.github.com>
…istenceFailed errors

The BOLT12 arm of UnifiedPayment::send was using a .map_err() + if let Ok pattern
that caused Critical errors (DuplicatePayment, PersistenceFailed) to fall through to the
BOLT11/onchain payment methods. This could result in double-payment if:

1. A BOLT12 payment fails with PersistenceFailed (e.g., payment store insert fails after
   ChannelManager accepted the payment)
2. The code falls through to BOLT11 attempt
3. BOLT11 also fails with PersistenceFailed
4. The code falls through to on-chain broadcast
5. User is charged twice (once via Lightning, once via on-chain)

This fix mirrors the BOLT11 arm fix in PR lightningdevkit#1038. Both DuplicatePayment and
PersistenceFailed are now terminal errors that abort the unified payment entirely.

Fixes: lightningdevkit#1060
@ldk-reviews-bot

ldk-reviews-bot commented Sep 13, 2026

Copy link
Copy Markdown

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.

@tnull

tnull commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

The two issues addressed are not even related. Please don't just mix arbitrary issues in one PR.

@tnull tnull closed this Sep 14, 2026
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.

close_channel returns Ok when no channel matches the user_channel_id BOLT12 leg falls through to BOLT11/on-chain on already-initiated errors

3 participants