Compare commits

...
6 Commits
7 changed files with 2593 additions and 323 deletions
+32 -24
View File
@@ -8,6 +8,10 @@ This repository contains the back end code. The user interface is contained in t
**Warning**: This repository is under active development. Things will be constantly changing and breaking.
## Media
- [High-level Overview of bch-dex](https://youtu.be/LVX8CLi4sHw) (Video)
- [Developer walk-through for installing and hacking on bch-dex](https://youtu.be/T5XI43-SWJo) (Video)
## Participate
This is an open source project, and we encourage other JavaScript developers to participate in its creation and maintenance. We have two chat rooms for the community:
- [Telegram Channel](https://t.me/psf_dex_dev)
@@ -26,33 +30,37 @@ The above software is orchestrated using [Docker](https://www.docker.com/) and D
Instructions for setting up Node.js, Docker, and Docker Compose can be found in [this Gist](https://gist.github.com/christroutner/a39f656850dc022b60f25c9663dd1cdd). Walk-through videos can also be found on the [PSF Videos page](https://psfoundation.cash/video/).
Building the Docker containers and getting the app working involve these steps:
- Follow the direction in [this Gist](https://gist.github.com/christroutner/a39f656850dc022b60f25c9663dd1cdd) to install Node.js, Docker, and Docker Compose.
- Clone the repository with `git clone https://github.com/Permissionless-Software-Foundation/bch-dex` and enter it with `cd bch-dex`.
- Install dependencies by running `npm install`
- Create a wallet by executing the [create-wallet.js script](./production/scripts/create-wallet.js) with `node create-wallet.js`
- Move the `wallet.json` file to the [x86 Docker folder](./production/docker/bch-dex) or the [RPi Docker folder](./production/rpi-docker/bch-dex/) depending on your hardware target.
- Change directory to the `docker` or `rpi-docker` folder depending on your hardware target.
- Build the Docker containers with `docker-compose build --no-cache`.
- Start the Docker containers with `docker-compose up -d`
- Wait for the containers to run for about a minute, then bring them down with `docker-compose down`. That will create the needed folders in `production/data`.
- Copy the `swarm.key` into the `production/data/go-ipfs/data/` directory. This will allow the IPFS node to connect to the PSF private network.
- Bring the containers back up with `docker-compose up -d`.
- Wait for the P2WDB to sync and populate bch-dex with trade data. You can monitor it with `docker logs --tail 20 -f p2wdb`.
- Open a web browser and navigate the `http://localhost:4500`. You'll be able to see new Offers as they come in and are detected by bch-dex.
- To take the other side of the trade, click the `Take` button in the UI.
- You can add the 12-word mnemonic from the `wallet.json` file to the the web wallet, which will mirror your wallet in the UI, and allow you to perform basic wallet functions (send and receive BCH and tokens).
<ol>
<li>Follow the direction in [this Gist](https://gist.github.com/christroutner/a39f656850dc022b60f25c9663dd1cdd) to install Node.js, Docker, and Docker Compose.</li>
<li>Clone the repository with `git clone https://github.com/Permissionless-Software-Foundation/bch-dex` and enter it with `cd bch-dex`.</li>
<li>Install dependencies by running `npm install`</li>
<li>Create a wallet by executing the [create-wallet.js script](./production/scripts/create-wallet.js) with `node create-wallet.js`</li>
<li>Move the `wallet.json` file to the `bch-dex` folder in either the [x86 Docker folder](./production/docker/bch-dex) or the [RPi Docker folder](./production/rpi-docker/bch-dex/) depending on your hardware target.</li>
<li>Change directory to the `docker` or `rpi-docker` folder depending on your hardware target.</li>
<li>Build the Docker containers with `docker-compose build --no-cache`.</li>
<li>Start the Docker containers with `docker-compose up -d`</li>
<li>Wait for the containers to run for about a minute, then bring them down with `docker-compose down`. That will create the needed folders in `production/data`.</li>
<li>Copy the `swarm.key` into the `production/data/go-ipfs/data/` directory. This will allow the IPFS node to connect to the PSF private network.</li>
<li>Bring the containers back up with `docker-compose up -d`.</li>
<li>Wait for the P2WDB to sync and populate bch-dex with trade data. You can monitor it with `docker logs --tail 20 -f p2wdb`.</li>
<li>Open a web browser and navigate the `http://localhost:4500`. You'll be able to see new Offers as they come in and are detected by bch-dex.</li>
<li>To take the other side of the trade, click the `Take` button in the UI.</li>
<li>You can add the 12-word mnemonic from the `wallet.json` file to the the web wallet, which will mirror your wallet in the UI, and allow you to perform basic wallet functions (send and receive BCH and tokens).</li>
</ol>
### Applying Software Updates
As this is an active project, software updates will happen frequently. To apply a software update, perform these steps.
- Enter the `docker` or `rpi-docker` folder, depending on your hardware target.
- Bring down the Docker containers with `docker-compose down`.
- Pull in the software updates with `git pull`
- Update dependencies with `npm install`
- Rebuild the Docker containers with `docker-compose build --no-cache`
- Clean up disk space by deleting old Docker images with `./cleanup-images.sh`
- Start the Docker containers with `docker-compose up -d`
<ol>
<li>Enter the `docker` or `rpi-docker` folder, depending on your hardware target.</li>
<li>Bring down the Docker containers with `docker-compose down`.</li>
<li>Pull in the software updates with `git pull`</li>
<li>Update dependencies with `npm install`</li>
<li>Rebuild the Docker containers with `docker-compose build --no-cache`</li>
<li>Clean up disk space by deleting old Docker images with `./cleanup-images.sh`</li>
<li>Start the Docker containers with `docker-compose up -d`</li>
</ol>
Sometimes it may be necessary to delete the databases before applying a software update. This can be done by stopping the Docker containers and deleting the `production/data` directory. When the Docker containers are restarted, they will recreate that directory. The P2WDB will re-sync and bch-dex will be populated with fresh trade data.
## License
+1 -1
View File
@@ -88,7 +88,7 @@ module.exports = {
p2wdbAppId: process.env.APP_ID ? process.env.APP_ID : 'bch-dex-test557',
webhookTarget: process.env.WEBHOOKTARGET
? process.env.WEBHOOKTARGET
: 'http://localhost:5700/offer',
: 'http://localhost:5700/p2wdb',
// IPFS Ports
ipfsTcpPort: process.env.IPFS_TCP_PORT ? process.env.IPFS_TCP_PORT : 4001,
+2550 -291
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -27,9 +27,9 @@
},
"repository": "Permissionless-Software-Foundation/bch-dex",
"dependencies": {
"@psf/bch-js": "6.2.1",
"@psf/bch-js": "6.2.5",
"axios": "0.21.1",
"bch-message-lib": "2.1.4",
"bch-message-lib": "2.2.0",
"bcryptjs": "2.4.3",
"bitcoincashjs-lib": "3.3.3",
"glob": "7.1.6",
@@ -52,7 +52,7 @@
"koa2-ratelimit": "0.9.1",
"libp2p": "^0.36.2",
"line-reader": "0.4.0",
"minimal-slp-wallet": "4.4.5",
"minimal-slp-wallet": "4.4.7",
"mongoose": "5.13.13",
"node-fetch": "npm:@achingbrain/node-fetch@2.6.7",
"nodemailer": "6.4.17",
+2
View File
@@ -89,6 +89,8 @@ services:
context: ./bch-dex-ui/
dockerfile: Dockerfile
container_name: dex-ui
environment:
SERVER: 'http://192.168.2.3'
logging:
driver: 'json-file'
options:
+3 -3
View File
@@ -8,8 +8,8 @@
const axios = require('axios')
// const LOCALHOST = 'http://localhost:5700'
const LOCALHOST = 'http://172.17.0.1:5700'
const LOCALHOST = 'http://localhost:5700'
// const LOCALHOST = 'http://172.17.0.1:5700'
async function start () {
try {
@@ -22,7 +22,7 @@ async function start () {
buyOrSell: 'sell',
rateInBaseUnit: 5000,
minUnitsToExchange: 5000,
numTokens: 1
numTokens: 2
}
const options = {
+2 -1
View File
@@ -49,7 +49,8 @@ class Wlogger {
}
notifyRotation (oldFilename, newFilename) {
this.wlogger.info('Rotating log files')
// this.wlogger.info('Rotating log files')
console.log('Rotating log files')
}
outputToConsole () {