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

Fallbacks, batch, web hooks, LNURL-Pay, more improvements #10

Open
wants to merge 58 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
7d3ba93
Partial create lnurl wdraw, wdrawrequest, wdraw
Kexkey Jul 15, 2021
3b6012a
First successful end2end withdraw, tests
Kexkey Jul 17, 2021
56cb255
Webhooks and e2e test
Kexkey Jul 22, 2021
08f99d7
Return bolt11 and decoded LNURL
Kexkey Jul 24, 2021
adc237c
case fix 1
Kexkey Jul 24, 2021
e58d570
case fix 2
Kexkey Jul 24, 2021
395b0e8
e2e test with https on preprod
Kexkey Jul 25, 2021
3651b3d
Expiration, delete, get, more tests
Kexkey Jul 27, 2021
4d6c6e4
Locks on delete lnurlwithdraw to avoid doublepay
Kexkey Jul 30, 2021
cad6653
Tests for delete lnurlwithdraw
Kexkey Jul 30, 2021
32b757f
secret_token unicity catch
Kexkey Jul 30, 2021
6a21f60
Added script LNURL wallet
Kexkey Aug 3, 2021
aa863bb
Changed amount to msatoshi
Kexkey Aug 4, 2021
0db696a
Fixed withdrawnDetails error in db
Kexkey Aug 4, 2021
e74e2bd
Call webhook only when withdraw successful
Kexkey Aug 12, 2021
b56fcc4
Added a 30sec timeout to CN
Kexkey Aug 13, 2021
311c776
Switched to Prisma ORM, added fallback, batch, webhooks
Kexkey Aug 31, 2021
e29dadc
Last commit didn't commit everything
Kexkey Aug 31, 2021
265468d
expiresAt and batched webhook
Kexkey Sep 2, 2021
ccde15d
Fixed timeout management and locks
Kexkey Sep 2, 2021
6377667
Added new stuff in README
Kexkey Sep 2, 2021
a3981df
Secured with more locks
Kexkey Sep 3, 2021
236ff44
pay retry twice and validate previous bolt11
Kexkey Sep 7, 2021
1bb8683
Added forceFallback
Kexkey Sep 7, 2021
f274769
Made LN pay more robust
Kexkey Sep 10, 2021
60479af
Fixed some comments and tests
Kexkey Sep 18, 2021
682ac73
Don't fallback if payment done in background
Kexkey Oct 7, 2021
6aaf80b
Call webhook only when paid
Kexkey Oct 7, 2021
cd93757
Better tests
Kexkey Nov 9, 2021
2ab6844
Fixed tests
Kexkey Nov 11, 2021
80010e3
prisma on arm32, small fixes in tests
Kexkey Nov 15, 2021
f98df05
Fixed forceFallback when payment pending
Kexkey Nov 16, 2021
03635c2
JWT compliant token
Kexkey Nov 25, 2021
38f1633
Merge pull request #2 from SatoshiPortal/features/jwtfix
Kexkey Nov 27, 2021
b2af9e2
dependabot directives
Kexkey Dec 3, 2021
d2d72b2
Lots of changes including tests and traefik v2
Kexkey Apr 28, 2022
178723e
Fix on detecting payment status
Kexkey Aug 10, 2022
cfa064c
Small fixes in tests
Kexkey Jan 8, 2023
aeb6272
initial LNURL-pay commit
Talej Jan 26, 2023
e5a04e2
cleaned up LnAddress
Talej Jan 27, 2023
26c87a3
Small fixes, improvements and tests
Kexkey Mar 3, 2023
ea30e43
Fixes to desc_hash, more tests, lnurlpay-wallet
Kexkey Mar 7, 2023
5b2a6ad
More tests
Kexkey Mar 6, 2024
1efe091
Fixed mandatory description matching for lnurl-w
Kexkey Nov 13, 2024
104e0c5
Validate bolt11 before saving it
Kexkey Nov 12, 2024
783e9ce
Merge branch 'dev' into features/diffdesc
Kexkey Nov 14, 2024
fbe3e08
Merge pull request #13 from SatoshiPortal/features/diffdesc
Kexkey Nov 14, 2024
608ae82
Added a webhook when a failed claim attempt occurs
Kexkey Nov 15, 2024
323c880
typo
Kexkey Nov 16, 2024
be41c5d
Merge pull request #14 from SatoshiPortal/features/failedwebhook
Kexkey Nov 18, 2024
d6bddf1
IReqPayLnAddress fix (#15)
Talej Nov 19, 2024
942e78b
Expired Voucher callbacks
Kexkey Dec 3, 2024
279e514
Validate fallback Bitcoin address when creating LNURL-W
Kexkey Dec 3, 2024
f071cd5
Merge pull request #16 from SatoshiPortal/features/expiredwebhook
Kexkey Dec 3, 2024
d071d19
tt
Kexkey Dec 3, 2024
a4e474d
Merge pull request #17 from SatoshiPortal/features/validateaddress
Kexkey Dec 4, 2024
e540107
Just reformating code with 132 char width
Kexkey Dec 10, 2024
b5ce2b7
CORS headers and small bug fix
Kexkey Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Dockerfile
node_modules
build
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
build

26 changes: 26 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {},
"plugins": [
"@typescript-eslint",
"prettier"
],
"rules": {
"prettier/prettier": [
"error",
{
"printWidth": 132
}
],
"@typescript-eslint/interface-name-prefix": [
"off"
]
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
]
}
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
target-branch: "dev"
109 changes: 6 additions & 103 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,104 +1,7 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
node_modules
# Keep environment variables out of version control
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
build
logs
*sqlite*
*.pem
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to remote",
"protocol": "inspector",
"address": "localhost",
"port": 9229,
"sourceMaps": true,
"localRoot": "${workspaceRoot}",
"remoteRoot": "/lnurl",
"sourceMapPathOverrides": {
"/usr/src/app/*": "${workspaceRoot}/*"
}
}
]
}
69 changes: 69 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# arm32 for arm32
ARG ARCH="all"

