fix bitstamp exchange
This commit is contained in:
parent
97bab49e15
commit
3652871ea4
3 changed files with 13 additions and 14 deletions
|
|
@ -176,7 +176,7 @@ function fetchData () {
|
|||
{code: 'litecoind', display: 'litecoind', class: 'wallet', cryptos: ['LTC']},
|
||||
{code: 'dashd', display: 'dashd', class: 'wallet', cryptos: ['DASH']},
|
||||
{code: 'bitgo', display: 'BitGo', class: 'wallet', cryptos: ['BTC']},
|
||||
{code: 'bitstamp', display: 'Bitstamp', class: 'exchange', cryptos: ['BTC']},
|
||||
{code: 'bitstamp', display: 'Bitstamp', class: 'exchange', cryptos: ['BTC', 'LTC']},
|
||||
{code: 'kraken', display: 'Kraken', class: 'exchange', cryptos: ['BTC', 'ETH', 'LTC', 'DASH', 'ZEC']},
|
||||
{code: 'mock-wallet', display: 'Mock wallet', class: 'wallet', cryptos: ALL_CRYPTOS},
|
||||
{code: 'no-exchange', display: 'No exchange', class: 'exchange', cryptos: ALL_CRYPTOS},
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
const querystring = require('querystring')
|
||||
const axios = require('axios')
|
||||
const crypto = require('crypto')
|
||||
const _ = require('lodash')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const API_ENDPOINT = 'https://www.bitstamp.net/api/v2'
|
||||
|
||||
|
|
@ -42,22 +42,27 @@ function authRequest (config, path, data) {
|
|||
.digest('hex')
|
||||
.toUpperCase()
|
||||
|
||||
_.merge(data, {
|
||||
const signedData = _.merge(data, {
|
||||
key: config.key,
|
||||
signature: signature,
|
||||
nonce: nonce
|
||||
})
|
||||
|
||||
return request(path, 'POST', data)
|
||||
return request(path, 'POST', signedData)
|
||||
}
|
||||
|
||||
function buildMarket (fiatCode, cryptoCode) {
|
||||
if (cryptoCode !== 'BTC') throw new Error('Unsupported crypto: ' + cryptoCode)
|
||||
if (fiatCode === 'USD') return 'btcusd'
|
||||
if (fiatCode === 'EUR') return 'btceur'
|
||||
if (!_.includes(cryptoCode, ['BTC', 'LTC'])) {
|
||||
throw new Error('Unsupported crypto: ' + cryptoCode)
|
||||
}
|
||||
|
||||
if (!_.includes(fiatCode, ['USD', 'EUR'])) {
|
||||
throw new Error('Unsupported fiat: ' + fiatCode)
|
||||
}
|
||||
|
||||
return `${cryptoCode.toLowerCase()}${fiatCode.toLowerCase()}`
|
||||
}
|
||||
|
||||
function request (path, method, data) {
|
||||
const options = {
|
||||
method: method,
|
||||
|
|
|
|||
|
|
@ -3,11 +3,6 @@ const common = require('../../common/bitstamp')
|
|||
|
||||
function ticker (account, fiatCode, cryptoCode) {
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
if (cryptoCode !== 'BTC') {
|
||||
throw new Error('Unsupported crypto: ' + cryptoCode)
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
const market = common.buildMarket(fiatCode, cryptoCode)
|
||||
return common.request('/ticker/' + market, 'GET')
|
||||
|
|
@ -23,4 +18,3 @@ function ticker (account, fiatCode, cryptoCode) {
|
|||
module.exports = {
|
||||
ticker
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue