0

While there are similar errors on github and here, they are older, i have signature problem while withdrawing coin from binance via API from my script. Message return as result of error :

 {Signature for this request is not valid}

I use node-binance-api for my script. Withdraw signature function being defined in this file : https://github.com/jaggedsoft/node-binance-api/blob/master/node-binance-api.js

const signedRequest = ( url, data = {}, callback, method = 'GET', noDataInSignature = false ) => {
        if ( !Binance.options.APIKEY ) throw Error( 'apiRequest: Invalid API Key' );
        if ( !Binance.options.APISECRET ) throw Error( 'signedRequest: Invalid API Secret' );
        data.timestamp = new Date().getTime() + Binance.info.timeOffset;
        if ( typeof data.recvWindow === 'undefined' ) data.recvWindow = Binance.options.recvWindow;
        let query = method === 'POST' && noDataInSignature ? '' : makeQueryString( data );
        let signature = crypto.createHmac( 'sha256', Binance.options.APISECRET ).update( query ).digest( 'hex' ); // set the HMAC hash header
        if ( method === 'POST' ) {
            let opt = reqObjPOST(
                url + '?signature=' + signature,
                data,
                method,
                Binance.options.APIKEY
            );
            proxyRequest( opt, callback );
        } else {
            let opt = reqObj(
                url + '?' + query + '&signature=' + signature,
                data,
                method,
                Binance.options.APIKEY
            );
            proxyRequest( opt, callback );
        }
    };

There is a solution here which seems like working some people: https://github.com/jaggedsoft/node-binance-api/issues/413 offers change signature method to change like this :

if ( method === 'POST' ) {
    let opt = reqObjPOST(
        url,
        data,
        method,
        Binance.options.APIKEY
    );
    opt.form.signature = signature;
    proxyRequest( opt, callback );
}

Unfortunately not worked for me and even caused trades to fail. I use withdraw function like in examples :

binance.withdraw("BTC", "1C5gqLRs96Xq4V2ZZAR1347yUCpHie7sa", 0.2)

I tested all other things like account limits, api settings, coin balance and didnt change any code but 4 days ago binance changed codes for API then withdraws started to give error. Developers of binance offers to change url to sapi https://binance-docs.github.io/apidocs/spot/en/#withdraw-sapi but also it caused same fails:

 signedRequest(sapi + 'v1/capital/withdraw/apply', params, callback, 'POST');

i dont have any problem with trade, orderbook and balance view with same signature, only withdraw gives signature error.

trmt
  • 137
  • 1
  • 14

1 Answers1

0

i noticed that my node-binance-api was not running on last version so i updated and made revision as noticed here https://github.com/jaggedsoft/node-binance-api/issues/413 then withrawals worked

trmt
  • 137
  • 1
  • 14