#--------------------------------------------------------------

FROM node:17.1-bullseye-slim as build-base-all

WORKDIR /lnurl

RUN apt-get update && apt-get install -y openssl

COPY package.json /lnurl

RUN npm install

#--------------------------------------------------------------

# Prisma team officially doesn't support arm32 engines binaries.
# pantharshit00 put together what's needed to build them:
# https://github.com/prisma/prisma/issues/5379#issuecomment-843961332
# https://github.com/pantharshit00/prisma-rpi-builds

# We will be using those.

# This stage will only be used when building the image with build-arg ARCH=arm32

FROM node:17.1-bullseye-slim as build-base-arm32

WORKDIR /lnurl

RUN apt-get update && apt-get install -y openssl wget

COPY --from=build-base-all /lnurl/node_modules/ /lnurl/node_modules/

RUN wget --quiet -O /lnurl/node_modules/@prisma/engines/introspection-engine https://github.com/pantharshit00/prisma-rpi-builds/releases/download/3.2.1/introspection-engine \
&& wget --quiet -O /lnurl/node_modules/@prisma/engines/libquery_engine.so https://github.com/pantharshit00/prisma-rpi-builds/releases/download/3.2.1/libquery_engine.so \
&& wget --quiet -O /lnurl/node_modules/@prisma/engines/migration-engine https://github.com/pantharshit00/prisma-rpi-builds/releases/download/3.2.1/migration-engine \
&& wget --quiet -O /lnurl/node_modules/@prisma/engines/prisma-fmt https://github.com/pantharshit00/prisma-rpi-builds/releases/download/3.2.1/prisma-fmt \
&& wget --quiet -O /lnurl/node_modules/@prisma/engines/query-engine https://github.com/pantharshit00/prisma-rpi-builds/releases/download/3.2.1/query-engine

RUN cd /lnurl/node_modules/@prisma/engines/ \
&& chmod +x introspection-engine migration-engine prisma-fmt query-engine

