/mftm-backend

Messages from the Mines backend code

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

This repo contains Node.js server-side code for Messages from the Mines. It does the following:

Installing Dependencies

# install the ZeroMQ development files
sudo apt-get update
sudo apt-get install libzmq3-dev

# install the npm modules
npm install

Generate SSL key pair

For security reasons, we haven't included keys in the ssl/ folder. Create some once you've cloned:

openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout ssl/private.key -out ssl/certificate.crt

Edit credentials in config.json and bitcoin.conf

config.json comes with dummy values for: - Basic authentication user/pass - MySQL user/pass - bitcoind JSONRPC user/pass

Edit basicAuth.users, mysql.user, mysql.password, bitcoinRPCClient.user, and bitcoinRPCClient.pass.

{
	"port": 8989,
	"peerInfoRefreshInterval": 10000,
	"bitcoinZMQAddress": "tcp://127.0.0.1:28332",
	"basicAuth": {
		"users": {
			"admin": "change-me-or-get-pwned"
		},
		"challenge": true
	},
	"ssl": {
		"key": "ssl/private.key",
		"cert": "ssl/certificate.crt"
	},
	"mysql": {
		"connectionLimit": 100,
		"host": "localhost",
		"user": "root",
		"password": "change-me-or-get-pwned",
		"database": "messages_from_the_mines"
	},
	"bitcoinRPCClient": {
		"host": "localhost",
	  	"port": 8332,
	  	"user": "admin",
	  	"pass": "change-me-or-get-pwned",
	  	"timeout": 30000
	}
}

bitcoin.conf contains dummy values for rpcuser and rpcpassword as well. Change those too.

rpcuser=admin
rpcpassword=change-me-or-get-pwned

Start the bitcoind Daemon

Bitcoin Core must be running for server.js to work properly. Before running, change -datadir to point to your Bitcoin Core data folder (usually ~/.bitcoin) in start_bitcoind.sh.

# change -datadir directory and save the file
nano start_bitcoind.sh

# start the bitcoind server
./start_bitcoin.sh

Launch the Server

Once bitcoind is running, launch the node server:

node server