Ok, so a developer friend has managed to help create a HMAC signature using opesSSL and using a batch to write a 'signature.txt' from which we pull the signature. The procedure is as follows...
time =InternetOpenURL("https://testnet.binance.vision/api/v3/time");
if( time )
{
while( ( str = InternetReadString( time ) ) != "" )
{
extracted = StrMid(str,14,13);
printf( "%s", extracted);
}
InternetClose( time );
}
apikey="YOUR_API_KEY_HERE";
secret="YOUR_API_SECRET_HERE";
url = "https://api3.binance.com" + "/sapi/v1/accountSnapshot";
queryString = " recvWindow=5000×tamp=" + extracted;
requestBody = "";
// use openssl to create signature.txt file
//opensslCmd = "echo -n \"" + queryString + requestBody + "\" | \"C:\\program files\\OpenSSL-Win64\\bin\\openssl.exe \" dgst -sha256 -hmac " + secret+" > signature.txt";
//printf(opensslCmd);
executeRes = ShellExecute("test.bat" ,queryString,"" ,1 );
printf("ShellExecute result = %g", executeRes);
// read in the signature from signature.txt
signature = "";
fh = fopen( "signature.txt", "r");
if( fh )
{
{
signature = fgets( fh );
printf("fgets = %s ",signature);
}
}
else
{
printf("ERROR: file can not be found (does not exist)");
}
fclose(fh);
signature = StrReplace(signature, "SHA2-256(stdin)= ", "");
signature = StrReplace(signature, "\n", "");
printf(signature);
// set header
InternetSetHeaders("X-MBX-APIKEY: " + apikey);
// do http get request
ih = InternetOpenURL( url + queryString + "&signature=" + signature );
if( ih )
{
while( ( str = InternetReadString( ih ) ) != "" )
{
printf( "%s", str );
}
InternetClose( ih );
}
else
printf("error getting from internet");
The test.bat file...
del signature.txt
echo -n %1 | "C:\program files\OpenSSL-Win64\bin\openssl.exe " dgst -sha256 -hmac qSzqUuN8LVTxMuMZvRvEz08QOHJ2yfzUoSKN2l8r1Z0i3dGrpHmi092Q2hPwSeMF > signature.txt
So, we have the hashing of the key via openSSL, which is what this thread was about. However, we're not out of the woods, as Binance still isn't happy. The JSON (I think this is a JSON) from Binance reads...
1663205835743WWNyvuBbxTJYIe2P4YV80zx4iAX7KAFAfgWHIGwjC2LqPcszGg3LOUdXAP1ku973
qSzqUuN8LVTxMuMZvRvEz08QOHJ2yfzUoSKN2l8r1Z0i3dGrpHmi092Q2hPwSeMF
https://api3.binance.com/sapi/v1/accountSnapshot
recvWindow=5000×tamp=1663205835743
ShellExecute result = 42
fgets = SHA2-256(stdin)= 08bca132af726eaf6db06b111fe17b02efb248b0c1fc77bc9f6347f69c8acee0
08bca132af726eaf6db06b111fe17b02efb248b0c1fc77bc9f6347f69c8acee0
08bca132af726eaf6db06b111fe17b02efb248b0c1fc77bc9f6347f69c8acee0
08bca132af726eaf6db06b111fe17b02efb248b0c1fc77bc9f6347f69c8acee0{"timestamp":1663205836583,"status":404,"error":"Not Found","message":"No message available","path":"/sapi/v1/accountSnapshot%20recvWindow=5000×tamp=1663205835743&signature=08bca132af726eaf6db06b111fe17b02efb248b0c1fc77bc9f6347f69c8acee0"}
Debug session has ended.
I can see that after accounthosted there is a %20, so I have delted the space, and got pretty much the same output ".....v1/accountSnapshotrecvWindow=5000×tamp=166320....." and I have also tried inserting & before recvWindow, but I still get the same JSON returned.
Any ideas on what I could be doing wrong? Wallet endpoints are here and signing instructions are here
@Tomasz I'm wondering if I should post this as a separate topic since the OP was about HMAC signitures, which I am 95% sure we have cracked so I'm wondering if the thread is actually solved, or, not as it's part of a larger project.