You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, Im trying to make a trading API for Bitforex but I am running into signData invalid problem, I see this thread https://github.com/bitforexapi/API_Doc_en/issues/10 had a similar problem and a poster recommended re-ordering the parameters, I tried alphabetizing and encodingURI like https://github.com/bitforexapi/API_Doc_en/issues/5 thread recommends and still get the same error, does anyone have ideas? Below is my code
const Crypto = require('crypto') // Standard JavaScript cryptography library const request = require('request') // "Request" HTTP req library const config = require('./config') const bitforex = https://api.bitforex.com`;
const api = "API";
const apiSecretUnencoded = "API_Secret";
let apiSecret = encodeURI(apiSecretUnencoded)
let price = 0;
let amount = 0;
let tradeType = 1; // tradeType 1 is buy , tradeType 2 is sell
let symbol = "coin-usdt-eth";
let nonce = Date.now();
let apiPath = /api/v1/trade/placeOrder?amount=${amount}&accessKey=${api}&nonce=${nonce}&price=${price}&symbol=${symbol}&tradeType=${tradeType}&signData=
const message = ${bitforex}${apiPath};
console.log("apiPath: "+ apiPath);
const signData = Crypto.createHmac('sha256', apiSecret).digest('hex');// The authentication signature is hashed using the private key
let fullData = ${bitforex}${apiPath}${signData};
console.log("signdata: " + signData);
console.log("");
console.log(${fullData});
const body = {}
const options = {
url: fullData,
headers: {
'content-type': 'application/json',
},
json: true
}
request.post(options, (error, response, body) => {
console.log(body); // Logs the response body
})`
In the event anyone needs this in the future the signData const does work properly, doubled checked it against a working python version. Using the same Nonce Im still getting different hashes though, now checking into if the byte array that works on python is parsed differently than the string here
Activity
BronacusAmmon commentedon Mar 25, 2020
In the event anyone needs this in the future the signData const does work properly, doubled checked it against a working python version. Using the same Nonce Im still getting different hashes though, now checking into if the byte array that works on python is parsed differently than the string here