mirror of
https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-service.git
synced 2026-09-22 01:02:03 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c347a2d99a | ||
|
|
5b7d8d4db4 | ||
|
|
dd0692e91f | ||
|
|
576da66194 | ||
|
|
f4851d6771 | ||
|
|
96abb0d56e | ||
|
|
fdf3141c91 | ||
|
|
6692d234da | ||
|
|
b8655e31ca | ||
|
|
e118fe4d6e | ||
|
|
86283195c5 | ||
|
|
a037646aca | ||
|
|
ae6bdcdd5f | ||
|
|
9fe822024c | ||
|
|
fc94041d17 | ||
|
|
a3f780b1f5 |
@@ -29,14 +29,34 @@ This repository is one step in a longer path. Here are the major milestones of t
|
||||
|
||||
## Installation
|
||||
|
||||
### Development Environment
|
||||
|
||||
A development environment will allow you modify the code on-the-fly and contribute to the code base of this repository. [PM2](https://www.npmjs.com/package/pm2) is recommended for running this code base as an IPFS Circuit Relay.
|
||||
|
||||
- [Video: Installing ipfs-service-provider](https://youtu.be/Z0NsboIVN44)
|
||||
- [Step-by-step installation instructions](https://gist.github.com/christroutner/3304a71d4c12a3a3e1664a438f64d9d0)
|
||||
|
||||
```bash
|
||||
git clone https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-service
|
||||
cd ipfs-bch-wallet-service
|
||||
sudo npm install -g node-pre-gyp
|
||||
./install-mongo-sh
|
||||
npm install
|
||||
npm start
|
||||
./ipfs-bch-wallet-service.sh
|
||||
```
|
||||
|
||||
### Production Environment
|
||||
|
||||
The [docker](./production/docker) directory contains a Dockerfile for building a production deployment. However, there is currently [a bug](https://github.com/Permissionless-Software-Foundation/ipfs-service-provider/issues/38) preventing the Docker container from being used as a Circuit Relay.
|
||||
|
||||
```
|
||||
docker-compose build --no-cache
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### Operation Notes
|
||||
|
||||
- There is a memory leak in the version of js-ipfs. The app is currently configured to shut down every 8 hours to flush memory. It relies on a process manager like pm2, Docker, or systemd to restart the app after it shuts down, in order to ensure continuous operation.
|
||||
|
||||
## Structure
|
||||
|
||||
The file layout of this repository differs from the koa-api-boilerplate. Instead, it follows the file layout of [Clean Architecture](troutsblog.com/blog/clean-architecture).
|
||||
|
||||
+2
-2
@@ -100,12 +100,12 @@ class Server {
|
||||
// Attach the other IPFS controllers
|
||||
await controllers.attachControllers(app)
|
||||
|
||||
// ipfs-coord has a memory leak. This app shuts down after 8 hours. It
|
||||
// ipfs-coord has a memory leak. This app shuts down after 4 hours. It
|
||||
// expects to be run by Docker or pm2, which can automatically restart
|
||||
// the app.
|
||||
setTimeout(function () {
|
||||
process.exit(0)
|
||||
}, 60000 * 60 * 8)
|
||||
}, 60000 * 60 * 4)
|
||||
|
||||
return app
|
||||
} catch (err) {
|
||||
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Ports
|
||||
export PORT=5001 # REST API port
|
||||
export IPFS_TCP_PORT=5268
|
||||
export IPFS_WS_PORT=5269
|
||||
|
||||
#export ENABLE_CIRCUIT_RELAY=1
|
||||
|
||||
# Production database connection string.
|
||||
#export DBURL=mongodb://localhost:27017/bch-service-dev
|
||||
|
||||
export COORD_NAME=ipfs-service-provider-generic
|
||||
export MNEMONIC="churn aisle shield silver ladder swear hunt slim pen demand spoil veteran"
|
||||
|
||||
export DEBUG_LEVEL=1
|
||||
|
||||
npm start
|
||||
Generated
+7
-7
@@ -14,7 +14,7 @@
|
||||
"axios": "^0.21.1",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"glob": "^7.1.6",
|
||||
"ipfs-coord": "^6.6.4",
|
||||
"ipfs-coord": "^6.6.6",
|
||||
"jsonrpc-lite": "^2.2.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"jwt-bch-lib": "^1.3.0",
|
||||
@@ -9472,9 +9472,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/ipfs-coord": {
|
||||
"version": "6.6.4",
|
||||
"resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-6.6.4.tgz",
|
||||
"integrity": "sha512-0rrfunCMvC9Oiw+MCCUZ5/J2VSY1Z3Wdq6qph2VN+ibdhxeRFtDcfZbVT7VrlWnGo/Q4lbGE+nDAPRro/pgitg==",
|
||||
"version": "6.6.6",
|
||||
"resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-6.6.6.tgz",
|
||||
"integrity": "sha512-vWMrh9kjbNimXuM2fjW7weKXqm4JqvIAoLmfmfuHfRMaJkXiK1RQeTERdE7FmYYunMKVkOz045pMEAFwnNh+vA==",
|
||||
"dependencies": {
|
||||
"bch-encrypt-lib": "^2.0.0",
|
||||
"orbit-db": "^0.26.1"
|
||||
@@ -31269,9 +31269,9 @@
|
||||
}
|
||||
},
|
||||
"ipfs-coord": {
|
||||
"version": "6.6.4",
|
||||
"resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-6.6.4.tgz",
|
||||
"integrity": "sha512-0rrfunCMvC9Oiw+MCCUZ5/J2VSY1Z3Wdq6qph2VN+ibdhxeRFtDcfZbVT7VrlWnGo/Q4lbGE+nDAPRro/pgitg==",
|
||||
"version": "6.6.6",
|
||||
"resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-6.6.6.tgz",
|
||||
"integrity": "sha512-vWMrh9kjbNimXuM2fjW7weKXqm4JqvIAoLmfmfuHfRMaJkXiK1RQeTERdE7FmYYunMKVkOz045pMEAFwnNh+vA==",
|
||||
"requires": {
|
||||
"bch-encrypt-lib": "^2.0.0",
|
||||
"orbit-db": "^0.26.1"
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
"bcryptjs": "^2.4.3",
|
||||
"glob": "^7.1.6",
|
||||
"@chris.troutner/ipfs": "2.0.2",
|
||||
"ipfs-coord": "^6.6.4",
|
||||
"ipfs-coord": "^6.6.6",
|
||||
"jsonrpc-lite": "^2.2.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"jwt-bch-lib": "^1.3.0",
|
||||
|
||||
@@ -2,32 +2,44 @@
|
||||
#
|
||||
|
||||
#IMAGE BUILD COMMANDS
|
||||
# ct-base-ubuntu = ubuntu 18.04 + nodejs v10 LTS
|
||||
FROM christroutner/ct-base-ubuntu:latest
|
||||
FROM ubuntu:20.04
|
||||
MAINTAINER Chris Troutner <chris.troutner@gmail.com>
|
||||
|
||||
#Update the OS and install any OS packages needed.
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y sudo git curl nano gnupg wget
|
||||
|
||||
#Install Node and NPM
|
||||
RUN curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh
|
||||
RUN bash nodesource_setup.sh
|
||||
RUN apt-get install -y nodejs build-essential
|
||||
|
||||
#Create the user 'safeuser' and add them to the sudo group.
|
||||
#RUN useradd -ms /bin/bash safeuser
|
||||
#RUN adduser safeuser sudo
|
||||
RUN useradd -ms /bin/bash safeuser
|
||||
RUN adduser safeuser sudo
|
||||
|
||||
#Set password to 'password' change value below if you want a different password
|
||||
#RUN echo safeuser:password | chpasswd
|
||||
RUN echo safeuser:password | chpasswd
|
||||
|
||||
#Set the working directory to be the home directory
|
||||
WORKDIR /home/safeuser
|
||||
|
||||
#Setup NPM for non-root global install
|
||||
#RUN mkdir /home/safeuser/.npm-global
|
||||
#RUN chown -R safeuser .npm-global
|
||||
#RUN echo "export PATH=~/.npm-global/bin:$PATH" >> /home/safeuser/.profile
|
||||
#RUN runuser -l safeuser -c "npm config set prefix '~/.npm-global'"
|
||||
RUN mkdir /home/safeuser/.npm-global
|
||||
RUN chown -R safeuser .npm-global
|
||||
RUN echo "export PATH=~/.npm-global/bin:$PATH" >> /home/safeuser/.profile
|
||||
RUN runuser -l safeuser -c "npm config set prefix '~/.npm-global'"
|
||||
|
||||
# Update to the latest version of npm.
|
||||
# Working with npm@7.21.1
|
||||
RUN npm install -g npm
|
||||
|
||||
# Switch to user account.
|
||||
#USER safeuser
|
||||
# Prep 'sudo' commands.
|
||||
#RUN echo 'abcd8765' | sudo -S pwd
|
||||
|
||||
# Clone the rest.bitcoin.com repository
|
||||
# Clone the repository
|
||||
WORKDIR /home/safeuser
|
||||
RUN git clone https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-service
|
||||
|
||||
|
||||
+28
-26
@@ -5,53 +5,55 @@
|
||||
*/
|
||||
|
||||
// Public NPM libraries
|
||||
const BCHJS = require('@psf/bch-js')
|
||||
const BCHJS = require("@psf/bch-js");
|
||||
|
||||
// Load individual adapter libraries.
|
||||
const IPFSAdapter = require('./ipfs')
|
||||
const LocalDB = require('./localdb')
|
||||
const LogsAPI = require('./logapi')
|
||||
const Passport = require('./passport')
|
||||
const Nodemailer = require('./nodemailer')
|
||||
const IPFSAdapter = require("./ipfs");
|
||||
const LocalDB = require("./localdb");
|
||||
const LogsAPI = require("./logapi");
|
||||
const Passport = require("./passport");
|
||||
const Nodemailer = require("./nodemailer");
|
||||
// const { wlogger } = require('./wlogger')
|
||||
const JSONFiles = require('./json-files')
|
||||
const FullStackJWT = require('./fullstack-jwt')
|
||||
const JSONFiles = require("./json-files");
|
||||
const FullStackJWT = require("./fullstack-jwt");
|
||||
|
||||
const config = require('../../config')
|
||||
const config = require("../../config");
|
||||
|
||||
class Adapters {
|
||||
constructor (localConfig = {}) {
|
||||
constructor(localConfig = {}) {
|
||||
// Encapsulate dependencies
|
||||
this.ipfs = new IPFSAdapter()
|
||||
this.localdb = new LocalDB()
|
||||
this.logapi = new LogsAPI()
|
||||
this.passport = new Passport()
|
||||
this.nodemailer = new Nodemailer()
|
||||
this.jsonFiles = new JSONFiles()
|
||||
this.bchjs = new BCHJS()
|
||||
this.config = config
|
||||
this.ipfs = new IPFSAdapter();
|
||||
this.localdb = new LocalDB();
|
||||
this.logapi = new LogsAPI();
|
||||
this.passport = new Passport();
|
||||
this.nodemailer = new Nodemailer();
|
||||
this.jsonFiles = new JSONFiles();
|
||||
this.bchjs = new BCHJS();
|
||||
this.config = config;
|
||||
|
||||
// Get a valid JWT API key and instance bch-js.
|
||||
this.fullStackJwt = new FullStackJWT(config)
|
||||
this.fullStackJwt = new FullStackJWT(config);
|
||||
}
|
||||
|
||||
async start () {
|
||||
async start() {
|
||||
try {
|
||||
if (this.config.getJwtAtStartup) {
|
||||
// Get a JWT token and instantiate bch-js with it. Then pass that instance
|
||||
// to all the rest of the apps controllers and adapters.
|
||||
await this.fullStackJwt.getJWT()
|
||||
await this.fullStackJwt.getJWT();
|
||||
// Instantiate bch-js with the JWT token, and overwrite the placeholder for bch-js.
|
||||
this.bchjs = await this.fullStackJwt.instanceBchjs()
|
||||
this.bchjs = await this.fullStackJwt.instanceBchjs();
|
||||
} else {
|
||||
this.bchjs = new BCHJS({ restURL: this.config.apiServer });
|
||||
}
|
||||
|
||||
// Start the IPFS node.
|
||||
await this.ipfs.start({ bchjs: this.bchjs })
|
||||
await this.ipfs.start({ bchjs: this.bchjs });
|
||||
} catch (err) {
|
||||
console.error('Error in adapters/index.js/start()')
|
||||
throw err
|
||||
console.error("Error in adapters/index.js/start()");
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Adapters
|
||||
module.exports = Adapters;
|
||||
|
||||
Reference in New Issue
Block a user