我正在尝试为专用端点生成签名消息。来自Kraken Futures API的文档步骤如下:
这就是我所做的:
//Definition of arguments
const secret = 'SecretGeneratedByKraken...rEqyX3nPw3UURLCu/M'
var nonce = new Date() * 1000;
const path = 'https://futures.kraken.com/derivatives/api/v3/' + fills;
const signature = getMessageSignature(path,params,secret,nonce);
//Auth function
getMessageSignature = (path, params, secret, nonce) => {
var message = qs.stringify(params);
var concat = message + nonce + path; // 1
var hash = crypto.createHash('sha256');
var hash_digest = hash.update(concat).digest('binary'); // 2
var secret_decoded = Buffer.from(secret, 'base64'); // 3
var hmac = crypto.createHmac('sha512', hash_digest);
var hmac_digest = hmac.update(secret_decoded, 'binary').digest('base64'); //4 and 5
return hmac_digest;
}
再次检查我是否传递了正确的参数,我们将不胜感激。