Closed rosa1173 closed 4 years ago
Hi @rosa1173 , that sounds like a nasty one... I've ran the the checks with my own account and I don't get the error. Do you get the error on all private Kraken API calls? Try e.g. a simple one without parameters vs a more complex one with parameters?
So the culprit must be in: APIsign = ComputeHash_C("SHA512", urlPath & ComputeHash_C("SHA256", NonceUnique & postdata, "", "RAW"), Base64Decode(Credentials("secretKey")), "STR64")
I assume you checked the variables that go into that function (urlPath, NonceUnique & postdata, Credentials("secretKey")) ? Sneaky differences like a space lead to a completely different outcome.
Hi @krijnsent, thank you so much for your reply. Yes, I am trying simple private Kraken API such as "Balance" which works on my Python program. It's just odd only Kraken API signature calculation doesn't work on this workbook, is this something related to my Kraken API Key/Secret got symbols such as "+" and "="? Also, I'm using Windows 10 and I had to downgrade .NET framework version to 3.5 to make the HMACSHA work. I have checked every single variable, and even tried different base64s in hex, byte etc... :( please let me know if there's anything I should try. Thanks!
Hi @rosa1173 , my kraken API secret has also + and =, so that shouldn't be the issue. I'm suspecting that the Base64Decode is the main issue, with the ComputeHash_C as the second suspect. As I can't look into your system, this is the list I would go through and double check with the Python code/outcome:
The last two are a bit tricky, as they give back raw ASCII which with debug.print is a bit nasty as not all characters are alphanumerical. So what I tried in a test for the Base64Decode is something like this:
StrIn = "0x854867+4897a765awekijxo+aABZ=="
StrOut = Base64Decode(StrIn)
TxtOut = ""
For i = 1 To Len(StrOut)
TxtOut = TxtOut & Asc(Mid(StrOut, i, 1)) & "-"
Next i
Debug.Print StrIn
Debug.Print StrOut
Debug.Print TxtOut
Hi @krijnsent, thank you so much for your help!
I also think Base64Decode could be the cause as your ModHash Module works for Bitfinex, BitMEX, Bittrex and Binance. (meaning ComputeHash_C is correctly working)
I tried different Base64 VBA decoders probably all of the available ones online, and they generate different results and none of them worked.
Result Example(modified):
Now I think that it's probably something related to character set as my system's default character set could be shift_jis instead of utf-8. I will investigate further, and please let me know if there's anything else I can try.
Thank you!
Hi @rosa1173 , mmm, okay, we got the culprit, victory one :). Maybe the character set is indeed the key. I found this post: https://stackoverflow.com/questions/41572920/encoding-special-chracters-to-base64-in-excel-vba -> there is other VBA code to do a base64 conversion. Could you check out if that works? Again: the bit of code I posted in my previous reaction helps to make sure that all characters are the same (as they are not all printable). Cheers, Koen
Hi @rosa1173 , any update on your issue? If not, i'd like to close this issue.
Hi @krijnsent. thanks for the Crypto VBA spreadsheet. Great work!! I know we had Kraken API issues before which were solved and closed before, but I'm still having difficulty connecting its Private API - getting {"error":["EAPI:Invalid key"]}
I do not get any error while connecting with other exchanges such as Binance, Bitfinex, and Bittrex on this sheet, so it's not about JSON converter or objHTTP.Send matter. I also can connect and successfully get the Private data on my Python program with the API key and secret, so my API key should be correct as well.
I carefully went through the API signature calculation part line by line, and I noticed the final "API-Sign" generated on this program is different from the one generated on my Python program (using the same nonce) (And, actually, I manually pasted the nonce and API signature generated on my Python program on this VBA, and I could successfully get the correct JSON data back)
I just need to be able to calculate the API signature for Kraken correctly, could you investigate and guide me...??
Thanks!