Skip to content

FIXES TODO in callbacks: implement strict validation for all payment callbacks#426

Merged
cameri merged 3 commits intocameri:mainfrom
Mohit-Davar:feat/callback-validation
Apr 18, 2026
Merged

FIXES TODO in callbacks: implement strict validation for all payment callbacks#426
cameri merged 3 commits intocameri:mainfrom
Mohit-Davar:feat/callback-validation

Conversation

@Mohit-Davar
Copy link
Copy Markdown
Contributor

Description

This pull request implements strict request validation for all supported payment processor callbacks (LNbits, Nodeless, OpenNode, and Zebedee).

Changes include:

  • Centralised Schema Layer: Created callback-request-schemas.ts to isolate and manage third-party webhook structures.
  • Joi based verification: Instead of relying on manual verification for every callback (like manually checking hex patterns or string lengths), I've moved everything to use Joi schemas and bringing the callback logic in line with how the rest of the project handles validation.

Related Issue

Resolves internal TODO: Validate markers in src/controllers/callbacks/.

Motivation and Context

The payment callback endpoints were previously processing external data without strict validation. This change ensures that all incoming webhooks from external processors are verified for correct structure and data types before any business logic is executed.

How Has This Been Tested?

I have implemented a unit test suite in callback-request-schemas.spec.ts

Screenshots (if appropriate):

Implemented these TODOs:

image

Test Cases:

image

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • All new and existing tests passed.

@Mohit-Davar Mohit-Davar changed the title FIXES TODO in implement strict validation for all payment callbacks FIXES TODO in callbacks: implement strict validation for all payment callbacks Apr 9, 2026
@cameri
Copy link
Copy Markdown
Owner

cameri commented Apr 10, 2026

@Mohit-Davar Appreciate your work here. Could you please create the issue for this PR?

Comment thread src/schemas/callback-request-schemas.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Joi-based request validation for incoming payment processor webhook callbacks (LNbits, Nodeless, OpenNode, Zebedee) by introducing centralized callback schemas and enforcing schema validation at the start of each callback controller.

Changes:

  • Added src/schemas/callback-request-schemas.ts to define Joi schemas for supported callback payloads/query params.
  • Updated each callback controller to validate incoming request bodies (and LNbits query) before running business logic.
  • Added a unit test suite covering the new callback schemas.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
test/unit/schemas/callback-request-schemas.spec.ts Adds unit tests for the new callback request schemas.
src/schemas/callback-request-schemas.ts Introduces Joi schemas for LNbits, Nodeless, OpenNode, and Zebedee callback payloads.
src/controllers/callbacks/zebedee-callback-controller.ts Rejects requests with invalid Zebedee callback bodies (400) before processing.
src/controllers/callbacks/opennode-callback-controller.ts Rejects requests with invalid OpenNode callback bodies (400) before processing.
src/controllers/callbacks/nodeless-callback-controller.ts Rejects requests with invalid Nodeless callback bodies (400) before signature/processing.
src/controllers/callbacks/lnbits-callback-controller.ts Validates LNbits callback query/body and replaces manual query/body checks with schema validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/schemas/callback-request-schemas.ts Outdated
Comment thread src/schemas/callback-request-schemas.ts Outdated
Comment thread src/schemas/callback-request-schemas.ts Outdated
Comment thread src/schemas/callback-request-schemas.ts Outdated
Comment thread src/controllers/callbacks/lnbits-callback-controller.ts Outdated
Comment thread test/unit/schemas/callback-request-schemas.spec.ts Outdated
Comment thread test/unit/schemas/callback-request-schemas.spec.ts Outdated
Comment thread test/unit/schemas/callback-request-schemas.spec.ts Outdated
@Mohit-Davar Mohit-Davar force-pushed the feat/callback-validation branch 2 times, most recently from 3acb533 to 50c02ce Compare April 11, 2026 07:30
@Mohit-Davar Mohit-Davar force-pushed the feat/callback-validation branch from 50c02ce to 2bd7e76 Compare April 11, 2026 07:31
@cameri
Copy link
Copy Markdown
Owner

cameri commented Apr 11, 2026

@Mohit-Davar kindly create the associated issue for this PR 🙏

@cameri cameri linked an issue Apr 11, 2026 that may be closed by this pull request
@Mohit-Davar
Copy link
Copy Markdown
Contributor Author

@cameri Thank you for reviewing my PRs earlier and for the detailed feedback. I’ve addressed all the requested changes and updated the PRs accordingly.
Could you please let me know if anything else is required from my side, or if there are any additional improvements I should make before they can be merged?
I really appreciate your time and guidance. Looking forward to your feedback. 🙂

@cameri cameri self-assigned this Apr 18, 2026
@cameri cameri merged commit c1df122 into cameri:main Apr 18, 2026
9 checks passed
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.

Implement strict validation for payment callback webhooks

3 participants