Skip to content

refactor: use exact pubkey matching for whitelist/blacklist#524

Merged
cameri merged 6 commits intocameri:mainfrom
vikashsiwach:feat/fix-whitelist-matching
Apr 19, 2026
Merged

refactor: use exact pubkey matching for whitelist/blacklist#524
cameri merged 6 commits intocameri:mainfrom
vikashsiwach:feat/fix-whitelist-matching

Conversation

@vikashsiwach
Copy link
Copy Markdown
Collaborator

@vikashsiwach vikashsiwach commented Apr 19, 2026

Description

This PR updates pubkey matching in whitelist and blacklist to use exact match instead of prefix-based matching.

Related Issue

Fixes issue #512

Motivation and Context

Some parts of codebase used startsWith which incorrectly match unrelated pubkeys sharing the same prefix. Based on discussion, the exact matching is more efficient method.

How Has This Been Tested?

-Ran full unit test suite:
npm run test:unit

  • Updated existing tests to show exact matching behvior

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.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Apr 19, 2026

Coverage Status

coverage: 71.16% (+0.007%) from 71.153% — vikashsiwach:feat/fix-whitelist-matching into cameri:main

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

Refactors pubkey matching for fee-schedule whitelists and event pubkey whitelist/blacklist enforcement to use exact pubkey matches (instead of prefix-based matching), addressing issue #512.

Changes:

  • Replace startsWith-based whitelist/blacklist checks with includes (exact match) in admission-fee and event-acceptance logic.
  • Update/add unit tests to assert exact-match behavior (prefix-only entries no longer match).
  • Add a changeset documenting the behavior change.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/services/payments-service.ts Switch fee whitelist matching to exact pubkey equality during admission-fee computation.
src/handlers/event-message-handler.ts Enforce exact pubkey matching for event whitelist/blacklist checks and admission-fee applicability.
src/controllers/invoices/post-invoice-controller.ts Apply exact pubkey matching for admission-fee whitelist checks and simplify fee summation.
src/app/static-mirroring-worker.ts Enforce exact pubkey matching for static mirroring pubkey whitelist/blacklist + admission-fee applicability.
test/unit/services/payments-service.spec.ts Update whitelist test data and add a regression test ensuring prefix-only whitelist entries do not match.
test/unit/handlers/event-message-handler.spec.ts Update blacklist/whitelist tests to reflect exact-match behavior.
.changeset/release-whitelist-exact-match.md Declare the release note for exact-match behavior change.

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

Comment thread test/unit/services/payments-service.spec.ts Outdated
Comment thread test/unit/services/payments-service.spec.ts Outdated
Comment thread test/unit/handlers/event-message-handler.spec.ts Outdated
Comment thread src/controllers/invoices/post-invoice-controller.ts Outdated
Comment thread .changeset/release-whitelist-exact-match.md Outdated
Copy link
Copy Markdown
Owner

@cameri cameri left a comment

Choose a reason for hiding this comment

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

Please address copilot comments.

@vikashsiwach vikashsiwach force-pushed the feat/fix-whitelist-matching branch from dcc83e9 to 70e37b8 Compare April 19, 2026 15:52
@vikashsiwach
Copy link
Copy Markdown
Collaborator Author

Please address copilot comments.

Addressed all the comments and updated the changeset to major

@cameri cameri merged commit b3effd1 into cameri:main Apr 19, 2026
13 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.

4 participants