dparlevliet / node.bittrex.api

Node Bittrex API is an asynchronous node.js library for the Bittrex API, the data can be received either via GET request or Stream.
MIT License
253 stars 100 forks source link

Cannot execute sample code - error when calling `getticker` #82

Closed TravelingTechGuy closed 6 years ago

TravelingTechGuy commented 6 years ago

I'm getting an error when running the sample code. Specifically, I get an error in the hmac-sha512.js file, when calling getticker (the first API call, getmarketsummaries, works well):

C:\Users\User\Code\bittrex\node_modules\node-bittrex-api\hmac-sha512.js:24
(function(){var a=CryptoJS,j=a.enc.Utf8;a.algo.HMAC=a.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init;"string"==typeof b&&(b=j.parse(b));var f=a.blockSize,l=4*f;b.sigBytes>l&&(b=a.finalize(b));b.clamp();for(var u=this._oKey=b.clone(),k=this._iKey=b.clone(),m=u.words,y=k.words,z=0;z<f;z++)m[z]^=1549556828,y[z]^=909522486;u.sigBytes=k.sigBytes=l;this.reset()},reset:function(){var a=this._hasher;a.reset();a.update(this._iKey)},update:function(a){this._hasher.update(a);return this},finalize:function(a){var b=

                                                                         ^

TypeError: Cannot read property 'sigBytes' of undefined
    at new init (C:\Users\User\Code\bittrex\node_modules\node-bittrex-api\hmac-sha512.js:24:178)
    at Object.HmacSHA512 (C:\Users\User\Code\bittrex\node_modules\node-bittrex-api\hmac-sha512.js:12:488)    at setRequestUriGetParams (C:\Users\User\Code\bittrex\node_modules\node-bittrex-api\node.bittrex.api.js:97:38)
    at publicApiCall (C:\Users\User\Code\bittrex\node_modules\node-bittrex-api\node.bittrex.api.js:154:53)
    at Object.getticker (C:\Users\User\Code\bittrex\node_modules\node-bittrex-api\node.bittrex.api.js:343:7)
    at bittrex.getmarketsummaries (C:\Users\User\Code\bittrex\index.js:16:13)
    at Request._callback (C:\Users\User\Code\bittrex\node_modules\node-bittrex-api\node.bittrex.api.js:144:11)
    at Request.self.callback (C:\Users\User\Code\bittrex\node_modules\request\request.js:186:22)
    at Request.emit (events.js:159:13)
    at Request.<anonymous> (C:\Users\User\Code\bittrex\node_modules\request\request.js:1163:10) 

I'm running the code on a Windows 10 machine. With minor changes, it's exactly the same as the sample:

const bittrex = require('node-bittrex-api');
const settings = require('./settings');

bittrex.options({
  'apikey': settings.apikey,
  'apisecret': settings.apisecret,
  'verbose': true
});

console.log('here');

bittrex.getmarketsummaries((data, err) => {
  if(err) {
    return console.error(err);
  }
  for(var i in data.result) {
    console.log(data.result[i].MarketName);
    bittrex.getticker({market: data.result[i].MarketName}, (ticker, err2) => {
      if(err) {
        return console.error(err2);
      }
      console.log(ticker);
    });
  }
});

What am I doing wrong?

PS: just verified I'm getting the exact same error when calling getbalance or any other method that requires authentication.

TravelingTechGuy commented 6 years ago

My bad - my settings file was corrupted. All works well.