Skip to content

Add cancel_invoice to Bolt11Payment#846

Open
benthecarman wants to merge 1 commit intolightningdevkit:mainfrom
benthecarman:cancel-invoice
Open

Add cancel_invoice to Bolt11Payment#846
benthecarman wants to merge 1 commit intolightningdevkit:mainfrom
benthecarman:cancel-invoice

Conversation

@benthecarman
Copy link
Contributor

@benthecarman benthecarman commented Mar 25, 2026

Allow cancelling a previously created BOLT11 invoice by payment hash. Enterprise integrators need this when they short-circuit an invoice with an internal database transfer or when an alternative payment method is used (e.g., on-chain payment via unified URI).

The PaymentClaimable event handler rejects HTLCs for cancelled invoices only when the preimage is known (auto-claim payments), preserving retry behavior for manual-claim (_for_hash) payments.

fail_for_hash already did the logic we needed so cancel_invoice just does a little bit extra pre-validation and then calls it. Could make the argument to just use fail_for_hash, update its docs, and the if statement to reject payments mark as failed in the PaymentClaimable. The only functionality change would be that if someone retries to do a payment after a fail_for_hash, we don't let the user evaluate again.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Mar 25, 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.

Allow canceling a previously created BOLT11 invoice by payment
hash. Enterprise integrators need this when they short-circuit an
invoice with an internal database transfer or when an alternative
payment method is used (e.g., on-chain payment via unified URI).

cancel_invoice validates the payment is inbound and unclaimed,
then delegates to fail_for_hash for the shared logic of marking
the payment as failed and failing back any pending HTLCs.

The PaymentClaimable event handler rejects HTLCs for cancelled
invoices only when the preimage is known (auto-claim payments),
preserving retry behavior for manual-claim (_for_hash) payments.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants