Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nonce to small error when using two libraries with same API Key #200

Open
1 task done
Jonah246 opened this issue Oct 16, 2019 · 1 comment
Open
1 task done

nonce to small error when using two libraries with same API Key #200

Jonah246 opened this issue Oct 16, 2019 · 1 comment

Comments

@Jonah246
Copy link

Issue type

  • bug

Brief description

I used python-sdk and this Golang sdk with the same api-key. While it works smoothly in python, I got error 500 nonce: small (10114).

Additional Notes:

After reading the source code, I found that nonce generation rules differs between two libraries

utils/nonce.go

func NewEpochNonceGenerator() *EpochNonceGenerator {
	return &EpochNonceGenerator{
		nonce: uint64(time.Now().Unix() * 1000),
	}
}

utils/auth.py

def _gen_nonce():
  return int(round(time.time() * 1000000))

If users use the same ApiKey, Go-SDK will generate a nonce that's 1000 times smaller than the python's one and always yield a nonce to small error. It may not be a bug but would be nice to have consistent rules between libraries.

@Jonah246 Jonah246 changed the title nonce to small error when using two librarie nonce to small error when using two libraries with same API Key Oct 16, 2019
@JacobPlaster
Copy link
Contributor

JacobPlaster commented Oct 17, 2019

Hey @Jonah246 thanks for raising this as an issue and providing some good code examples. We are aware of this problem but havent changed it due to the fact that we like to encourage users to generate a new key for each strategy/implementation.

It may not be a bug but would be nice to have consistent rules between libraries.

I do agree with this so im going to leave this open and add a TODO for us to implement this. I guess we have two options, either we upgrade all of the libs to match the python lib (since the nonce is the largest there) or we break some peoples code and force them to re-generate new api keys.

For reference, the nodejs nonce generation function: https://github.com/bitfinexcom/bfx-api-node-util/blob/master/lib/nonce.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@JacobPlaster @Jonah246 and others