bitfinexcom / bitfinex-api-node

BITFINEX NodeJS trading API - Bitcoin, Litecoin, and Ether exchange
https://www.bitfinex.com/
MIT License
462 stars 213 forks source link

fix nonce mechanism #566

Open robertkowalski opened 3 years ago

robertkowalski commented 3 years ago

when the api key way used with the node lib, the nonce does not work any more in the ruby lib and our other libraries

https://github.com/bitfinexcom/bfx-api-node-util/blob/master/lib/nonce.js#L11

the change was added in https://github.com/bitfinexcom/bfx-api-node-util/commit/8980fe2e02cf471703f18acb75ed369c54efd2eb and is imho the wrong approach fixing it, because multiplying by 1000 does not fix the issue, am i missing something here?

the ruby lib still has the old code, where a normal timestamp is used https://github.com/bitfinexcom/bitfinex-api-rb/blob/cac18d9b817663fef9b4a07b5730d1402272e709/lib/rest/rest_client.rb#L91-L93

not sure about the other implementations, like golang

Originally posted by @robertkowalski in https://github.com/bitfinexcom/bitfinex-api-rb/pull/98#r547931566

ezewer commented 3 years ago

The 1000 rule is kept as to do backward compatibility as the nodejs library already had it in previous versions, check the following: https://github.com/bitfinexcom/bitfinex-api-node/commit/036e20b08b4f630df890e4f2872e6d1d90f3c02f#diff-005b36cbae2c8dbca1a[…]53039360d359604a90260R23 If removing it would break all the bots and other software that are using it, that is what happened when utils was migrated as a separate library, this was not taken into consideration and was a huge issue. That commit was a to fix it. As a great plus it allows to +1 if there are several calls on the same ms, so for example if there are 2 calls on ms 1608762134348, first call would be 1608762134348000 and second 1608762134348001 Recommendation would be too add *1000 to ruby also as using greater values would keep compatibility, on case where it does not matter if a call fails and can be done again. If using different workers, software, etc best approach is to use different keys.