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

GetNonce() lead to an invalid auth #201

Open
0xAnarz opened this issue Nov 7, 2019 · 4 comments
Open

GetNonce() lead to an invalid auth #201

0xAnarz opened this issue Nov 7, 2019 · 4 comments

Comments

@0xAnarz
Copy link

0xAnarz commented Nov 7, 2019

GetNonce() for v2 REST can lead to an integer which exceed the MAX_SAFE_INTEGER constant, resulting in an authentication error from the API.

Temp fix :
func (u *EpochNonceGenerator) GetNonce() string { return strconv.FormatUint(atomic.AddUint64(&u.nonce, 1) / 1000, 10) }

@JacobPlaster
Copy link
Contributor

Oh not good, I guess we should use micro seconds instead of unix milli seconds. Thanks @0xAnarz for opening the issue.

I will work on a fix now.

@JacobPlaster
Copy link
Contributor

Actually I've just looked into this. Right now the nonce is generated using the function uint64(time.Now().Unix() * 1000), which right now is 1573140173000.

MAX_SAFE_INTEGER is 9007199254740991 which means I am able to make 9005626114567991 requests before I exceed the integer limit.

Are you sure that the error you are seeing is due to an invalid nonce??

@0xAnarz
Copy link
Author

0xAnarz commented Nov 7, 2019

func (u *EpochNonceGenerator) GetNonce() string { return strconv.FormatUint(atomic.AddUint64(&u.nonce, 1), 10) }
actually give me 1573143819683568401

The temp fix (/1000) work, and without it I'm still getting :

2019/11/07 17:23:39 Error: POST https://api.bitfinex.com/v2/auth/r/positions: 500 apikey: invalid (10100)

Maybe an OS issue ? I'm doing it from win7

@JacobPlaster
Copy link
Contributor

Thats strange, ill try this out on a windows machine.

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 @0xAnarz and others