Skip to content

Commit

Permalink
Version 1.0.2 candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
onsightit committed Jan 16, 2017
1 parent 1125dd9 commit 0b1e579
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 46 deletions.
7 changes: 2 additions & 5 deletions Docker/coin.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
rpcuser=rpcuser
rpcpassword=password
rpcconnect=node.yourcoin.com # RPC node does not run in this docker
rpcport=18184
rpcport=18181

rpcallowip=127.0.0.1
port=18186
gen=0
server=1
staking=1

addnode=node.yourcoin.com
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Mongo DB for storing account info. See: https://www.mongodb.com/

Create DB and user:
> use solarcoin
> db.createUser( { user: "solarcoin", pwd: "{password}", roles: [ "readWrite" ] } )
> db.createUser( { user: "solarcoin", pwd: "{password}", roles: [ { role: "readWrite" } ] } )
Node.js 6.x for running the Web Wallet. For debian installations:

Expand Down Expand Up @@ -54,7 +54,8 @@ Either way, the config file will need at a minimum the following parameters:
> rpcuser=rpcuser
> rpcpassword=password # Change me!
> rpcconnect=localhost # RPC daemon
> rpcport=18184
> rpcport=18181
> server=1 # If not running a daemon
Local vs Not-Local configuration:

Expand Down
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ function startApp(app) {
// });
process.on('uncaughtException', function (err) {
// socket.emit('news', { news: 'Wallet connection error.' });
console.log('Caught exception: ' + err);
console.log('Caught exception: ' + JSON.stringify(err));
tryReconnect();
});
//});
Expand Down
8 changes: 2 additions & 6 deletions lib/coin.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
rpcuser=rpcuser
rpcpassword=password
rpcconnect=localhost # RPC Node
rpcport=18184
rpcport=18181

rpcallowip=127.0.0.1
rpcport=18184
port=18186
gen=0
server=1
staking=1

addnode=node.yourcoin.com
12 changes: 9 additions & 3 deletions lib/coinapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (process.platform == 'darwin'){
}

if (fs.existsSync(filepath) === false){
console.log("Config file does not exists. Using the node's config file...");
console.log("WARNING: Config file does not exists. Using the node's config file...");
filepath = 'lib/coin.conf';
}

Expand Down Expand Up @@ -68,8 +68,14 @@ for (var k in arrayFromConf){
}
}
// Validation checks
if (rpcHost === "") rpcHost = "127.0.0.1";
if (rpcPort === "") rpcPort = "18184";
if (rpcHost === "")
console.log("WARNING: " + filepath + " does not contain rpcconnect setting!");
if (rpcPort === "")
console.log("WARNING: " + filepath + " does not contain rpcport setting!");
if (rpcUser === "")
console.log("WARNING: " + filepath + " does not contain rpcuser setting!");
if (rpcPass === "")
console.log("WARNING: " + filepath + " does not contain rpcpassword setting!");

var isLocal = false;
if (rpcHost === "localhost" || rpcHost === "127.0.0.1" || rpcHost.indexOf("192.168.") === 0 || rpcHost.indexOf(".") === -1){
Expand Down
52 changes: 28 additions & 24 deletions lib/init-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,39 @@ var doneFindUserWallet = 30;

function GetAccountAddresses(account) {
coin.api.exec('getaddressesbyaccount', account, function(err, res){
accountAddresses = res;
// If a new wallet needs to be created for MASTER_ACCOUNT,
// but no empty labeled addresses exist, create one.
if ((!accountAddresses || !accountAddresses.length) && !foundUserWallet && account === ""){
coin.api.exec('getnewaddress', account, function(err, res){
masterAddress = res;
accountAddresses = [masterAddress];
if (typeof res !== 'undefined'){
accountAddresses = res;
// If a new wallet needs to be created for MASTER_ACCOUNT,
// but no empty labeled addresses exist, create one.
if ((!accountAddresses || !accountAddresses.length) && !foundUserWallet && account === ""){
coin.api.exec('getnewaddress', account, function(err, res){
masterAddress = res;
accountAddresses = [masterAddress];
doneGetAccountAddresses = 0;
});
} else {
doneGetAccountAddresses = 0;
});
} else {
doneGetAccountAddresses = 0;
}
}
});
}

function SetAccountAddresses(account, addresses) {
// Foreach address: setaccount <address> <acccount>
for (var k in addresses){
if (addresses.hasOwnProperty(k) && addresses[k].substring(0,1) === coin.settings.coinChar){
coin.api.exec('setaccount', addresses[k], account, function(err, res){
if (err) console.log("Error: err:" + err + " res:" + res);
if (doneSetAccountAddresses){
// Make sure we have a master address.
if (masterAddress === ""){
masterAddress = addresses[0]; // Use first address
if (addresses && addresses.length){
for (var k in addresses){
if (addresses.hasOwnProperty(k) && addresses[k].substring(0,1) === coin.settings.coinChar){
coin.api.exec('setaccount', addresses[k], account, function(err, res){
if (err) console.log("Error: err:" + err + " res:" + res);
if (doneSetAccountAddresses){
// Make sure we have a master address.
if (masterAddress === ""){
masterAddress = addresses[0]; // Use first address
}
doneSetAccountAddresses = 0;
}
doneSetAccountAddresses = 0;
}
});
});
}
}
}
}
Expand Down Expand Up @@ -116,7 +120,7 @@ function Init() {
},1000); // end timeout
} else {
// Node is down and DB is up.
console.log("Init-Wallet Error: Is the wallet daemon down?");
console.log("Init-Wallet Error: Is the RPC wallet daemon running?");
user = null;
process.abort();
}
Expand All @@ -138,14 +142,14 @@ function Init() {
interval2 = setInterval(function(){
if (!doneSetAccountAddresses){
clearInterval(interval2);

// Just waiting till complete...
} else { doneSetAccountAddresses--; }
},1000); // end timeout

} else {
// Node is down and DB is up.
console.log("Init-Wallet Error: Is the wallet daemon down?");
console.log("Init-Wallet Error: Is the RPC wallet daemon running?");
user = null;
process.abort();
}
Expand Down
4 changes: 3 additions & 1 deletion lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ var fs = require("fs");
var moment = require("moment");
var jsonminify = require("jsonminify");

// NOTE: rpcuser/pass/host/port is pulled from the coin's config file.

// Version
exports.version = "1.0.2";

Expand Down Expand Up @@ -82,7 +84,7 @@ exports.sslPort = process.env.SSLPORT || 8383;
exports.sslKey = "./sslcert/server.key";
exports.sslCrt = "./sslcert/server.crt";

// This setting is passed to MongoDB to set up the database
// This setting is passed to MongoDB. See README.md for setting up the database.
exports.mdb = {
"user": "solarcoin",
"password": "password",
Expand Down
11 changes: 10 additions & 1 deletion node_modules/coin-node/lib/coin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions settings.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Do not modify settings.json.template!
//
{
// NOTE: rpcuser/pass/host/port is pulled from the coin's config file.

// Version
"version": "1.0.2",

Expand Down Expand Up @@ -82,11 +84,11 @@
// SSL certs crt
"sslCrt": "./sslcert/server.crt",

// Database settings (MongoDB)
// This setting is passed to MongoDB. See README.md for setting up the database.
"mdb": {
"user": "SolarCoin",
"user": "solarcoin",
"password": "password",
"database": "SolarCoin",
"database": "solarcoin",
"host": "localhost",
"port": 27017
},
Expand Down

0 comments on commit 0b1e579

Please sign in to comment.