ENV PRISMA_QUERY_ENGINE_BINARY=/lnurl/node_modules/@prisma/engines/query-engine
ENV PRISMA_MIGRATION_ENGINE_BINARY=/lnurl/node_modules/@prisma/engines/migration-engine
ENV PRISMA_INTROSPECTION_ENGINE_BINARY=/lnurl/node_modules/@prisma/engines/introspection-engine
ENV PRISMA_FMT_BINARY=/lnurl/node_modules/@prisma/engines/prisma-fmt
ENV PRISMA_QUERY_ENGINE_LIBRARY=/lnurl/node_modules/@prisma/engines/libquery_engine.so
ENV PRISMA_CLI_QUERY_ENGINE_TYPE=binary
ENV PRISMA_QUERY_ENGINE_TYPE=binary

#--------------------------------------------------------------

FROM build-base-${ARCH}

ENV PRISMA_CLI_QUERY_ENGINE_TYPE=binary
ENV PRISMA_QUERY_ENGINE_TYPE=binary

COPY package.json /lnurl
COPY tsconfig.json /lnurl
COPY prisma /lnurl/prisma
COPY src /lnurl/src

RUN npx prisma generate
RUN npm run build

EXPOSE 9229 3000

ENTRYPOINT [ "npm", "run", "start" ]
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# lnurl_cypherapp
# LNURL Cypherapp

LNURL cypherapp for cyphernode

## General endpoints

### reloadConfig, getConfig

Request: N/A

Response:

```TypeScript
{
result?: {
LOG: string;
BASE_DIR: string;
DATA_DIR: string;
DB_NAME: string;
URL_API_SERVER: string;
URL_API_PORT: number;
URL_API_CTX: string;
URL_CTX_WEBHOOKS: string;
SESSION_TIMEOUT: number;
CN_URL: string;
CN_API_ID: string;
CN_API_KEY: string;
BATCHER_URL: string;
LN_SERVICE_SERVER: string;
LN_SERVICE_PORT: number;
LN_SERVICE_CTX: string;
LN_SERVICE_WITHDRAW_REQUEST_CTX: string;
LN_SERVICE_WITHDRAW_CTX: string;
RETRY_WEBHOOKS_TIMEOUT: number;
CHECK_EXPIRATION_TIMEOUT: number;
},
error?: {
code: number;
message: string;
data?: D;
}
}
```

## LNURL-Withdraw specific endpoints

[LNURL-Withdraw specific documentation can be found here](doc/LNURL-Withdraw.md)

## LNURL-Pay specific endpoints

[LNURL-Pay specific documentation can be found here](doc/LNURL-Pay.md)
26 changes: 26 additions & 0 deletions cypherapps/data/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"LOG": "DEBUG",
"BASE_DIR": "/lnurl",
"DATA_DIR": "data",
"DB_NAME": "lnurl.sqlite",
"URL_API_SERVER": "http://lnurl",
"URL_API_PORT": 8000,
"URL_API_CTX": "/api",
"URL_CTX_WITHDRAW_WEBHOOKS": "/webhooks",
"URL_CTX_PAY_WEBHOOKS": "/payWebhooks",
"SESSION_TIMEOUT": 600,
"CN_URL": "https://gatekeeper:2009/v0",
"CN_API_ID": "003",
"CN_API_KEY": "bdd3fc82dff1fb9193a9c15c676e79da10367a540a85cb50b736e77f452f9dc6",
"BATCHER_URL": "http://batcher:8000",
"LN_SERVICE_SCHEME": "https",
"LN_SERVICE_DOMAIN": "yourdomain",
"LN_SERVICE_PORT": 443,
"LN_SERVICE_CTX": "/lnurl",
"LN_SERVICE_WITHDRAW_REQUEST_CTX": "/withdrawRequest",
"LN_SERVICE_WITHDRAW_CTX": "/withdraw",
"LN_SERVICE_PAY_SPECS_CTX": "/paySpecs",
"LN_SERVICE_PAY_REQUEST_CTX": "/payRequest",
"RETRY_WEBHOOKS_TIMEOUT": 1,
"CHECK_EXPIRATION_TIMEOUT": 1
}
Loading