Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issues with invoices #271

Merged
merged 13 commits into from
Apr 7, 2023
Merged

fix: issues with invoices #271

merged 13 commits into from
Apr 7, 2023

Conversation

cameri
Copy link
Owner

@cameri cameri commented Mar 28, 2023

Description

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

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.

@coveralls
Copy link
Collaborator

coveralls commented Mar 28, 2023

Pull Request Test Coverage Report for Build 4638676897

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 27 of 50 (54.0%) changed or added relevant lines in 9 files are covered.
  • 98 unchanged lines in 15 files lost coverage.
  • Overall coverage decreased (-4.2%) to 50.678%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/handlers/request-handlers/root-request-handler.ts 0 1 0.0%
src/handlers/subscribe-message-handler.ts 4 5 80.0%
src/utils/secret.ts 3 4 75.0%
src/controllers/invoices/post-invoice-controller.ts 0 2 0.0%
src/utils/event.ts 11 13 84.62%
src/app/maintenance-worker.ts 0 4 0.0%
src/handlers/event-message-handler.ts 5 9 55.56%
src/services/payments-service.ts 3 11 27.27%
Files with Coverage Reduction New Missed Lines %
src/handlers/request-handlers/root-request-handler.ts 1 12.5%
src/repositories/event-repository.ts 1 97.44%
src/services/payments-service.ts 1 6.45%
src/app/maintenance-worker.ts 2 0.0%
src/handlers/event-strategies/replaceable-event-strategy.ts 2 84.62%
src/adapters/web-server-adapter.ts 3 56.67%
src/app/worker.ts 3 34.29%
src/handlers/event-message-handler.ts 3 82.69%
src/factories/rate-limiter-factory.ts 4 45.45%
src/utils/settings.ts 4 65.82%
Totals Coverage Status
Change from base Build 4343993912: -4.2%
Covered Lines: 1117
Relevant Lines: 2135

💛 - Coveralls

@cameri cameri requested review from Semisol and antonleviathan April 4, 2023 19:38
@cameri cameri requested a review from bmewj April 4, 2023 22:53
Comment on lines 261 to 265
return
}

if (this.getRelayPublicKey() === event.pubkey) {
return undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

Inconsistent returns, is this intentional?

Copy link
Owner Author

Choose a reason for hiding this comment

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

this is fine, we return undefined if user is admitted/whitelisted or a string with the reason if they are not admitted

this new check fixes the issue of the relay's public key not being allowed on the relay when payment is enabled which is a big oversight

Copy link
Owner Author

Choose a reason for hiding this comment

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

in the future we could change this pattern to using constants or symbols

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah got it, I was referring more to line 261 vs line 265, cause one is just return and the other return undefined

Copy link
Owner Author

Choose a reason for hiding this comment

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

Ah, I'll remove the extra undefined

@@ -181,15 +181,33 @@ export const identifyEvent = async (event: UnidentifiedEvent): Promise<UnsignedE
return { ...event, id }
}

export function getRelayPrivateKey(relayUrl: string): string {
let privateKeyCache: string | undefined
export function getRelayPrivateKey(secret: string): string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is secret an optional parameter? If so we could make the type indicate this

Copy link
Owner Author

Choose a reason for hiding this comment

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

it should always be the relay's URL, but it is ignored when RELAY_PRIVATE_KEY env var is set

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, why is the param called secret?

src/utils/event.ts Outdated Show resolved Hide resolved
@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 7, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

49.4% 49.4% Coverage
0.0% 0.0% Duplication

@cameri cameri merged commit e1561e7 into main Apr 7, 2023
@cameri cameri deleted the fix/invoice-page branch April 7, 2023 16:48
github-actions bot pushed a commit that referenced this pull request May 12, 2023
# [1.23.0](v1.22.6...v1.23.0) (2023-05-12)

### Bug Fixes

* add SECRET as env variable ([#298](#298)) ([58a1254](58a1254))
* invoice auto marked as paid ([be6d6f1](be6d6f1))
* issues with invoices ([#271](#271)) ([e1561e7](e1561e7))

### Features

* add LNURL processor ([#202](#202)) ([f237400](f237400))
* allow lightning zap receipts on paid relays ([#303](#303)) ([14bc96f](14bc96f))
@github-actions
Copy link

🎉 This PR is included in version 1.23.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

cameri pushed a commit that referenced this pull request May 15, 2023
# [1.23.0](v1.22.6...v1.23.0) (2023-05-12)

### Bug Fixes

* add SECRET as env variable ([#298](#298)) ([58a1254](58a1254))
* invoice auto marked as paid ([be6d6f1](be6d6f1))
* issues with invoices ([#271](#271)) ([e1561e7](e1561e7))

### Features

* add LNURL processor ([#202](#202)) ([f237400](f237400))
* allow lightning zap receipts on paid relays ([#303](#303)) ([14bc96f](14bc96f))
cameri added a commit that referenced this pull request May 15, 2023
* chore: hide powered by zebedee if payment processor is not

* chore: add nodeless as payments processor to settings

* fix: bad content type on zebedee callback req handler

* chore(release): 1.23.0 [skip ci]

# [1.23.0](v1.22.6...v1.23.0) (2023-05-12)

### Bug Fixes

* add SECRET as env variable ([#298](#298)) ([58a1254](58a1254))
* invoice auto marked as paid ([be6d6f1](be6d6f1))
* issues with invoices ([#271](#271)) ([e1561e7](e1561e7))

### Features

* add LNURL processor ([#202](#202)) ([f237400](f237400))
* allow lightning zap receipts on paid relays ([#303](#303)) ([14bc96f](14bc96f))

* feat: implement nodeless payments processor

* docs: add accepting payments section

* chore: validate nodeless webhook secret

* chore: hide powered-by-zebedee for non-zebedee processors

---------

Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
github-actions bot pushed a commit that referenced this pull request May 15, 2023
# [1.24.0](v1.23.0...v1.24.0) (2023-05-15)

### Features

* implement nodeless payments processor ([#305](#305)) ([52aac39](52aac39)), closes [#298](#298) [#271](#271) [#202](#202) [#303](#303)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants