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

feat: implement bitcoin api #1

Merged
merged 50 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
759b893
feat: add vercel config and serverless endpoint
ahonn Feb 21, 2024
80dadfc
feat: add bitcoin v1 address balance route
ahonn Feb 22, 2024
38cea96
feat: call importdescriptors with watchonly flag
ahonn Feb 22, 2024
2ecd373
feat: add electrs api to fetch balance
ahonn Feb 22, 2024
c8754c5
feat: add types and update docs
ahonn Feb 25, 2024
75b73e3
feat: adjust dir struct and add transaction api
ahonn Feb 26, 2024
f2e4830
feat: add jwt token and onRequest hook
ahonn Feb 26, 2024
18635dd
feat: fixed bitcoind decorator and add block api
ahonn Feb 26, 2024
0c06db5
feat: add sentry to capture error
ahonn Feb 26, 2024
45c32e5
chore: update environment variables
ahonn Feb 26, 2024
35fbd67
feat: add cache plugin and refactor swagger/jwt to plugin
ahonn Feb 26, 2024
fc6813b
feat: impl rate limit plugin
ahonn Feb 26, 2024
a879b4b
feat: add cors
ahonn Feb 26, 2024
a54c0c3
feat: update address balance response key case
ahonn Feb 27, 2024
352c1cd
feat: update token generate params
ahonn Feb 27, 2024
e8976e0
fix: fix "scriptpubkey_address" is required
ahonn Feb 27, 2024
52b7f25
feat: update cache plugin
ahonn Feb 27, 2024
8aaa935
fix: fix cache JSON.stringify
ahonn Feb 27, 2024
96a9315
feat: integrate Sentry profiler
ahonn Feb 27, 2024
ecd54ff
refactor: update Bitcoin status object to include optional block info
ahonn Feb 28, 2024
0731596
feat: update cache plugin and modify send transaction response struct
ahonn Feb 28, 2024
f27ded1
feat: refactor bitcoind/electrs to request service
ahonn Feb 28, 2024
6bbc000
refactor: improve handling of custom headers in Bitcoin transaction r…
ahonn Feb 28, 2024
1938a9f
fix: remove electrs useless setLogger method
ahonn Feb 28, 2024
5809c19
feat: add bitcoin address validation and block fetching capabilities
ahonn Feb 29, 2024
538f5ad
feat: add cache-control header
ahonn Feb 29, 2024
a5dd0ec
feat: add @fastify/compress to reduce content size
ahonn Feb 29, 2024
d6ec204
refactor: refactor dependency injection and logger interceptors.
ahonn Feb 29, 2024
7d27806
feat: revamp container registration and redis handling
ahonn Feb 29, 2024
914f86f
refactor: add sentry profiling
ahonn Feb 29, 2024
9b47ab2
fix: improve cache operations and error handling
ahonn Feb 29, 2024
1e91220
feat: skip caching for docs routes
ahonn Feb 29, 2024
bbeedbe
test: add some test cases
ahonn Mar 1, 2024
f54cea1
test: refactor testing setup
ahonn Mar 1, 2024
910ba8a
build: update npm start script
ahonn Mar 1, 2024
4c0baab
test: add test cases and add pre-commit hook
ahonn Mar 4, 2024
ac1c708
ci: add unit tests workflow
ahonn Mar 4, 2024
9cfb28c
ci: update test workflow
ahonn Mar 4, 2024
71fd9ea
fix: fix crashing vitest with free(): invalid next size (fast)
ahonn Mar 4, 2024
391c35e
ci: update
ahonn Mar 4, 2024
17e278a
feat: add jwt aud validate
ahonn Mar 4, 2024
81e0a20
feat: rename ALLOWED_URLS to JWT_ALLOWED_URLS
ahonn Mar 4, 2024
0c404c9
feat: add cors max-age
ahonn Mar 4, 2024
d39d974
feat: check origin header in jwt verify
ahonn Mar 4, 2024
52ddbbc
test: add origin header to test request
ahonn Mar 4, 2024
7e2527a
Merge pull request #2 from ckb-cell/feat/jwt-aud-validate
ahonn Mar 4, 2024
226bffb
feat: add min_satoshi filter param to address balance
ahonn Mar 4, 2024
84b8c36
chore: add cache plugin comments
ahonn Mar 4, 2024
63a051e
test: add test for getting address balance with min_satoshi param
ahonn Mar 4, 2024
4f28a7d
feat: add invalid aud error
ahonn Mar 5, 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
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
JWT_SECRET=
REDIS_URL=

