Skip to content

Commit

Permalink
Apply changes from code we received from a retired Bisq dev.
Browse files Browse the repository at this point in the history
As we don't have a git version to know on which version was based on, it was hard to merge.
I tried to not delete any files from latest snapshot (before Bisq got removed from mempool) and I tried to keep new changes which are likely unreleated to his changes. Though its messy and requires a dev familiar with the used tech stack to clear all that up.
  • Loading branch information
HenrikJannsen committed Jul 21, 2024
1 parent 1b21cd8 commit 341bc8c
Show file tree
Hide file tree
Showing 89 changed files with 14,393 additions and 30,883 deletions.
43 changes: 43 additions & 0 deletions _README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## Quick Setup for Development

(prerequisite: bisq-daonode is installed & running)

### Install node, npm, n

```
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
source ~/.bashrc
nvm install v16.14
node -v
npm -v
npm install -g n
n --version
```

### Explorer Backend


```
cd mempool/backend
npm install
npm run build
npm run start
```

logging should show it connecting to Bisq, retrieving blocks, prices, offers, trades etc.

### Explorer Frontend

```
cd mempool/frontend
npm install
npm run build
npm run serve
```

the explorer should be visible in a browser at http://localhost:4200
alternately, to have the frontend served by nginx:
`cp mempool/frontend/dist/mempool/browser/en-US/* /var/www/mempool`



