diff --git a/package-lock.json b/package-lock.json index 8407d10..ce9f6fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,14 +9,14 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@psf/bch-js": "6.4.1", + "@psf/bch-js": "6.4.5", "axios": "0.27.2", "bch-message-lib": "2.2.0", "bcryptjs": "2.4.3", "bitcoincashjs-lib": "3.3.3", "glob": "7.1.6", "ipfs": "0.62.3", - "ipfs-coord": "8.0.2", + "ipfs-coord": "8.0.5", "ipfs-http-client": "55.0.0", "jsonrpc-lite": "2.2.0", "jsonwebtoken": "8.5.1", @@ -1311,8 +1311,9 @@ "license": "BSD-3-Clause" }, "node_modules/@psf/bch-js": { - "version": "6.4.1", - "license": "MIT", + "version": "6.4.5", + "resolved": "https://registry.npmjs.org/@psf/bch-js/-/bch-js-6.4.5.tgz", + "integrity": "sha512-sH72zbJJI5oe9EUMczFQb0jCaNQb8rc3/86E6xXKl3325HCwBqE80BX7JFvZ97Qv1gGxwp/3WROp59v6Dz2NKA==", "dependencies": { "@chris.troutner/bip32-utils": "1.0.5", "@psf/bip21": "2.0.1", @@ -7518,10 +7519,9 @@ } }, "node_modules/ipfs-coord": { - "version": "8.0.2", - "resolved": "http://94.130.170.209:4873/ipfs-coord/-/ipfs-coord-8.0.2.tgz", - "integrity": "sha512-CdUH4GLLFArUDb8LIRAXxPlhbRQ44A5PEWB4J9zzDB3by93O7DLEgjqPqLDolalzrtiQBVzoARO/exZvdxBF+w==", - "license": "MIT", + "version": "8.0.5", + "resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-8.0.5.tgz", + "integrity": "sha512-V4pqR+MU290ZxFRE+Rx/7JuxR7LsOFBLuL0av3eVU5ZQWqeF/Zi9vh52zCqpp1IBCXi4QXNZGlysvm16xFDXww==", "dependencies": { "axios": "0.21.4", "bch-encrypt-lib": "2.0.0", @@ -10632,6 +10632,37 @@ "crypto-js": "4.0.0" } }, + "node_modules/minimal-slp-wallet/node_modules/@psf/bch-js": { + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/@psf/bch-js/-/bch-js-6.4.1.tgz", + "integrity": "sha512-/BLGzWH02VqaDNeY05QGMhrCtYDw5bXn45Egz+L5FLcyZaOqONR4kl80T6a8xvTPcREO4R+AjGTRBpfjdikwpA==", + "dependencies": { + "@chris.troutner/bip32-utils": "1.0.5", + "@psf/bip21": "2.0.1", + "@psf/bitcoincash-ops": "2.0.0", + "@psf/bitcoincashjs-lib": "4.0.2", + "@psf/coininfo": "4.0.0", + "axios": "0.26.1", + "bc-bip68": "1.0.5", + "bchaddrjs-slp": "0.2.5", + "bigi": "1.4.2", + "bignumber.js": "9.0.0", + "bip-schnorr": "0.3.0", + "bip38": "2.0.2", + "bip39": "3.0.2", + "bip66": "1.1.5", + "bitcoinjs-message": "2.0.0", + "bs58": "4.0.1", + "ecashaddrjs": "1.0.7", + "ini": "1.3.8", + "randombytes": "2.0.6", + "safe-buffer": "5.1.2", + "satoshi-bitcoin": "1.0.4", + "slp-mdm": "0.0.6", + "slp-parser": "0.0.4", + "wif": "2.0.6" + } + }, "node_modules/minimal-slp-wallet/node_modules/apidoc": { "version": "0.51.0", "license": "MIT", @@ -10673,6 +10704,14 @@ "node": ">=14.0.0" } }, + "node_modules/minimal-slp-wallet/node_modules/axios": { + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", + "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", + "dependencies": { + "follow-redirects": "^1.14.8" + } + }, "node_modules/minimal-slp-wallet/node_modules/glob": { "version": "7.2.3", "license": "ISC", @@ -11502,6 +11541,8 @@ "node_modules/node-fetch": { "name": "@achingbrain/node-fetch", "version": "2.6.7", + "resolved": "https://registry.npmjs.org/@achingbrain/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-iTASGs+HTFK5E4ZqcMsHmeJ4zodyq8L38lZV33jwqcBJYoUt3HjN4+ot+O9/0b+ke8ddE7UgOtVuZN/OkV19/g==", "license": "MIT", "engines": { "node": "4.x || >=6.0.0" @@ -20382,7 +20423,9 @@ "version": "1.1.0" }, "@psf/bch-js": { - "version": "6.4.1", + "version": "6.4.5", + "resolved": "https://registry.npmjs.org/@psf/bch-js/-/bch-js-6.4.5.tgz", + "integrity": "sha512-sH72zbJJI5oe9EUMczFQb0jCaNQb8rc3/86E6xXKl3325HCwBqE80BX7JFvZ97Qv1gGxwp/3WROp59v6Dz2NKA==", "requires": { "@chris.troutner/bip32-utils": "1.0.5", "@psf/bip21": "2.0.1", @@ -24562,9 +24605,9 @@ } }, "ipfs-coord": { - "version": "8.0.2", - "resolved": "http://94.130.170.209:4873/ipfs-coord/-/ipfs-coord-8.0.2.tgz", - "integrity": "sha512-CdUH4GLLFArUDb8LIRAXxPlhbRQ44A5PEWB4J9zzDB3by93O7DLEgjqPqLDolalzrtiQBVzoARO/exZvdxBF+w==", + "version": "8.0.5", + "resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-8.0.5.tgz", + "integrity": "sha512-V4pqR+MU290ZxFRE+Rx/7JuxR7LsOFBLuL0av3eVU5ZQWqeF/Zi9vh52zCqpp1IBCXi4QXNZGlysvm16xFDXww==", "requires": { "axios": "0.21.4", "bch-encrypt-lib": "2.0.0", @@ -26811,6 +26854,37 @@ "crypto-js": "4.0.0" }, "dependencies": { + "@psf/bch-js": { + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/@psf/bch-js/-/bch-js-6.4.1.tgz", + "integrity": "sha512-/BLGzWH02VqaDNeY05QGMhrCtYDw5bXn45Egz+L5FLcyZaOqONR4kl80T6a8xvTPcREO4R+AjGTRBpfjdikwpA==", + "requires": { + "@chris.troutner/bip32-utils": "1.0.5", + "@psf/bip21": "2.0.1", + "@psf/bitcoincash-ops": "2.0.0", + "@psf/bitcoincashjs-lib": "4.0.2", + "@psf/coininfo": "4.0.0", + "axios": "0.26.1", + "bc-bip68": "1.0.5", + "bchaddrjs-slp": "0.2.5", + "bigi": "1.4.2", + "bignumber.js": "9.0.0", + "bip-schnorr": "0.3.0", + "bip38": "2.0.2", + "bip39": "3.0.2", + "bip66": "1.1.5", + "bitcoinjs-message": "2.0.0", + "bs58": "4.0.1", + "ecashaddrjs": "1.0.7", + "ini": "1.3.8", + "randombytes": "2.0.6", + "safe-buffer": "5.1.2", + "satoshi-bitcoin": "1.0.4", + "slp-mdm": "0.0.6", + "slp-parser": "0.0.4", + "wif": "2.0.6" + } + }, "apidoc": { "version": "0.51.0", "requires": { @@ -26838,6 +26912,14 @@ "winston": "^3.3.3" } }, + "axios": { + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", + "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", + "requires": { + "follow-redirects": "^1.14.8" + } + }, "glob": { "version": "7.2.3", "requires": { @@ -27374,7 +27456,9 @@ } }, "node-fetch": { - "version": "npm:@achingbrain/node-fetch@2.6.7" + "version": "npm:@achingbrain/node-fetch@2.6.7", + "resolved": "https://registry.npmjs.org/@achingbrain/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-iTASGs+HTFK5E4ZqcMsHmeJ4zodyq8L38lZV33jwqcBJYoUt3HjN4+ot+O9/0b+ke8ddE7UgOtVuZN/OkV19/g==" }, "node-forge": { "version": "1.3.1" diff --git a/package.json b/package.json index 386a789..5eff438 100644 --- a/package.json +++ b/package.json @@ -27,14 +27,14 @@ }, "repository": "Permissionless-Software-Foundation/bch-dex", "dependencies": { - "@psf/bch-js": "6.4.1", + "@psf/bch-js": "6.4.5", "axios": "0.27.2", "bch-message-lib": "2.2.0", "bcryptjs": "2.4.3", "bitcoincashjs-lib": "3.3.3", "glob": "7.1.6", "ipfs": "0.62.3", - "ipfs-coord": "8.0.2", + "ipfs-coord": "8.0.5", "ipfs-http-client": "55.0.0", "jsonrpc-lite": "2.2.0", "jsonwebtoken": "8.5.1", diff --git a/production/docker/docker-compose.yml b/production/docker/docker-compose.yml index 5e69e79..35614f9 100644 --- a/production/docker/docker-compose.yml +++ b/production/docker/docker-compose.yml @@ -4,7 +4,7 @@ version: '3.9' services: mongo-p2wdb-service: - image: mongo:4.4.2-bionic + image: mongo:4.2.0 container_name: mongo-p2wdb-service ports: - '5666:27017' # : @@ -14,10 +14,16 @@ services: restart: always ipfs: - image: ipfs/go-ipfs:v0.13.0 + # https://github.com/christroutner/trickle-ipfs + image: christroutner/trickle-ipfs:v1.0.1 + #build: + # context: ./ + # dockerfile: Dockerfile container_name: ipfs environment: - MY_ENV_VAR: 'placeholder' + IPFS_DAEMON_ARGUMENTS: '--enable-pubsub-experiment --migrate=true --agent-version-suffix=docker --routing=dhtclient' + UPLOAD_KBPS: '1000' + DOWNLOAD_KBPS: '1000' logging: driver: 'json-file' options: @@ -26,27 +32,21 @@ services: mem_limit: 2000mb ports: - 4001:4001 + - 4003:4003 - 172.17.0.1:5001:5001 - 172.17.0.1:8080:8080 + command: [ + './start-ipfs.sh' + ] volumes: - - ../data/go-ipfs/data:/data/ipfs - #- ../../swarm.key:/data/ipfs/swarm.key - # https://docs.docker.com/compose/compose-file/compose-file-v3/#command - # https://github.com/ipfs/go-ipfs/blob/91c52657166bcf86f2476926e4fe56694dc26562/Dockerfile#L115 - command: - [ - 'daemon', - '--migrate=true', - '--agent-version-suffix=docker', - '--enable-pubsub-experiment' - ] + - ../data/go-ipfs/data:/root/.ipfs restart: always p2wdb: #build: # context: ./p2wdb/ # dockerfile: Dockerfile - image: christroutner/p2wdb:v3.0.6 + image: christroutner/p2wdb:v3.0.9 container_name: p2wdb environment: CONSUMER_URL: 'https://free-bch.fullstack.cash' diff --git a/production/rpi-docker/p2wdb/start-production.sh b/production/rpi-docker/p2wdb/start-production.sh index 27a70b2..c12243b 100755 --- a/production/rpi-docker/p2wdb/start-production.sh +++ b/production/rpi-docker/p2wdb/start-production.sh @@ -40,6 +40,7 @@ export P2W_ENV=production export IPFS_HOST=172.17.0.1 export IPFS_API_PORT=5001 export IPFS_TCP_PORT=4001 +export IPFS_WS_PORT=4003 # P2WDB specific env vars export ORBITDB_NAME=/orbitdb/zdpuAqNiwLiJBfbRK7uihV2hAbNSXj78ufzv5VyQb8GuvRwDh/psf-bch-p2wdb-keyvalue-v3.0.0-0001 diff --git a/src/adapters/ipfs/index.js b/src/adapters/ipfs/index.js index 13050d1..f150c3f 100644 --- a/src/adapters/ipfs/index.js +++ b/src/adapters/ipfs/index.js @@ -5,6 +5,7 @@ // Local libraries const IpfsAdapter = require('./ipfs') const IpfsCoordAdapter = require('./ipfs-coord') +const config = require('../../../config') class IPFS { constructor (localConfig = {}) { @@ -12,6 +13,7 @@ class IPFS { this.ipfsAdapter = new IpfsAdapter() this.IpfsCoordAdapter = IpfsCoordAdapter this.process = process + this.config = config this.ipfsCoordAdapter = {} // placeholder @@ -32,7 +34,9 @@ class IPFS { // Start ipfs-coord this.ipfsCoordAdapter = new this.IpfsCoordAdapter({ - ipfs: this.ipfs + ipfs: this.ipfs, + tcpPort: this.config.ipfsTcpPort, + wsPort: this.config.ipfsWsPort }) await this.ipfsCoordAdapter.start() console.log('ipfs-coord is ready.') diff --git a/test/unit/mocks/adapters/index.js b/test/unit/mocks/adapters/index.js index 2ea38f4..cc576f0 100644 --- a/test/unit/mocks/adapters/index.js +++ b/test/unit/mocks/adapters/index.js @@ -1,16 +1,22 @@ /* Mocks for the Adapter library. */ - const BCHJS = require('@psf/bch-js') const bchjs = new BCHJS() -const ipfs = { - ipfsAdapter: { - ipfs: {} - }, - ipfsCoordAdapter: { - ipfsCoord: { +class IpfsAdapter { + constructor () { + this.ipfs = { + files: { + stat: () => {} + } + } + } +} + +class IpfsCoordAdapter { + constructor () { + this.ipfsCoord = { useCases: { peer: { sendPrivateMessage: () => { @@ -21,6 +27,12 @@ const ipfs = { } } +const ipfs = { + ipfsAdapter: new IpfsAdapter(), + ipfsCoordAdapter: new IpfsCoordAdapter() +} +ipfs.ipfs = ipfs.ipfsAdapter.ipfs + const localdb = { Users: class Users { static findById () {}