Skip to content

Expose payment failure reason on PaymentFailed event - #263

Open
elnafateh wants to merge 3 commits into
lightningdevkit:mainfrom
elnafateh:expose-payment-failure-reason
Open

Expose payment failure reason on PaymentFailed event#263
elnafateh wants to merge 3 commits into
lightningdevkit:mainfrom
elnafateh:expose-payment-failure-reason

Conversation

@elnafateh

Copy link
Copy Markdown

Closes part of #251.

PaymentFailed currently drops the reason field that LDK Node already provides. This adds it as an optional PaymentFailureReason enum on the proto event, mapped 1:1 from lightning::events::PaymentFailureReason.

  • New PaymentFailureReason enum in events.proto, mirrors LDK's variants
  • payment_failure_reason_to_proto() mapping function, wired into the event handler
  • Unit test covering all 10 variants
  • E2e test updated to assert reason is populated

The other items in #251 (splice events, channel snapshot fields, on-chain tx classification, misc fields) are left for follow-up PRs.

Adds PaymentFailureReason to the PaymentFailed proto event, mapped
from ldk-node's lightning::events::PaymentFailureReason. Covers one
item from lightningdevkit#251.
@ldk-reviews-bot

ldk-reviews-bot commented Aug 28, 2026

Copy link
Copy Markdown

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

Comment thread ldk-server/src/main.rs Outdated
}

#[test]
fn test_payment_failure_reason_mapping() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This test doesn't really do anything, can we delete

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes

Comment thread e2e-tests/tests/e2e.rs Outdated
Some(Event::PaymentFailed(payment_failed)) => {
// NOTE: exact variant depends on how a receiver-side manual fail propagates;
// asserting `Some` here, tighten to the specific reason once confirmed locally.
assert!(payment_failed.reason.is_some());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This test should always produce the same error and we can just assert that error

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

ok

Comment thread e2e-tests/tests/e2e.rs Outdated
elnafateh and others added 2 commits August 28, 2026 11:04
Co-authored-by: benthecarman <15256660+benthecarman@users.noreply.github.com>
@elnafateh
elnafateh requested a review from benthecarman August 28, 2026 10:59
@benthecarman

Copy link
Copy Markdown
Collaborator

Please squash your commits

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