diff --git a/coins/21coin.json b/coins/21coin.json new file mode 100644 index 0000000..8aa9ea5 --- /dev/null +++ b/coins/21coin.json @@ -0,0 +1,5 @@ +{ + "name": "21coin", + "symbol": "21", + "algorithm": "sha256" +} diff --git a/coins/arkenstone.json b/coins/arkenstone.json new file mode 100644 index 0000000..d767bdd --- /dev/null +++ b/coins/arkenstone.json @@ -0,0 +1,5 @@ +{ + "name": "Arkenstone", + "symbol": "ARS", + "algorithm": "sha256" +} diff --git a/coins/arkhash.json b/coins/arkhash.json new file mode 100644 index 0000000..da4d780 --- /dev/null +++ b/coins/arkhash.json @@ -0,0 +1,5 @@ +{ + "name": "Arkhash", + "symbol": "ARK", + "algorithm": "sha256" +} diff --git a/coins/bitraam.json b/coins/bitraam.json new file mode 100644 index 0000000..4a46ae7 --- /dev/null +++ b/coins/bitraam.json @@ -0,0 +1,5 @@ +{ + "name": "BitRaam", + "symbol": "BRM", + "algorithm": "sha256" +} diff --git a/coins/continuumcoin.json b/coins/continuumcoin.json new file mode 100644 index 0000000..21a3b6e --- /dev/null +++ b/coins/continuumcoin.json @@ -0,0 +1,5 @@ +{ + "name": "Continuumcoin", + "symbol": "CTM", + "algorithm": "sha256" +} diff --git a/coins/fastcoinsha.json b/coins/fastcoinsha.json new file mode 100644 index 0000000..d4e0882 --- /dev/null +++ b/coins/fastcoinsha.json @@ -0,0 +1,5 @@ +{ + "name": "Fastcoinsha", + "symbol": "FSS", + "algorithm": "sha256" +} diff --git a/coins/stashcoin.json b/coins/stashcoin.json new file mode 100644 index 0000000..6c2a50a --- /dev/null +++ b/coins/stashcoin.json @@ -0,0 +1,5 @@ +{ + "name": "Stashcoin", + "symbol": "STA", + "algorithm": "sha256" +} diff --git a/coins/wearesatoshi.json b/coins/wearesatoshi.json new file mode 100644 index 0000000..01ed43d --- /dev/null +++ b/coins/wearesatoshi.json @@ -0,0 +1,5 @@ +{ + "name": "WeAreSatoshi", + "symbol": "WAS", + "algorithm": "sha256" +} diff --git a/libs/apiCoinWarz.js b/libs/apiCoinWarz.js new file mode 100644 index 0000000..172d2b7 --- /dev/null +++ b/libs/apiCoinWarz.js @@ -0,0 +1,115 @@ +var request = require('request'); +var nonce = require('nonce'); + +module.exports = function() { + 'use strict'; + + // Module dependencies + + // Constants + var version = '0.0.1', + PUBLIC_API_URL = 'http://www.coinwarz.com/v1/api/profitability/?apikey=YOUR_API_KEY&algo=all', + USER_AGENT = 'nomp/node-open-mining-portal' + + // Constructor + function Cryptsy(key, secret){ + // Generate headers signed by this user's key and secret. + // The secret is encapsulated and never exposed + this._getPrivateHeaders = function(parameters){ + var paramString, signature; + + if (!key || !secret){ + throw 'CoinWarz: Error. API key and secret required'; + } + + // Sort parameters alphabetically and convert to `arg1=foo&arg2=bar` + paramString = Object.keys(parameters).sort().map(function(param){ + return encodeURIComponent(param) + '=' + encodeURIComponent(parameters[param]); + }).join('&'); + + signature = crypto.createHmac('sha512', secret).update(paramString).digest('hex'); + + return { + Key: key, + Sign: signature + }; + }; + } + + // If a site uses non-trusted SSL certificates, set this value to false + Cryptsy.STRICT_SSL = true; + + // Helper methods + function joinCurrencies(currencyA, currencyB){ + return currencyA + '_' + currencyB; + } + + // Prototype + CoinWarz.prototype = { + constructor: CoinWarz, + + // Make an API request + _request: function(options, callback){ + if (!('headers' in options)){ + options.headers = {}; + } + + options.headers['User-Agent'] = USER_AGENT; + options.json = true; + options.strictSSL = CoinWarz.STRICT_SSL; + + request(options, function(err, response, body) { + callback(err, body); + }); + + return this; + }, + + // Make a public API request + _public: function(parameters, callback){ + var options = { + method: 'GET', + url: PUBLIC_API_URL, + qs: parameters + }; + + return this._request(options, callback); + }, + + + ///// + + + // PUBLIC METHODS + + getTicker: function(callback){ + var parameters = { + method: 'marketdatav2' + }; + + return this._public(parameters, callback); + }, + + getOrderBook: function(currencyA, currencyB, callback){ + var parameters = { + command: 'returnOrderBook', + currencyPair: joinCurrencies(currencyA, currencyB) + }; + + return this._public(parameters, callback); + }, + + getTradeHistory: function(currencyA, currencyB, callback){ + var parameters = { + command: 'returnTradeHistory', + currencyPair: joinCurrencies(currencyA, currencyB) + }; + + return this._public(parameters, callback); + }, + + + //// + + return CoinWarz; +}(); diff --git a/libs/profitSwitch.js b/libs/profitSwitch.js index 990314e..c4b712d 100644 --- a/libs/profitSwitch.js +++ b/libs/profitSwitch.js @@ -4,6 +4,7 @@ var bignum = require('bignum'); var algos = require('stratum-pool/lib/algoProperties.js'); var util = require('stratum-pool/lib/util.js'); +var CoinWarz = require('./apiCoinWarz.js'); var Cryptsy = require('./apiCryptsy.js'); var Poloniex = require('./apiPoloniex.js'); var Mintpal = require('./apiMintpal.js'); @@ -65,6 +66,10 @@ module.exports = function(logger){ // // setup APIs // + var coinwarzApi = new CpinWarz( + // 'API_KEY', + // 'API_SECRET' + ); var poloApi = new Poloniex( // 'API_KEY', // 'API_SECRET'