diff --git a/app/controllers/addresses.js b/app/controllers/addresses.js index 30cfca3c5..f45e249d0 100644 --- a/app/controllers/addresses.js +++ b/app/controllers/addresses.js @@ -9,6 +9,8 @@ var Address = require('../models/Address'); var common = require('./common'); var async = require('async'); +var RPC_CONCURRENCY = 5; + var tDb = require('../../lib/TransactionDb').default(); var getAddr = function(req, res, next) { @@ -101,7 +103,7 @@ exports.multitxs = function(req, res, next) { if (paginated) { txs.sort(function(a, b) { - return (b.ts || b.ts) - (a.ts || a.ts); + return (b.firstSeenTs || b.ts) - (a.firstSeenTs || a.ts); }); var start = Math.max(from || 0, 0); var end = Math.min(to || txs.length, txs.length); @@ -111,10 +113,15 @@ exports.multitxs = function(req, res, next) { var txIndex = {}; _.each(txs, function (tx) { txIndex[tx.txid] = tx; }); - async.each(txs, function (tx, callback) { - tDb.fromIdWithInfo(tx.txid, function(err, tx) { + async.eachLimit(txs, RPC_CONCURRENCY, function(tx2, callback) { + tDb.fromIdWithInfo(tx2.txid, function(err, tx) { if (err) console.log(err); if (tx && tx.info) { + + if (tx2.firstSeenTs) + tx.info.firstSeenTs = tx2.firstSeenTs; + + txIndex[tx.txid].info = tx.info; } callback(); diff --git a/app/controllers/blocks.js b/app/controllers/blocks.js index 2de390d4f..a9ba7540f 100644 --- a/app/controllers/blocks.js +++ b/app/controllers/blocks.js @@ -144,7 +144,8 @@ exports.list = function(req, res) { hash: b.hash, time: b.ts || info.time, txlength: info.tx.length, - poolInfo: info.poolInfo + poolInfo: info.poolInfo, + algo: info.pow_algo }); }); }, function(err, allblocks) { diff --git a/app/controllers/currency.js b/app/controllers/currency.js index 244ef3278..2579543f2 100644 --- a/app/controllers/currency.js +++ b/app/controllers/currency.js @@ -5,7 +5,7 @@ var config = require('../../config/config'); // Set the initial vars var timestamp = +new Date(), delay = config.currencyRefresh * 60000, - bitstampRate = 0; + usdRate = 0; exports.index = function(req, res) { @@ -40,21 +40,21 @@ exports.index = function(req, res) { // Init var currentTime = +new Date(); - if (bitstampRate === 0 || currentTime >= (timestamp + delay)) { + if (usdRate === 0 || currentTime >= (timestamp + delay)) { timestamp = currentTime; - _request('https://www.bitstamp.net/api/ticker/', function(err, data) { - if (!err) bitstampRate = parseFloat(JSON.parse(data).last); + _request('http://coinmarketcap-nexuist.rhcloud.com/api/dgb', function(err, data) { + if (!err) usdRate = parseFloat(JSON.parse(data).price.usd); res.jsonp({ status: 200, - data: { bitstamp: bitstampRate } + data: { bitstamp: usdRate } }); }); } else { res.jsonp({ status: 200, - data: { bitstamp: bitstampRate } + data: { bitstamp: usdRate } }); } }; diff --git a/app/models/Address.js b/app/models/Address.js index 1cfe7e760..e58dd604f 100644 --- a/app/models/Address.js +++ b/app/models/Address.js @@ -1,6 +1,7 @@ 'use strict'; var imports = require('soop').imports(); +var _ = require('lodash'); var async = require('async'); var bitcore = require('bitcore'); var BitcoreAddress = bitcore.Address; @@ -112,7 +113,7 @@ Address.prototype._addTxItem = function(txItem, txList, includeInfo) { seen[txItem.txid] = 1; add = 1; - addTx({ txid: txItem.txid, ts: txItem.ts }); + addTx({ txid: txItem.txid, ts: txItem.ts, firstSeenTs: txItem.firstSeenTs }); } // Spent tx @@ -178,7 +179,7 @@ Address.prototype.update = function(next, opts) { return !x.spentTxId; }); tDb.fillScriptPubKey(txOut, function() { - self.unspent = txOut.map(function(x){ + self.unspent = _.filter(txOut.map(function(x) { return { address: self.addrStr, txid: x.txid, @@ -189,7 +190,7 @@ Address.prototype.update = function(next, opts) { confirmations: x.isConfirmedCached ? (config.safeConfirmations) : x.confirmations, confirmationsFromCache: !!x.isConfirmedCached, }; - }); + }), 'scriptPubKey'); return next(); }); } diff --git a/app/models/Status.js b/app/models/Status.js index ffb744ad0..4bef2dea7 100644 --- a/app/models/Status.js +++ b/app/models/Status.js @@ -7,20 +7,28 @@ var RpcClient = bitcore.RpcClient; var config = require('../../config/config'); var rpc = new RpcClient(config.bitcoind); var bDb = require('../../lib/BlockDb').default(); +var _ = require('lodash'); function Status() {} + Status.prototype.getInfo = function(next) { var that = this; async.series([ function (cb) { - rpc.getInfo(function(err, info){ + rpc.getBlockchainInfo(function(err, info){ if (err) return cb(err); that.info = info.result; return cb(); }); }, + function (cb) { + rpc.getNetworkInfo(function(err, info) { + _.extend(that.info, _.extend(info.result)); + return cb(); + }) + } ], function (err) { return next(err); }); diff --git a/config/config.js b/config/config.js index cdae77c33..f4808699b 100644 --- a/config/config.js +++ b/config/config.js @@ -25,14 +25,14 @@ if (process.env.INSIGHT_NETWORK === 'livenet') { env = 'livenet'; db = home; port = '3000'; - b_port = '8332'; - p2p_port = '8333'; + b_port = '14022'; + p2p_port = '12024'; } else { env = 'testnet'; db = home + '/testnet'; port = '3001'; - b_port = '18332'; - p2p_port = '18333'; + b_port = '14023'; + p2p_port = '12026'; } port = parseInt(process.env.INSIGHT_PORT) || port; @@ -56,9 +56,9 @@ var isWin = /^win/.test(process.platform); var isMac = /^darwin/.test(process.platform); var isLinux = /^linux/.test(process.platform); if (!dataDir) { - if (isWin) dataDir = '%APPDATA%\\Bitcoin\\'; - if (isMac) dataDir = process.env.HOME + '/Library/Application Support/Bitcoin/'; - if (isLinux) dataDir = process.env.HOME + '/.bitcoin/'; + if (isWin) dataDir = '%APPDATA%\\Digibyte\\'; + if (isMac) dataDir = process.env.HOME + '/Library/Application Support/Digibyte/'; + if (isLinux) dataDir = process.env.HOME + '/.digibyte/'; } dataDir += network === 'testnet' ? 'testnet3' : ''; diff --git a/etc/minersPoolStrings.json b/etc/minersPoolStrings.json index 1ad3892d9..cca61ed37 100644 --- a/etc/minersPoolStrings.json +++ b/etc/minersPoolStrings.json @@ -1,227 +1,221 @@ [ { - "poolName":"50BTC", - "url":"https://50btc.com/", + "poolName":"Mining-Dutch", + "url":"https://www.mining-dutch.nl/", "searchStrings":[ - "50BTC.com", - "50btc.com" + "Mining-Dutch" ] }, { - "poolName":"175btc", - "url":"http://www.175btc.com/", + "poolName":"Mining Pool Hub", + "url":"https://miningpoolhub.com/", "searchStrings":[ - "Mined By 175btc.com" + "mph" ] }, { - "poolName":"ASICminer", - "url":"https://bitcointalk.org/index.php?topic=99497.0", + "poolName":"Unknown yiimp", + "url":"https://github.com/tpruvot/yiimp/blob/next/stratum/coinbase.cpp#L100", "searchStrings":[ - "Mined By ASICMiner" + "yiimp" ] }, - { - "poolName":"AntMiner", - "url":"https://bitmaintech.com/", + { + "poolName":"skpool", + "url":"#", "searchStrings":[ - "AntPool" + "skpool" ] }, { - "poolName":"agentD", - "url":"http://", + "poolName":"who", + "url":"#", "searchStrings":[ - "agentD" + "who" ] }, { - "poolName":"Bitfury", - "url":"http://bitfury.org/", + "poolName":"Unknown sapool", + "url":"#", "searchStrings":[ - "2av0id51pct" + "sapool" ] }, { - "poolName":"BitMinter", - "url":"https://bitminter.com/", + "poolName":"ckpool", + "url":"http://solo.ckpool.org/", "searchStrings":[ - "BitMinter" + "ckpool" ] }, { - "poolName":"Bitparking", - "url":"http://bitparking.com/", + "poolName":"ProHashing", + "url":"https://prohashing.com/", "searchStrings":[ - "bitparking" + "prohashing.com" ] }, { - "poolName":"BTC Guild", - "url":"https://www.btcguild.com/", + "poolName":"Multipool.us", + "url":"https://www.multipool.us/", "searchStrings":[ - "Mined by BTC Guild", - "BTC Guild" + "Multipool.us" ] }, + { - "poolName":"bcpool.io", - "url":"https://bcpool.io/", + "poolName":"Unknown p2pool-DGB", + "url":"https://github.com/mcpool/p2pool-dgb", "searchStrings":[ - "bcpool" + "p2pool-DGB" ] }, { - "poolName":"Discus Fish", - "url":"http://f2pool.com/", + "poolName":"dgb256.online", + "url":"https://dgb256.online/", "searchStrings":[ - "七彩神仙鱼", - "Made in China", - "Mined by user" + "dgb256.online" ] }, { - "poolName":"Discus Fish Solo", - "url":"http://f2pool.com/", + "poolName":"Zerg Pool", + "url":"https://zergpool.com/", "searchStrings":[ - "For Pierce and Paul" + "zerg" ] }, { - "poolName":"Cointerra", - "url":"http://cointerra.com/", + "poolName":"Coin Foundry", + "url":"https://coinfoundry.org/", "searchStrings":[ - "cointerra" + "MiningCore" ] }, { - "poolName":"Eligius", - "url":"http://eligius.st/", + "poolName":"gos.cx", + "url":"https://gos.cx/", "searchStrings":[ - "Eligius" + "gos.cx" ] }, - { - "poolName":"EclipseMC", - "url":"https://eclipsemc.com/", + { + "poolName":"MinersPoolEU", + "url":"https://www.miners-pool.eu/", "searchStrings":[ - "Josh Zerlan was here!", - "EclipseMC", - "Aluminum Falcon" - ] - }, - { - "poolName":"GIVE-ME-COINS", - "url":"https://give-me-coins.com/", + "minersPoolEU" + ] + }, + { + + "poolName":"DigiHash", + "url":"http://digihash.co", "searchStrings":[ - "Mined at GIVE-ME-COINS.com" - ] - }, + "DigiHash" + ] + }, { - "poolName":"ghash.io", - "url":"https://ghash.io/", + "poolName":"ZPOOL", + "url":"https://www.zpool.ca", "searchStrings":[ - "ghash.io", - "GHash.IO" + "zpool.ca" ] }, { - "poolName":"HHTT", - "url":"http://hhtt.1209k.com/", + "poolName":"The Blocks Factory", + "url":"https://theblocksfactory.com", "searchStrings":[ - "HHTT" + "theblocksfactory" ] }, - { - "poolName":"KNCminer", - "url":"https://www.kncminer.com/", + { + "poolName":"Unknown NOMP Pool", + "url":"https://github.com/zone117x/node-stratum-pool/blob/4f298c3ead7651646c27a30601fcdbf6512b367a/lib/transactions.js#L78", "searchStrings":[ - "KnCMiner" + "nodeStratum" ] }, - { - "poolName":"Megabigpower", - "url":"http://megabigpower.com/", + { + "poolName":"blazepool", + "url":"http://blazepool.com/", "searchStrings":[ - "megabigpower.com" + "blazepool" ] }, - { - "poolName":"MultiCoin", - "url":"https://multicoin.co/", + { + "poolName":"Brutangs Solo", + "url":"http://dgbsolo.brutang.work:5025/static/", "searchStrings":[ - "MultiCoin.co" + "Brutangs-Solo-Node" ] }, - { - "poolName":"Mt Red", - "url":"https://mtred.com/‎", + { + "poolName":"Brutangs Group", + "url":"http://dgb.brutang.work:5025/static/", "searchStrings":[ - "/mtred/" + "Brutangs-Group-Node" ] }, - { - "poolName":"MaxBTC", - "url":"https://www.maxbtc.com", + { + "poolName":"BSOD", + "url":"http://bsod.pw/", "searchStrings":[ - "MaxBTC" + "bsod" ] }, - { - "poolName":"NMCbit", - "url":"http://nmcbit.com/", + { + "poolName":"Coinminerz", + "url":"http://coinminerz.com", "searchStrings":[ - "nmcbit.com" + "Coinminerz" ] }, - { - "poolName":"ozcoin", - "url":"https://ozco.in/", + { + "poolName":"CybtcPool", + "url":"https://cybtc.info/", "searchStrings":[ - "ozco.in", - "ozcoin" + "CybtcPool" ] }, - { - "poolName":"Polmine.pl", - "url":"https://polmine.pl/‎", + { + "poolName":"dgb256.online", + "url":"https://dgb256.online/", "searchStrings":[ - "by polmine.pl" + "dgb256.online" ] }, - { - "poolName":"simplecoin", - "url":"http://simplecoin.us/", + { + "poolName":"HashWiz", + "url":"https://hashwiz.io/", "searchStrings":[ - "simplecoin.us ftw" + "hashwiz.io" ] }, - { - "poolName":"Slush", - "url":"https://mining.bitcoin.cz/", + { + "poolName":"PersianMine", + "url":"https://persianmine.com/pool/en", "searchStrings":[ - "slush" + "PersianMine.com" ] }, - { - "poolName":"TripleMining", - "url":"https://www.triplemining.com/", + { + "poolName":"SwineMine", + "url":"https://www.swinemine.com/", "searchStrings":[ - "Triplemining.com" + "SwineMine.com" ] }, - { - "poolName":"wizkid057", - "url":"http://wizkid057.com/btc", + { + "poolName":"The Crypto Pools", + "url":"https://cryptopools.aod-tech.com/", "searchStrings":[ - "wizkid057" + "Crypto Pools by AoD Technologies" ] }, - { - "poolName":"Yourbtc.net", - "url":"http://yourbtc.net/", + { + "poolName":"IceMining.ca", + "url":"https://icemining.ca/", "searchStrings":[ - "yourbtc.net" + "iceca" ] } ] diff --git a/lib/Rpc.js b/lib/Rpc.js index f81f37212..8702eaa4f 100644 --- a/lib/Rpc.js +++ b/lib/Rpc.js @@ -88,7 +88,8 @@ Rpc.getBlock = function(hash, cb) { if (info.result.height) - info.result.reward = BitcoreBlock.getBlockValue(info.result.height) / bitcore.util.COIN ; + info.result.reward = (BitcoreBlock.getBlockValue(info.result.height) / bitcore.util.COIN); + info.result.reward = Math.floor(info.result.reward); return cb(err,info.result); }); diff --git a/lib/TransactionDb.js b/lib/TransactionDb.js index 37e507330..29970aff0 100644 --- a/lib/TransactionDb.js +++ b/lib/TransactionDb.js @@ -465,8 +465,11 @@ TransactionDb.prototype.fromAddr = function(addr, opts, cb) { var k = data.key.split('-'); var index = k[3] + k[4]; if (!unique[index]) { - unique[index] = 1; - ret.push(self._parseAddrData(k, data, opts.ignoreCache)); + unique[index] = self._parseAddrData(k, data, opts.ignoreCache); + ret.push(unique[index]); + } else { + // add first seen + unique[index].firstSeenTs = END_OF_WORLD_TS - parseInt(k[2]); } }) .on('error', cb) @@ -520,12 +523,16 @@ TransactionDb.prototype.getStandardizedTx = function(tx, time, isCoinBase) { var val; if (txout.s) { var s = new Script(txout.s); - var addrs = new Address.fromScriptPubKey(s, config.network); - // support only for p2pubkey p2pubkeyhash and p2sh - if (addrs && addrs.length === 1) { - val = { - addresses: [addrs[0].toString()] - }; + try { + var addrs = new Address.fromScriptPubKey(s, config.network); + // support only for p2pubkey p2pubkeyhash and p2sh + if (addrs && addrs.length === 1) { + val = { + addresses: [addrs[0].toString()] + }; + } + } catch(e) { + val = { addresses: [] } } } return { diff --git a/package.json b/package.json index 0505b3ef0..3217124e0 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "insight-bitcore-api", - "description": "An open-source bitcoin blockchain API. The Insight API provides you with a convenient, powerful and simple way to query and broadcast data on the bitcoin network and build your own services with it.", - "version": "0.2.12", + "description": "An open-source DigiByte blockchain API. The Insight API provides you with a convenient, powerful and simple way to query and broadcast data on the bitcoin network and build your own services with it.", + "version": "0.2.13", "author": { - "name": "Ryan X Charles", - "email": "ryan@bitpay.com" + "name": "DigiByte Team", + "email": "info@digibyte.io" }, - "repository": "git://github.com/bitpay/insight-api.git", + "repository": "git@github.com:DigiByte-Core/insight-api.git", "contributors": [ { "name": "Matias Alejo Garcia", @@ -34,9 +34,9 @@ } ], "bugs": { - "url": "https://github.com/bitpay/insight-api/issues" + "url": "https://github.com/DigiByte-Core/insight-api/issues" }, - "homepage": "https://github.com/bitpay/insight-api", + "homepage": "https://github.com/DigiByte-Core/insight-api.git", "license": "MIT", "keywords": [ "insight", @@ -55,11 +55,11 @@ "start": "node node_modules/grunt-cli/bin/grunt" }, "dependencies": { - "async": "*", + "async": "0.9.2", "base58-native": "0.1.2", "bignum": "*", "bitauth": "^0.1.1", - "bitcore": "git://github.com/bitpay/bitcore.git#aa41c70cff2583d810664c073a324376c39c8b36", + "bitcore": "git://github.com/digicontributer/bitcore.git#8a1376a65a23dc5e6e7445eee8227442a19abb88", "bufferput": "git://github.com/bitpay/node-bufferput.git", "buffertools": "*", "commander": "^2.3.0", @@ -79,7 +79,7 @@ "socket.io": "1.0.6", "socket.io-client": "1.0.6", "soop": "=0.1.5", - "winston": "*", + "winston": "0.5.7", "xmlhttprequest": "~1.6.0" }, "devDependencies": { diff --git a/plugins/emailTemplates/copay.html b/plugins/emailTemplates/copay.html index 3639b0d4e..84ccd8ab3 100644 --- a/plugins/emailTemplates/copay.html +++ b/plugins/emailTemplates/copay.html @@ -150,12 +150,12 @@

Hi, <%= email %>

-

You are now using Insight to store an encrypted Copay backup. This is a free -service that we are providing that you can turn off from Copay's preferences.

+

You are now using DigiExplorer to store an encrypted DGBWallet backup. This is a free +service that we are providing that you can turn off from DGBWallet's preferences.

In order to prevent abuse, we need you to confirm that this email is valid and that you requested this backup. Please follow this link if you agree on -backing up your Copay profile within our servers:

+backing up your DGBWallet profile within our servers:

@@ -166,7 +166,7 @@

We would also like you to know that: