ccxt的bitmart签名无效错误
createOrder: async (req,res) =>; { 常量{ 象征, 数量, 价格, 边 } = 请求体;
const t = Math.floor(new Date().getTime());
console.log(t);
const timestamp = t;
const memo = '*****';
const queryString = {"symbol":"BMX","side":"BUY"};
const SecretKey = '***************************************';
const signat = new CryptoJS.HmacSHA256(timestamp + "#" + memo + "#" + queryString, SecretKey);
const s = signat.toString();
console.log(s);
const exchange = new ccxt.bitmart({
apiKey: process.env.apiKey,
secret: process.env.secret,
uid: process.env.uid,
password: process.env.password,
enableRateLimit: true,
memo:'amal',
headers: {
'X-BM-SIGN': s,
},
// 'options': {
// 'createMarketBuyOrderRequiresPrice': true,
// },
// url: "https://api-test.bitmax-sandbox.io/",
// sign: signat,
});
//console.log(exchange);
try {
console.log("inside create order");
const s = symbol;
const a = amount ;// BMX
const p = price ;// BTC
const buyOrsell = side;
// cost = amount * price = 2 * 9000 = 18000 (USD)
const order = await exchange.createOrder (s, 'market', buyOrsell, a, p);
console.log (order);
res.json(order);
} catch (e) {
if (e instanceof ccxt.NetworkError) {
console.log (exchange.id, 'createOrder failed due to a network error:', e.message)
// retry or whatever
// ...
} else if (e instanceof ccxt.ExchangeError) {
console.log (exchange.id, 'createOrder failed due to exchange error:', e.message)
// res.json(exchange.id, 'createOrder failed due to exchange error:', e.message);
// retry or whatever
// ...
} else {
console.log (exchange.id, 'createOrder failed with:', e.message)
// retry or whatever
// ...
}
}
// catch (err) {
// res.json({ message: err});
// console.log(err);
// }
}
由于交换错误,
bitmart createOrder 失败:bitmart {"message":"标头 X-BM-SIGN 错误","code":30005,"trace":"74530845-d504-46b1-b1f9-1374ae11cbc6","data ":{}}
这个标头在哪里给出? 怎么解决这个问题?
createOrder: async (req,res) => {
const {
symbol,
amount,
price,
side
} = req.body;
const t = Math.floor(new Date().getTime());
console.log(t);
const timestamp = t;
const memo = '*****';
const queryString = {"symbol":"BMX","side":"BUY"};
const SecretKey = '***************************************';
const signat = new CryptoJS.HmacSHA256(timestamp + "#" + memo + "#" + queryString, SecretKey);
const s = signat.toString();
console.log(s);
const exchange = new ccxt.bitmart({
apiKey: process.env.apiKey,
secret: process.env.secret,
uid: process.env.uid,
password: process.env.password,
enableRateLimit: true,
memo:'amal',
headers: {
'X-BM-SIGN': s,
},
// 'options': {
// 'createMarketBuyOrderRequiresPrice': true,
// },
// url: "https://api-test.bitmax-sandbox.io/",
// sign: signat,
});
//console.log(exchange);
try {
console.log("inside create order");
const s = symbol;
const a = amount ;// BMX
const p = price ;// BTC
const buyOrsell = side;
// cost = amount * price = 2 * 9000 = 18000 (USD)
const order = await exchange.createOrder (s, 'market', buyOrsell, a, p);
console.log (order);
res.json(order);
} catch (e) {
if (e instanceof ccxt.NetworkError) {
console.log (exchange.id, 'createOrder failed due to a network error:', e.message)
// retry or whatever
// ...
} else if (e instanceof ccxt.ExchangeError) {
console.log (exchange.id, 'createOrder failed due to exchange error:', e.message)
// res.json(exchange.id, 'createOrder failed due to exchange error:', e.message);
// retry or whatever
// ...
} else {
console.log (exchange.id, 'createOrder failed with:', e.message)
// retry or whatever
// ...
}
}
// catch (err) {
// res.json({ message: err});
// console.log(err);
// }
}
}
bitmart createOrder failed due to exchange error: bitmart {"message":"Header X-BM-SIGN is wrong","code":30005,"trace":"74530845-d504-46b1-b1f9-1374ae11cbc6","data":{}}
where this header is given?
how to solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
uid不要是你的账户uid,填写api-memo就可以了
the uid should be not your account uid, fill in the api-memo that will be fine