BITCOIN_JSON_RPC_URL=
BITCOIN_JSON_RPC_USERNAME=
BITCOIN_JSON_RPC_PASSWORD=

BITCOIN_ELECTRS_API_URL=
38 changes: 38 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Unit Tests

on:
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Install PNPM
uses: pnpm/action-setup@v3
with:
version: 8

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "21"
cache: "pnpm"

- name: Install dependencies
run: pnpm install

- name: Run Unit Tests
env:
JWT_SECRET: ${{ secrets.JWT_SECRET }}
BITCOIN_JSON_RPC_URL: ${{ secrets.BITCOIN_JSON_RPC_URL }}
BITCOIN_JSON_RPC_USERNAME: ${{ secrets.BITCOIN_JSON_RPC_USERNAME }}
BITCOIN_JSON_RPC_PASSWORD: ${{ secrets.BITCOIN_JSON_RPC_PASSWORD }}
BITCOIN_ELECTRS_API_URL: ${{ secrets.BITCOIN_ELECTRS_API_URL }}
run: pnpm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ dist

yarn.lock
.vercel
coverage
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"semi": true,
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"jsxSingleQuote": false,
"trailingComma": "all",
"endOfLine": "lf",
"printWidth": 120
}
8 changes: 8 additions & 0 deletions api/serverless.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { buildFastify } from '../src/app';

const app = buildFastify();

export default async (req: Request, res: Response) => {
await app.ready();
app.server.emit('request', req, res);
};
48 changes: 44 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,65 @@
"description": "",
"main": "index.js",
"scripts": {
"dev": "tsx ./src/index.ts",
"start": "node ./dist/index.js",
"build": "tsc -p tsconfig.json"
"dev": "tsx watch ./src/index.ts",
"start": "node ./dist/src/index.js",
"build": "tsc -p tsconfig.json",
"test": "vitest",
"coverage": "vitest run --coverage"
},
"keywords": [],
"author": "Yuexun Jiang <yuexunjiang@cryptape.com>",
"license": "ISC",
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
},
"lint-staged": {
"*.ts": [
"eslint --fix",
"prettier --ignore-unknown --write"
]
},
"dependencies": {
"@fastify/compress": "^7.0.0",
"@fastify/cors": "^9.0.1",
"@fastify/http-proxy": "^9.4.0",
"@fastify/jwt": "^8.0.0",
"@fastify/rate-limit": "^9.1.0",
"@fastify/redis": "^6.1.1",
"@fastify/sensible": "^5.5.0",
"@fastify/swagger": "^8.14.0",
"@fastify/swagger-ui": "^3.0.0",
"@fastify/type-provider-typebox": "^4.0.0",
"@sentry/node": "^7.102.1",
"@sentry/profiling-node": "^7.102.1",
"@sinclair/typebox": "^0.32.14",
"awilix": "^10.0.1",
"axios": "^1.6.7",
"dotenv": "^16.4.2",
"fastify": "^4.26.0",
"fastify-plugin": "^4.5.1",
"ioredis": "^5.3.2",
"multicoin-address-validator": "^0.5.16",
"pino": "^8.19.0",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/ioredis-mock": "^8.2.5",
"@types/multicoin-address-validator": "^0.5.2",
"@types/node": "^20.11.17",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitest/coverage-istanbul": "^1.3.1",
"@vitest/ui": "^1.3.1",
"eslint": "^8.56.0",
"ioredis-mock": "^8.9.0",
"lint-staged": "^15.2.2",
"pino-pretty": "^10.3.1",
"prettier": "^3.2.5",
"simple-git-hooks": "^2.10.0",
"tsx": "^4.7.1",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"vercel": "^33.5.1",
"vitest": "^1.3.1"
}
}
Loading
Loading