cameri / nostream

A Nostr Relay written in TypeScript
MIT License
729 stars 188 forks source link

feat: add LNURL processor #202

Closed im-adithya closed 1 year ago

im-adithya commented 1 year ago

Description

Adds an lnurl processor for payments. We used the LNURL verify spec: https://github.com/lnurl/luds/issues/182

This is made in such a way that any provider can implement, all they have to do is return a verify link in their lnurlp callback.

For example: https://getalby.com/lnurlp/adithya/callback?amount=10000

{
    "status": "OK",
    "verify": "https://getalby.com/lnurlp/adithya/verify/HLzzSn7vzrAwgrsmTJ9LjQSH",  // <--
    "routes": [],
    "pr": <bolt11 invoice>
}

And a call to the verify URL returns the status:

{
    "status": "OK",
    "settled": false, // <--
    "preimage": null,
    "pr": <bolt11 invoice>
}

To support this, we added a verify_url field in the database.

Related Issue

Motivation and Context

Mitigates the need of adding processors for each and every provider separately.

How Has This Been Tested?

Tested it locally.

Screenshots (if appropriate):

Screenshot 2023-02-17 at 2 31 48 PM

Types of changes

Checklist:

coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 4164668858


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/app/maintenance-worker.ts 0 1 0.0%
src/payments-processors/payments-procesor.ts 0 1 0.0%
src/payments-processors/zebedee-payments-processor.ts 0 3 0.0%
src/services/payments-service.ts 0 3 0.0%
src/factories/payments-processor-factory.ts 3 10 30.0%
src/payments-processors/lnurl-payments-processor.ts 5 22 22.73%
<!-- Total: 9 41 21.95% -->
Files with Coverage Reduction New Missed Lines %
src/services/payments-service.ts 1 7.03%
<!-- Total: 1 -->
Totals Coverage Status
Change from base Build 4148256062: -0.6%
Covered Lines: 1174
Relevant Lines: 1983

💛 - Coveralls
im-adithya commented 1 year ago

@Cameri can you please review this :D

cameri commented 1 year ago

@Cameri can you please review this :D

Thanks for contributing. It's on my todo list.

cameri commented 1 year ago

@im-adithya could you please rebase and fix the conflicts?

im-adithya commented 1 year ago

Done!

cameri commented 1 year ago

@im-adithya do you have a relay instance running with this where you and I can test this code?

im-adithya commented 1 year ago

Sorry, I don't :( I just tested it locally

github-actions[bot] commented 1 year ago

:tada: This PR is included in version 1.23.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: