diff --git a/binary_artifacts.sh b/binary_artifacts.sh index 0bfdb6c..569b657 100755 --- a/binary_artifacts.sh +++ b/binary_artifacts.sh @@ -1,11 +1,58 @@ echo Refreshing binaries from artifacts.supernet.org echo ========================================= echo Step: Removing old binaries +mkdir -p build cd build rm -rvf artifacts.supernet.org echo echo Step: Cloning latest binaries for build wget --recursive --no-parent https://artifacts.supernet.org/latest/ +chmod -R +x artifacts.supernet.org/latest/ cd .. echo ========================================= -echo +echo +echo ========================================= +echo Step: Moving osx binaries from artifacts to assets/bin/osx/ +echo +mv -fv build/artifacts.supernet.org/latest/osx/iguana assets/bin/osx/ +mv -fv build/artifacts.supernet.org/latest/osx/komodo-cli assets/bin/osx/ +mv -fv build/artifacts.supernet.org/latest/osx/komodod assets/bin/osx/ +mv -fv build/artifacts.supernet.org/latest/osx/libgcc_s.1.dylib assets/bin/osx/ +mv -fv build/artifacts.supernet.org/latest/osx/libgomp.1.dylib assets/bin/osx/ +mv -fv build/artifacts.supernet.org/latest/osx/libnanomsg.5.0.0.dylib assets/bin/osx/ +mv -fv build/artifacts.supernet.org/latest/osx/libstdc++.6.dylib assets/bin/osx/ +echo +echo ========================================= +echo Step: Moving Win64 binaries from artifacts to assets/bin/win64/ +echo +mv -fv build/artifacts.supernet.org/latest/windows/genkmdconf.bat assets/bin/win64/ +mv -fv build/artifacts.supernet.org/latest/windows/iguana.exe assets/bin/win64/ +mv -fv build/artifacts.supernet.org/latest/windows/index.html assets/bin/win64/ +mv -fv build/artifacts.supernet.org/latest/windows/komodo-cli.exe assets/bin/win64/ +mv -fv build/artifacts.supernet.org/latest/windows/komodo-tx.exe assets/bin/win64/ +mv -fv build/artifacts.supernet.org/latest/windows/komodod.exe assets/bin/win64/ +mv -fv build/artifacts.supernet.org/latest/windows/libcrypto-1_1.dll assets/bin/win64/ +mv -fv build/artifacts.supernet.org/latest/windows/libcurl-4.dll assets/bin/win64/ +mv -fv build/artifacts.supernet.org/latest/windows/libcurl.dll assets/bin/win64/ +mv -fv build/artifacts.supernet.org/latest/windows/libgcc_s_sjlj-1.dll assets/bin/win64/ +mv -fv build/artifacts.supernet.org/latest/windows/libnanomsg.dll assets/bin/win64/ +mv -fv build/artifacts.supernet.org/latest/windows/libssl-1_1.dll assets/bin/win64/ +mv -fv build/artifacts.supernet.org/latest/windows/libwinpthread-1.dll assets/bin/win64/ +mv -fv build/artifacts.supernet.org/latest/windows/nanomsg.dll assets/bin/win64/ +mv -fv build/artifacts.supernet.org/latest/windows/pthreadvc2.dll assets/bin/win64/ +echo +echo ========================================= +echo Step: Moving linux64 binaries from artifacts to assets/bin/linux64 +echo +mv -fv build/artifacts.supernet.org/latest/linux/iguana assets/bin/linux64/ +mv -fv build/artifacts.supernet.org/latest/linux/komodo-cli assets/bin/linux64/ +mv -fv build/artifacts.supernet.org/latest/linux/komodod assets/bin/linux64/ +echo +echo ========================================= +echo Step: Cleaning artifacts data +echo +rm -rf build/ +echo +echo ========================================= +echo Step: Finished Updating binaries from artifacts +echo \ No newline at end of file diff --git a/main.js b/main.js index 64f46c2..d986083 100644 --- a/main.js +++ b/main.js @@ -42,11 +42,11 @@ if (os.platform() === 'linux') { // GUI APP settings and starting gui on address http://120.0.0.1:17777 var shepherd = require('./routes/shepherd'), - guiapp = express(); + guiapp = express(); shepherd.createIguanaDirs(); -const appSessionHash = md5(new Date(Date.now()).toLocaleString); +const appSessionHash = md5(Date.now()); shepherd.writeLog('app init ' + appSessionHash); shepherd.writeLog('app info: ' + appBasicInfo.name + ' ' + appBasicInfo.version); @@ -105,7 +105,7 @@ guiapp.use(function(req, res, next) { res.header('Access-Control-Allow-Headers', 'X-Requested-With'); res.header('Access-Control-Allow-Credentials', 'true'); res.header('Access-Control-Allow-Headers', 'Content-Type'); - res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS'); // TODO: limit allowed methods + res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS'); next(); }); @@ -176,34 +176,6 @@ shepherd.setVar('appBasicInfo', appBasicInfo); shepherd.setVar('appSessionHash', appSessionHash); module.exports = guiapp; -// END GUI App Settings - -//require('./assets/js/iguana.js'); //below code shall be separated into asset js for public version -/* -// SELECTING IGUANA BUILD TO RUN AS PER OS DETECTED BY DESKTOP APP -var iguanaOSX = path.join(__dirname, '/assets/bin/osx/iguana'); -var iguanaLinux = path.join(__dirname, '/assets/bin/linux64/iguana'); -var iguanaWin = path.join(__dirname, '/assets/bin/win64/iguana.exe'); iguanaWin = path.normalize(iguanaWin); -var iguanaConfsDirSrc = path.join(__dirname, '/assets/deps/confs'); - -// SETTING OS DIR TO RUN IGUANA FROM -// SETTING APP ICON FOR LINUX AND WINDOWS -if (os.platform() === 'darwin') { - var iguanaDir = process.env.HOME + '/Library/Application Support/iguana'; - var iguanaConfsDir = iguanaDir + '/confs'; -} -if (os.platform() === 'linux') { - var iguanaDir = process.env.HOME + '/.iguana' - var iguanaConfsDir = iguanaDir + '/confs'; - var iguanaIcon = path.join(__dirname, '/assets/icons/iguana_app_icon_png/128x128.png') -} -if (os.platform() === 'win32') { - var iguanaDir = process.env.APPDATA + '/iguana'; iguanaDir = path.normalize(iguanaDir) - var iguanaConfsDir = process.env.APPDATA + '/iguana/confs'; iguanaConfsDir = path.normalize(iguanaConfsDir) - var iguanaIcon = path.join(__dirname, '/assets/icons/iguana_app_icon.ico') - iguanaConfsDirSrc = path.normalize(iguanaConfsDirSrc); -} -*/ if (os.platform() === 'linux') { var iguanaIcon = path.join(__dirname, '/assets/icons/agama_icons/128x128.png'); @@ -212,26 +184,6 @@ if (os.platform() === 'win32') { var iguanaIcon = path.join(__dirname, '/assets/icons/agama_icons/agama_app_icon.ico'); } -//console.log(iguanaDir); -/* -// MAKE SURE IGUANA DIR IS THERE FOR USER -mkdirp(iguanaDir, function (err) { - if (err) - console.error(err) - else - fs.readdir(iguanaDir, (err, files) => { - files.forEach(file => { - //console.log(file); - }); - }) -}); - -// COPY CONFS DIR WITH PEERS FILE TO IGUANA DIR, AND KEEP IT IN SYNC -fs.copy(iguanaConfsDirSrc, iguanaConfsDir, function (err) { - if (err) return console.error(err) - console.log('confs files copied successfully at: '+ iguanaConfsDir ) -}) -*/ let mainWindow; let loadingWindow; @@ -256,7 +208,7 @@ function createLoadingWindow() { shepherd.writeLog('show loading window'); // DEVTOOLS - only for dev purposes - ca333 - //loadingWindow.webContents.openDevTools() + // loadingWindow.webContents.openDevTools() // if window closed we kill iguana proc loadingWindow.on('hide', function () { @@ -304,25 +256,6 @@ function createLoadingWindow() { }); } }); - - //ca333 todo - add os detector to use correct binary - so we can use the same bundle on ALL OS platforms - /*if (os.platform() === 'win32') { - process.chdir(iguanaDir); - //exec(iguanaWin, {cwd: iguanaDir}); //specify binary in startup - ig = spawn(iguanaWin); - } - if (os.platform() === 'linux') { - process.chdir(iguanaDir); - ig = spawn(iguanaLinux); - //corsproxy_process = spawn('corsproxy'); - } - if (os.platform() === 'darwin') { - //process.chdir(iguanaDir); - //ig = spawn(iguanaOSX); - //corsproxy_process = spawn('corsproxy'); - }*/ - - //if (os.platform() !== 'win32') { ig.stderr.on( 'error: ', data => { console.log( `stderr: ${data}` ); }); } } app.on('ready', createLoadingWindow); @@ -365,7 +298,7 @@ function createWindow (status) { if (appConfig.edexGuiOnly) { if (appConfig.v2) { shepherd.writeLog('show edex gui'); - // mainWindow.loadURL('http://127.0.0.1:3000'); + //mainWindow.loadURL('http://127.0.0.1:3000'); mainWindow.appConfig = appConfig; mainWindow.appSessionHash = appSessionHash; mainWindow.loadURL('http://' + appConfig.host + ':' + appConfig.agamaPort + '/gui/EasyDEX-GUI/react/build'); @@ -388,7 +321,7 @@ function createWindow (status) { }); // DEVTOOLS - only for dev purposes - ca333 - //mainWindow.webContents.openDevTools() + // mainWindow.webContents.openDevTools() function pm2Exit() { var ConnectToPm2 = function() { diff --git a/private/kmdcli.js b/private/kmdcli.js index ffc9572..e8dcffe 100644 --- a/private/kmdcli.js +++ b/private/kmdcli.js @@ -31,16 +31,16 @@ var child_process = require('child_process'), os = require('os'); if (os.platform() === 'darwin') { - var komodocliBin = path.join(__dirname, '../assets/bin/osx/komodo-cli'), + var komodocliBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/osx/komodo-cli'), zcashcliBin = '/Applications/ZCashSwingWalletUI.app/Contents/MacOS/zcash-cli'; } if (os.platform() === 'linux') { - var komodocliBin = path.join(__dirname, '../assets/bin/linux64/komodo-cli'); + var komodocliBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/linux/komodo-cli'); } if (os.platform() === 'win32') { - var komodocliBin = path.join(__dirname, '../assets/bin/win64/komodo-cli.exe'), + var komodocliBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/windows/komodo-cli.exe'), komodocliBin = path.normalize(komodocliBin); } diff --git a/routes/cache.js b/routes/cache.js index bcc37cb..2a83617 100644 --- a/routes/cache.js +++ b/routes/cache.js @@ -252,13 +252,6 @@ checkCallStack = function() { if (total / Object.keys(callStack).length === 1) { cache.dumpCacheBeforeExit(); - /*fs.writeFile(cache.iguanaDir + '/shepherd/cache-' + pubkey + '.json', JSON.stringify(inMemCache), function(err) { - if (err) { - return console.log(err); - } - - console.log('file ' + cache.iguanaDir + '/shepherd/cache-' + pubkey + '.json is updated'); - });*/ cacheCallInProgress = false; cache.io.emit('messages', { 'message': { @@ -269,8 +262,6 @@ checkCallStack = function() { } } }); - // add timestamp to cache file - // writeCache(Date.now()); } }; @@ -279,7 +270,8 @@ checkCallStack = function() { * params: userpass, pubkey, coin, address, skip */ cache.one = function(req, res, next) { - if (req.query.pubkey && !fs.existsSync(cache.iguanaDir + '/shepherd/cache-' + req.query.pubkey + '.json')) { + if (req.query.pubkey && + !fs.existsSync(cache.iguanaDir + '/shepherd/cache-' + req.query.pubkey + '.json')) { cacheCallInProgress = false; } @@ -394,7 +386,8 @@ cache.one = function(req, res, next) { outObj = fixJSON(_file); } - if (!outObj || !outObj.basilisk) { + if (!outObj || + !outObj.basilisk) { console.log('no local basilisk info'); outObj['basilisk'] = {}; outObj['basilisk'][coin] = {}; @@ -503,7 +496,9 @@ cache.one = function(req, res, next) { url: mock ? 'http://localhost:17777/shepherd/mock?url=' + dexUrl : dexUrl, method: 'GET' }, function (error, response, body) { - if (response && response.statusCode && response.statusCode === 200) { + if (response && + response.statusCode && + response.statusCode === 200) { cache.io.emit('messages', { 'message': { 'shepherd': { @@ -542,7 +537,9 @@ cache.one = function(req, res, next) { writeCache(); } - if (error || !body || !response) { + if (error || + !body || + !response) { outObj.basilisk[coin][address][key] = {}; outObj.basilisk[coin][address][key].data = { 'error': 'request failed' }; outObj.basilisk[coin][address][key].timestamp = 1471620867 // add timestamp @@ -635,12 +632,14 @@ cache.one = function(req, res, next) { if (addresses) { parseAddresses(coin, addresses); } else { - const tempUrl = 'http://' + cache.appConfig.host + ':' + cache.appConfig.iguanaCorePort /*iguanaCorePort*/ + '/api/bitcoinrpc/getaddressesbyaccount?userpass=' + sessionKey + '&coin=' + coin + '&account=*'; + const tempUrl = 'http://' + cache.appConfig.host + ':' + cache.appConfig.iguanaCorePort + '/api/bitcoinrpc/getaddressesbyaccount?userpass=' + sessionKey + '&coin=' + coin + '&account=*'; request({ url: mock ? 'http://localhost:17777/shepherd/mock?url=' + tempUrl : tempUrl, method: 'GET' }, function (error, response, body) { - if (response && response.statusCode && response.statusCode === 200) { + if (response && + response.statusCode && + response.statusCode === 200) { parseAddresses(coin, JSON.parse(body).result); } else { // TODO: error @@ -666,12 +665,14 @@ cache.one = function(req, res, next) { }); if (coin === 'all') { - const tempUrl = 'http://' + cache.appConfig.host + ':' + /*iguanaCorePort*/ cache.appConfig.iguanaCorePort + '/api/InstantDEX/allcoins?userpass=' + sessionKey; + const tempUrl = 'http://' + cache.appConfig.host + ':' + cache.appConfig.iguanaCorePort + '/api/InstantDEX/allcoins?userpass=' + sessionKey; request({ url: mock ? 'http://localhost:17777/shepherd/mock?url=' + tempUrl : tempUrl, method: 'GET' }, function (error, response, body) { - if (response && response.statusCode && response.statusCode === 200) { + if (response && + response.statusCode && + response.statusCode === 200) { console.log(JSON.parse(body).basilisk); cache.io.emit('messages', { 'message': { @@ -688,7 +689,8 @@ cache.one = function(req, res, next) { }); body = JSON.parse(body); // basilisk coins - if (body.basilisk && body.basilisk.length) { + if (body.basilisk && + body.basilisk.length) { // get coin addresses async.each(body.basilisk, function(coin) { callStack[coin] = 1; diff --git a/routes/shepherd.js b/routes/shepherd.js index 67b85f9..6c74c2a 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -43,8 +43,7 @@ if (os.platform() === 'darwin') { iguanaConfsDir = iguanaDir + '/confs', komododBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/osx/komodod'), komodocliBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/osx/komodo-cli'), - komodoDir = process.env.HOME + '/Library/Application Support/Komodo'; - + komodoDir = process.env.HOME + '/Library/Application Support/Komodo', zcashdBin = '/Applications/ZCashSwingWalletUI.app/Contents/MacOS/zcashd', zcashcliBin = '/Applications/ZCashSwingWalletUI.app/Contents/MacOS/zcash-cli', zcashDir = process.env.HOME + '/Library/Application Support/Zcash'; @@ -69,7 +68,7 @@ if (os.platform() === 'win32') { iguanaConfsDir = path.normalize(iguanaConfsDir); iguanaIcon = path.join(__dirname, '/assets/icons/agama_icons/agama_app_icon.ico'), iguanaConfsDirSrc = path.normalize(iguanaConfsDirSrc), - komododBin = path.join(__dirname, '../assets/bin/win64/komodod.exe'), + komododBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/windows/komodod.exe'), komododBin = path.normalize(komododBin), komodocliBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/windows/komodo-cli.exe'), komodocliBin = path.normalize(komodocliBin), @@ -475,10 +474,12 @@ shepherd.getSyncOnlyForksInfo = function() { if (iguanaInstanceRegistry[port].mode.indexOf('/sync') > -1) { syncOnlyIguanaInstanceInfo[port] = {}; request({ - url: 'http://localhost:' + port + '/api/bitcoinrpc/getinfo?userpass=tmpIgRPCUser@1234', + url: 'http://localhost:' + port + '/api/bitcoinrpc/getinfo?userpass=tmpIgRPCUser@' + shepherd.appSessionHash, method: 'GET' }, function (error, response, body) { - if (response && response.statusCode && response.statusCode === 200) { + if (response && + response.statusCode && + response.statusCode === 200) { // console.log(body); try { syncOnlyIguanaInstanceInfo[port].getinfo = JSON.parse(body); @@ -488,10 +489,12 @@ shepherd.getSyncOnlyForksInfo = function() { } }); request({ - url: 'http://localhost:' + port + '/api/SuperNET/activehandle?userpass=tmpIgRPCUser@1234', + url: 'http://localhost:' + port + '/api/SuperNET/activehandle?userpass=' + shepherd.appSessionHash, method: 'GET' }, function (error, response, body) { - if (response && response.statusCode && response.statusCode === 200) { + if (response && + response.statusCode && + response.statusCode === 200) { // console.log(body); try { syncOnlyIguanaInstanceInfo[port].activehandle = JSON.parse(body); @@ -844,7 +847,9 @@ shepherd.post('/setconf', function(req, res) { console.log('======= req.body ======='); console.log(req.body); - if (os.platform() === 'win32' && req.body.chain == 'komodod') { + if (os.platform() === 'win32' && + req.body.chain == 'komodod') { + setkomodoconf = spawn(path.join(__dirname, '../build/artifacts.supernet.org/latest/windows/genkmdconf.bat')); setkomodoconf = spawn(path.join(__dirname, '../build/artifacts.supernet.org/latest/windows/genkmdconf.bat')); } else { setConf(req.body.chain); @@ -981,7 +986,8 @@ shepherd.get('/kick', function(req, res, next) { ] }; - if (_coin && _type) { + if (_coin && + _type) { for (var i = 0; i < kickStartDirs[_type].length; i++) { var currentKickItem = kickStartDirs[_type][i]; @@ -995,7 +1001,8 @@ shepherd.get('/kick', function(req, res, next) { } else if (currentKickItem.type === 'pattern') { var dirItems = fs.readdirSync(iguanaDir + '/' + currentKickItem.name.replace('[coin]', _coin)); - if (dirItems && dirItems.length) { + if (dirItems && + dirItems.length) { for (var j = 0; j < dirItems.length; j++) { if (dirItems[j].indexOf(currentKickItem.match) > -1) { rimraf(iguanaDir + '/' + currentKickItem.name.replace('[coin]', _coin) + '/' + dirItems[j], function(err) { @@ -1048,7 +1055,7 @@ shepherd.readDebugLog = function(fileLocation, lastNLines) { }; function herder(flock, data) { - if (data == undefined) { + if (data === undefined) { data = 'none'; console.log('it is undefined'); } @@ -1295,7 +1302,7 @@ shepherd.setConfKMD = function() { _fs.access(komodoDir + '/komodo.conf', fs.constants.R_OK, function(err) { if (err) { console.log('creating komodo conf'); - shepherd.writeLog('creating komodo conf in ' + komodoDir + '/komodo.conf'); + shepherd.writeLog('creating komodo conf in ' + komodoDir + '/komodo.conf'); setConf('komodod'); } else { shepherd.writeLog('komodo conf exists'); diff --git a/version b/version index 9331c05..0ec99b6 100644 --- a/version +++ b/version @@ -1,2 +1,2 @@ -version=0.1.6 -type=e-beta \ No newline at end of file +version=0.2.0.1 +type=e-beta diff --git a/version_build b/version_build index 148f501..9028718 100644 --- a/version_build +++ b/version_build @@ -1 +1 @@ -0.1.6.2e-beta \ No newline at end of file +0.2.0.1a-beta