3 changes: 0 additions & 3 deletions backend/npm_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@ rm -rf package
# Move JS and deps
mv dist package
cp -R node_modules package
# Remove symlink for rust-gbt and insert real folder
rm package/node_modules/rust-gbt
cp -R rust-gbt package/node_modules
# Clean up deps
npm run package-rm-build-deps
3 changes: 1 addition & 2 deletions backend/npm_package_rm_build_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ set -e
cd package/node_modules
rm -r \
typescript \
@typescript-eslint \
@napi-rs
@typescript-eslint
34 changes: 11 additions & 23 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,50 @@
{
"name": "mempool-backend",
"version": "3.0.0-dev",
"description": "Bitcoin mempool visualizer and blockchain explorer backend",
"name": "bisq-explorer-backend",
"version": "1.0.0-dev",
"description": "Bisq explorer backend",
"license": "GNU Affero General Public License v3.0",
"homepage": "https://mempool.space",
"homepage": "https://bisq.network",
"repository": {
"type": "git",
"url": "git+https://github.com/mempool/mempool"
"url": "git+https://github.com/bisq-network/bisq"
},
"bugs": {
"url": "https://github.com/mempool/mempool/issues"
"url": "https://github.com/bisq-network/bisq/issues"
},
"keywords": [
"bitcoin",
"mempool",
"bisq",
"blockchain",
"explorer",
"liquid",
"lightning"
"explorer"
],
"main": "index.ts",
"scripts": {
"tsc": "./node_modules/typescript/bin/tsc -p tsconfig.build.json",
"build": "npm run tsc && npm run create-resources",
"clean": "rm -rf ./dist/ ./node_modules/ ./package/ ./rust-gbt/",
"create-resources": "cp ./src/tasks/price-feeds/mtgox-weekly.json ./dist/tasks && node dist/api/fetch-version.js",
"create-resources": "node dist/api/fetch-version.js",
"package": "./npm_package.sh",
"package-rm-build-deps": "./npm_package_rm_build_deps.sh",
"preinstall": "cd ../rust/gbt && npm run build-release && npm run to-backend",
"start": "node --max-old-space-size=2048 dist/index.js",
"start-production": "node --max-old-space-size=16384 dist/index.js",
"reindex-updated-pools": "npm run start-production --update-pools",
"reindex-all-blocks": "npm run start-production --update-pools --reindex-blocks",
"test": "./node_modules/.bin/jest --coverage",
"test:ci": "CI=true ./node_modules/.bin/jest --coverage",
"lint": "./node_modules/.bin/eslint . --ext .ts",
"lint:fix": "./node_modules/.bin/eslint . --ext .ts --fix",
"prettier": "./node_modules/.bin/prettier --write \"src/**/*.{js,ts}\""
},
"dependencies": {
"@babel/core": "^7.24.0",
"@mempool/electrum-client": "1.1.9",
"@babel/core": "^7.23.2",
"@types/node": "^18.15.3",
"axios": "~1.6.1",
"bitcoinjs-lib": "~6.1.3",
"crypto-js": "~4.2.0",
"express": "~4.18.2",
"maxmind": "~4.3.11",
"mysql2": "~3.9.1",
"rust-gbt": "file:./rust-gbt",
"redis": "^4.6.6",
"socks-proxy-agent": "~7.0.0",
"typescript": "~4.9.3",
"ws": "~8.13.0"
},
"devDependencies": {
"@babel/code-frame": "^7.18.6",
"@babel/core": "^7.24.0",
"@babel/core": "^7.23.2",
"@types/compression": "^1.7.2",
"@types/crypto-js": "^4.1.1",
"@types/express": "^4.17.17",
Expand Down
1 change: 0 additions & 1 deletion backend/src/api/backend-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class BackendInfo {
hostname: os.hostname(),
version: versionInfo.version,
gitCommit: versionInfo.gitCommit,
lightning: config.LIGHTNING.ENABLED
};
}

Expand Down
37 changes: 27 additions & 10 deletions backend/src/api/bisq/bisq.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ import { RequiredSpec } from '../../mempool.interfaces';
import bisq from './bisq';
import { MarketsApiError } from './interfaces';
import marketsApi from './markets-api';
import bisqPriceService from './price-service';

class BisqRoutes {
public initRoutes(app: Application) {
app
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/stats', this.getBisqStats)
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/dao-cycles', this.getDaoCycles)
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/tx/:txId', this.getBisqTransaction)
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/block/:hash', this.getBisqBlock)
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/blocks/tip/height', this.getBisqTip)
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/blocks/:index/:length', this.getBisqBlocks)
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/address/:address', this.getBisqAddress)
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/txs/:index/:length', this.getBisqTransactions)
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/markets/price/:currency', this.getBisqMarketPrice)
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/markets/currencies', this.getBisqMarketCurrencies.bind(this))
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/markets/depth', this.getBisqMarketDepth.bind(this))
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/markets/hloc', this.getBisqMarketHloc.bind(this))
Expand All @@ -33,22 +36,27 @@ class BisqRoutes {
res.json(result);
}

private getDaoCycles(req: Request, res: Response) {
const result = bisq.getDaoCycles();
res.json(result);
}

private getBisqTip(req: Request, res: Response) {
const result = bisq.getLatestBlockHeight();
res.type('text/plain');
res.send(result.toString());
}

private getBisqTransaction(req: Request, res: Response) {
const result = bisq.getTransaction(req.params.txId);
private async getBisqTransaction(req: Request, res: Response) {
const result = await bisq.$getTransaction(req.params.txId);
if (result) {
res.json(result);
} else {
res.status(404).send('Bisq transaction not found');
}
}

private getBisqTransactions(req: Request, res: Response) {
private async getBisqTransactions(req: Request, res: Response) {
const types: string[] = [];
req.query.types = req.query.types || [];
if (!Array.isArray(req.query.types)) {
Expand All @@ -64,37 +72,46 @@ class BisqRoutes {

const index = parseInt(req.params.index, 10) || 0;
const length = parseInt(req.params.length, 10) > 100 ? 100 : parseInt(req.params.length, 10) || 25;
const [transactions, count] = bisq.getTransactions(index, length, types);
const [transactions, count] = await bisq.$getTransactions(index, length, types);
res.header('X-Total-Count', count.toString());
res.json(transactions);
}

private getBisqBlock(req: Request, res: Response) {
const result = bisq.getBlock(req.params.hash);
private async getBisqBlock(req: Request, res: Response) {
const result = await bisq.$getBlock(req.params.hash);
if (result) {
res.json(result);
} else {
res.status(404).send('Bisq block not found');
}
}

private getBisqBlocks(req: Request, res: Response) {
private async getBisqBlocks(req: Request, res: Response) {
const index = parseInt(req.params.index, 10) || 0;
const length = parseInt(req.params.length, 10) > 100 ? 100 : parseInt(req.params.length, 10) || 25;
const [transactions, count] = bisq.getBlocks(index, length);
const [transactions, count] = await bisq.$getBlocks(index, length);
res.header('X-Total-Count', count.toString());
res.json(transactions);
}

private getBisqAddress(req: Request, res: Response) {
const result = bisq.getAddress(req.params.address.substr(1));
private async getBisqAddress(req: Request, res: Response) {
const result = await bisq.$getAddress(req.params.address.substr(1));
if (result) {
res.json(result);
} else {
res.status(404).send('Bisq address not found');
}
}

private async getBisqMarketPrice(req: Request, res: Response) {
const result = bisqPriceService.getPrice(req.params.currency);
if (result) {
res.json(result);
} else {
res.status(404).send('Bisq market price not found');
}
}

private getBisqMarketCurrencies(req: Request, res: Response) {
const constraints: RequiredSpec = {
'type': {
Expand Down
Loading

0 comments on commit 341bc8c

Please sign in to comment.