Commit eb6c91be by zihan

bug fixed

parent 06c8f7bb
...@@ -244,7 +244,11 @@ class biboxApi { ...@@ -244,7 +244,11 @@ class biboxApi {
_genSign(timestamp,method,path,params){ _genSign(timestamp,method,path,params){
let signStr = null; let signStr = null;
if(params){ if(params){
signStr = timestamp+method+path+JSON.stringify(params); if(method === 'GET'){
signStr = timestamp+method+path+"?"+this.transform(params)
}else{
signStr = timestamp+method+path+JSON.stringify(params);
}
}else{ }else{
signStr = timestamp+method+path; signStr = timestamp+method+path;
} }
...@@ -259,6 +263,12 @@ class biboxApi { ...@@ -259,6 +263,12 @@ class biboxApi {
} }
let url = host + path; let url = host + path;
const timestamp = Date.now()+''; const timestamp = Date.now()+'';
const requestParams = {};
if (method === 'GET' && params) {
url += '?' + this.transform(params);
}else if(method === 'POST'){
requestParams["body"] = JSON.stringify(params);
}
const sign = this._genSign(timestamp,method,path,params); const sign = this._genSign(timestamp,method,path,params);
const headers = { const headers = {
'KC-API-KEY': this.apiKey, 'KC-API-KEY': this.apiKey,
...@@ -267,12 +277,7 @@ class biboxApi { ...@@ -267,12 +277,7 @@ class biboxApi {
'KC-API-PASSPHRASE':this.pass, 'KC-API-PASSPHRASE':this.pass,
"Content-Type": "application/json" "Content-Type": "application/json"
} }
const requestParams = {};
if (method === 'GET' && params) {
url += '?' + this.transform(params);
}else if(method === 'POST'){
requestParams["body"] = JSON.stringify(params);
}
requestParams["url"] = url; requestParams["url"] = url;
requestParams["method"] = method; requestParams["method"] = method;
requestParams["headers"] = headers; requestParams["headers"] = headers;
...@@ -322,7 +327,7 @@ class biboxApi { ...@@ -322,7 +327,7 @@ class biboxApi {
} }
balance(callback) { balance(callback) {
this._request("GET", "/api/v1/accounts", null, callback); this._request("GET", "/api/v1/accounts", {type:'trade'}, callback);
} }
// coins_info(callback) { // coins_info(callback) {
......
...@@ -43,7 +43,7 @@ function testCollector(){ ...@@ -43,7 +43,7 @@ function testCollector(){
// const strategy3 = new BiboxStrategy3(collector); // const strategy3 = new BiboxStrategy3(collector);
// strategy3.run(); // strategy3.run();
} }
// testCollector(); testCollector();
function printCurrency(){ function printCurrency(){
const currentArray = [,'ETH','BTC','LTC','BCH','USDT','USD','RMB',"RCN","WINGS","TRX","LEND","CMT","POWR","HSR","GAS","RDN","TNT","OAX" const currentArray = [,'ETH','BTC','LTC','BCH','USDT','USD','RMB',"RCN","WINGS","TRX","LEND","CMT","POWR","HSR","GAS","RDN","TNT","OAX"
...@@ -141,10 +141,10 @@ function testOrder(){ ...@@ -141,10 +141,10 @@ function testOrder(){
// console.log(error); // console.log(error);
// console.log(result); // console.log(result);
// }) // })
api.balance((error,result)=>{ // api.balance((error,result)=>{
console.log(error); // console.log(error);
console.log(result); // console.log(result);
}) // })
// const sign = api._genSign('1547015186532','POST', '/api/v1/deposit-addresses',{'currency':'BTC'}) // const sign = api._genSign('1547015186532','POST', '/api/v1/deposit-addresses',{'currency':'BTC'})
// console.log(sign === '7QP/oM0ykidMdrfNEUmng8eZjg/ZvPafjIqmxiVfYu4='); // console.log(sign === '7QP/oM0ykidMdrfNEUmng8eZjg/ZvPafjIqmxiVfYu4=');
// api.balance((error,data)=>{ // api.balance((error,data)=>{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment